5fd2783
From: Hans de Goede <hdegoede@redhat.com>
5fd2783
Date: Fri, 27 Jun 2014 18:46:42 +0200
dbc4a9b
Subject: [PATCH] psmouse: Add psmouse_matches_pnp_id helper function
5fd2783
5fd2783
The matches_pnp_id function from the synaptics driver is useful for other
5fd2783
drivers too. Make it a generic psmouse helper function.
5fd2783
5fd2783
Bugzilla: 1110011
5fd2783
Upstream-status: sent for 3.17/3.18
5fd2783
5fd2783
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5fd2783
---
5fd2783
 drivers/input/mouse/psmouse-base.c | 14 ++++++++++++++
5fd2783
 drivers/input/mouse/psmouse.h      |  1 +
5fd2783
 drivers/input/mouse/synaptics.c    | 17 +++--------------
5fd2783
 3 files changed, 18 insertions(+), 14 deletions(-)
5fd2783
5fd2783
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
dbc4a9b
index b4e1f014ddc2..02e68c3008a3 100644
5fd2783
--- a/drivers/input/mouse/psmouse-base.c
5fd2783
+++ b/drivers/input/mouse/psmouse-base.c
5fd2783
@@ -462,6 +462,20 @@ static int psmouse_poll(struct psmouse *psmouse)
5fd2783
 			   PSMOUSE_CMD_POLL | (psmouse->pktsize << 8));
5fd2783
 }
5fd2783
 
5fd2783
+/*
5fd2783
+ * psmouse_matches_pnp_id - check if psmouse matches one of the passed in ids.
5fd2783
+ */
5fd2783
+bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[])
5fd2783
+{
5fd2783
+	int i;
5fd2783
+
5fd2783
+	if (!strncmp(psmouse->ps2dev.serio->firmware_id, "PNP:", 4))
5fd2783
+		for (i = 0; ids[i]; i++)
5fd2783
+			if (strstr(psmouse->ps2dev.serio->firmware_id, ids[i]))
5fd2783
+				return true;
5fd2783
+
5fd2783
+	return false;
5fd2783
+}
5fd2783
 
5fd2783
 /*
5fd2783
  * Genius NetMouse magic init.
5fd2783
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
5fd2783
index 2f0b39d59a9b..f4cf664c7db3 100644
5fd2783
--- a/drivers/input/mouse/psmouse.h
5fd2783
+++ b/drivers/input/mouse/psmouse.h
5fd2783
@@ -108,6 +108,7 @@ void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
5fd2783
 psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse);
5fd2783
 int psmouse_activate(struct psmouse *psmouse);
5fd2783
 int psmouse_deactivate(struct psmouse *psmouse);
5fd2783
+bool psmouse_matches_pnp_id(struct psmouse *psmouse, const char * const ids[]);
5fd2783
 
5fd2783
 struct psmouse_attribute {
5fd2783
 	struct device_attribute dattr;
5fd2783
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
dbc4a9b
index fd23181c1fb7..6394d9b5bfd3 100644
5fd2783
--- a/drivers/input/mouse/synaptics.c
5fd2783
+++ b/drivers/input/mouse/synaptics.c
5fd2783
@@ -185,18 +185,6 @@ static const char * const topbuttonpad_pnp_ids[] = {
5fd2783
 	NULL
5fd2783
 };
5fd2783
 
5fd2783
-static bool matches_pnp_id(struct psmouse *psmouse, const char * const ids[])
5fd2783
-{
5fd2783
-	int i;
5fd2783
-
5fd2783
-	if (!strncmp(psmouse->ps2dev.serio->firmware_id, "PNP:", 4))
5fd2783
-		for (i = 0; ids[i]; i++)
5fd2783
-			if (strstr(psmouse->ps2dev.serio->firmware_id, ids[i]))
5fd2783
-				return true;
5fd2783
-
5fd2783
-	return false;
5fd2783
-}
5fd2783
-
5fd2783
 /*****************************************************************************
5fd2783
  *	Synaptics communications functions
5fd2783
  ****************************************************************************/
5fd2783
@@ -362,7 +350,8 @@ static int synaptics_resolution(struct psmouse *psmouse)
5fd2783
 	}
5fd2783
 
5fd2783
 	for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
5fd2783
-		if (matches_pnp_id(psmouse, min_max_pnpid_table[i].pnp_ids)) {
5fd2783
+		if (psmouse_matches_pnp_id(psmouse,
5fd2783
+					   min_max_pnpid_table[i].pnp_ids)) {
5fd2783
 			priv->x_min = min_max_pnpid_table[i].x_min;
5fd2783
 			priv->x_max = min_max_pnpid_table[i].x_max;
5fd2783
 			priv->y_min = min_max_pnpid_table[i].y_min;
dbc4a9b
@@ -1492,7 +1481,7 @@ static void set_input_params(struct psmouse *psmouse,
5fd2783
 
5fd2783
 	if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
5fd2783
 		__set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
5fd2783
-		if (matches_pnp_id(psmouse, topbuttonpad_pnp_ids))
5fd2783
+		if (psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids))
5fd2783
 			__set_bit(INPUT_PROP_TOPBUTTONPAD, dev->propbit);
5fd2783
 		/* Clickpads report only left button */
5fd2783
 		__clear_bit(BTN_RIGHT, dev->keybit);
5fd2783
-- 
5fd2783
1.9.3
5fd2783