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