Commit a0e625f8b7fd3fbffcb3af36fb1f88ea059ee6a6
Committed by
Jiri Kosina
1 parent
8abd820503
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
HID: logitech-hidpp: prefix the name with "Logitech"
Current names are reported as "K750", "M705", and it can be misleading for the users when they look at their input device list. Prefixing the names with "Logitech " makes things better. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Showing 1 changed file with 34 additions and 0 deletions Side-by-side Diff
drivers/hid/hid-logitech-hidpp.c
... | ... | @@ -282,6 +282,33 @@ |
282 | 282 | (report->rap.sub_id == 0x41); |
283 | 283 | } |
284 | 284 | |
285 | +/** | |
286 | + * hidpp_prefix_name() prefixes the current given name with "Logitech ". | |
287 | + */ | |
288 | +static void hidpp_prefix_name(char **name, int name_length) | |
289 | +{ | |
290 | +#define PREFIX_LENGTH 9 /* "Logitech " */ | |
291 | + | |
292 | + int new_length; | |
293 | + char *new_name; | |
294 | + | |
295 | + if (name_length > PREFIX_LENGTH && | |
296 | + strncmp(*name, "Logitech ", PREFIX_LENGTH) == 0) | |
297 | + /* The prefix has is already in the name */ | |
298 | + return; | |
299 | + | |
300 | + new_length = PREFIX_LENGTH + name_length; | |
301 | + new_name = kzalloc(new_length, GFP_KERNEL); | |
302 | + if (!new_name) | |
303 | + return; | |
304 | + | |
305 | + snprintf(new_name, new_length, "Logitech %s", *name); | |
306 | + | |
307 | + kfree(*name); | |
308 | + | |
309 | + *name = new_name; | |
310 | +} | |
311 | + | |
285 | 312 | /* -------------------------------------------------------------------------- */ |
286 | 313 | /* HIDP++ 1.0 commands */ |
287 | 314 | /* -------------------------------------------------------------------------- */ |
... | ... | @@ -321,6 +348,10 @@ |
321 | 348 | return NULL; |
322 | 349 | |
323 | 350 | memcpy(name, &response.rap.params[2], len); |
351 | + | |
352 | + /* include the terminating '\0' */ | |
353 | + hidpp_prefix_name(&name, len + 1); | |
354 | + | |
324 | 355 | return name; |
325 | 356 | } |
326 | 357 | |
... | ... | @@ -497,6 +528,9 @@ |
497 | 528 | } |
498 | 529 | index += ret; |
499 | 530 | } |
531 | + | |
532 | + /* include the terminating '\0' */ | |
533 | + hidpp_prefix_name(&name, __name_length + 1); | |
500 | 534 | |
501 | 535 | return name; |
502 | 536 | } |