aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2015-02-27 19:17:59 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-03-06 14:25:31 -0500
commit99e14c1e23108c34c4216d68c488fcd937310c32 (patch)
treec04c4ab84d37eb4e41b93a85e8dada4b0c16e577 /drivers/input/mouse
parentd7535ffa427b8976b2d41f8d9f7fb9f1c97d786c (diff)
Input: psmouse - when comparing PNP IDs ignore case
PNP IDs are supposed to be case-insensitive and so we should compare them as such. Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r--drivers/input/mouse/psmouse-base.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 4ccd01d7a48d..bd91a8efa0f1 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -463,19 +463,45 @@ static int psmouse_poll(struct psmouse *psmouse)
463 PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)); 463 PSMOUSE_CMD_POLL | (psmouse->pktsize << 8));
464} 464}
465 465
466static bool psmouse_check_pnp_id(const char *id, const char * const ids[])
467{
468 int i;
469
470 for (i = 0; ids[i]; i++)
471 if (!strcasecmp(id, ids[i]))
472 return true;
473
474 return false;
475}
476
466/* 477/*
467 * psmouse_matches_pnp_id - check if psmouse matches one of the passed in ids. 478 * psmouse_matches_pnp_id - check if psmouse matches one of the passed in ids.
468 */ 479 */
469bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[]) 480bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[])
470{ 481{
471 int i; 482 struct serio *serio = psmouse->ps2dev.serio;
472 483 char *p, *fw_id_copy, *save_ptr;
473 if (!strncmp(psmouse->ps2dev.serio->firmware_id, "PNP:", 4)) 484 bool found = false;
474 for (i = 0; ids[i]; i++) 485
475 if (strstr(psmouse->ps2dev.serio->firmware_id, ids[i])) 486 if (strncmp(serio->firmware_id, "PNP: ", 5))
476 return true; 487 return false;
488
489 fw_id_copy = kstrndup(&serio->firmware_id[5],
490 sizeof(serio->firmware_id) - 5,
491 GFP_KERNEL);
492 if (!fw_id_copy)
493 return false;
494
495 save_ptr = fw_id_copy;
496 while ((p = strsep(&fw_id_copy, " ")) != NULL) {
497 if (psmouse_check_pnp_id(p, ids)) {
498 found = true;
499 break;
500 }
501 }
477 502
478 return false; 503 kfree(save_ptr);
504 return found;
479} 505}
480 506
481/* 507/*