Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934159AbbDUQ0s (ORCPT ); Tue, 21 Apr 2015 12:26:48 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57149 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755671AbbDUPcy (ORCPT ); Tue, 21 Apr 2015 11:32:54 -0400 From: Luis Henriques To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Hans de Goede , Dmitry Torokhov , Luis Henriques Subject: [PATCH 3.16.y-ckt 023/144] Input: psmouse - add psmouse_matches_pnp_id helper function Date: Tue, 21 Apr 2015 16:30:08 +0100 Message-Id: <1429630329-21748-24-git-send-email-luis.henriques@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429630329-21748-1-git-send-email-luis.henriques@canonical.com> References: <1429630329-21748-1-git-send-email-luis.henriques@canonical.com> X-Extended-Stable: 3.16 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4038 Lines: 106 3.16.7-ckt10 -stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans de Goede commit 2c75ada6250990ea859b0b5498cb0b7c2823a9d7 upstream. The matches_pnp_id function from the synaptics driver is useful for other drivers too. Make it a generic psmouse helper function. Signed-off-by: Hans de Goede Signed-off-by: Dmitry Torokhov [ luis: 3.16-stable prereq for: 8b04baba10b0 "Input: synaptics - split synaptics_resolution(), query first" ] Signed-off-by: Luis Henriques --- drivers/input/mouse/psmouse-base.c | 14 ++++++++++++++ drivers/input/mouse/psmouse.h | 1 + drivers/input/mouse/synaptics.c | 17 +++-------------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index cff065f6261c..bc1bc2653f15 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -462,6 +462,20 @@ static int psmouse_poll(struct psmouse *psmouse) PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)); } +/* + * 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; + + return false; +} /* * Genius NetMouse magic init. diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index 2f0b39d59a9b..f4cf664c7db3 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h @@ -108,6 +108,7 @@ void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse); int psmouse_activate(struct psmouse *psmouse); int psmouse_deactivate(struct psmouse *psmouse); +bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[]); struct psmouse_attribute { struct device_attribute dattr; diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index e5feafb0949f..30eabf9f7086 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -188,18 +188,6 @@ static const char * const topbuttonpad_pnp_ids[] = { NULL }; -static bool 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; - - return false; -} - /***************************************************************************** * Synaptics communications functions ****************************************************************************/ @@ -365,7 +353,8 @@ static int synaptics_resolution(struct psmouse *psmouse) } for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) { - if (matches_pnp_id(psmouse, min_max_pnpid_table[i].pnp_ids)) { + if (psmouse_matches_pnp_id(psmouse, + min_max_pnpid_table[i].pnp_ids)) { priv->x_min = min_max_pnpid_table[i].x_min; priv->x_max = min_max_pnpid_table[i].x_max; priv->y_min = min_max_pnpid_table[i].y_min; @@ -1448,7 +1437,7 @@ static void set_input_params(struct psmouse *psmouse, if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) { __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); - if (matches_pnp_id(psmouse, topbuttonpad_pnp_ids)) + if (psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids)) __set_bit(INPUT_PROP_TOPBUTTONPAD, dev->propbit); /* Clickpads report only left button */ __clear_bit(BTN_RIGHT, dev->keybit); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/