Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Benjamin Tissoires and committed by
Jiri Kosina
a0e625f8 8abd8205

+34
+34
drivers/hid/hid-logitech-hidpp.c
··· 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 /* -------------------------------------------------------------------------- */ ··· 348 321 return NULL; 349 322 350 323 memcpy(name, &response.rap.params[2], len); 324 + 325 + /* include the terminating '\0' */ 326 + hidpp_prefix_name(&name, len + 1); 327 + 351 328 return name; 352 329 } 353 330 ··· 528 497 } 529 498 index += ret; 530 499 } 500 + 501 + /* include the terminating '\0' */ 502 + hidpp_prefix_name(&name, __name_length + 1); 531 503 532 504 return name; 533 505 }