diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-02-27 16:17:59 -0800 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2015-03-06 11:25:31 -0800 |
commit | 99e14c1e23108c34c4216d68c488fcd937310c32 (patch) | |
tree | c04c4ab84d37eb4e41b93a85e8dada4b0c16e577 /drivers/input | |
parent | d7535ffa427b8976b2d41f8d9f7fb9f1c97d786c (diff) | |
download | linux-99e14c1e23108c34c4216d68c488fcd937310c32.tar.gz linux-99e14c1e23108c34c4216d68c488fcd937310c32.tar.bz2 linux-99e14c1e23108c34c4216d68c488fcd937310c32.zip |
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')
-rw-r--r-- | drivers/input/mouse/psmouse-base.c | 40 |
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) PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)); } +static bool psmouse_check_pnp_id(const char *id, const char * const ids[]) +{ + int i; + + for (i = 0; ids[i]; i++) + if (!strcasecmp(id, ids[i])) + return true; + + return false; +} + /* * psmouse_matches_pnp_id - check if psmouse matches one of the passed in ids. */ bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[]) { - int i; - - if (!strncmp(psmouse->ps2dev.serio->firmware_id, "PNP:", 4)) - for (i = 0; ids[i]; i++) - if (strstr(psmouse->ps2dev.serio->firmware_id, ids[i])) - return true; + struct serio *serio = psmouse->ps2dev.serio; + char *p, *fw_id_copy, *save_ptr; + bool found = false; + + if (strncmp(serio->firmware_id, "PNP: ", 5)) + return false; + + fw_id_copy = kstrndup(&serio->firmware_id[5], + sizeof(serio->firmware_id) - 5, + GFP_KERNEL); + if (!fw_id_copy) + return false; + + save_ptr = fw_id_copy; + while ((p = strsep(&fw_id_copy, " ")) != NULL) { + if (psmouse_check_pnp_id(p, ids)) { + found = true; + break; + } + } - return false; + kfree(save_ptr); + return found; } /* |