a1ef73d
From: Daniel Martin <consume.noise@gmail.com>
a1ef73d
Date: Sun, 8 Mar 2015 22:27:37 -0700
a1ef73d
Subject: [PATCH] Input: synaptics - split synaptics_resolution(), query first
a1ef73d
a1ef73d
Split the function synaptics_resolution() into synaptics_resolution() and
a1ef73d
synaptics_quirks().  synaptics_resolution() will be called before
a1ef73d
synaptics_quirks() to query dimensions and resolutions before overwriting
a1ef73d
them with quirks.
a1ef73d
a1ef73d
Cc: stable@vger.kernel.org
a1ef73d
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
a1ef73d
Acked-by: Hans de Goede <hdegoede@redhat.com>
a1ef73d
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
a1ef73d
---
a1ef73d
 drivers/input/mouse/synaptics.c | 35 +++++++++++++++++++++++------------
a1ef73d
 1 file changed, 23 insertions(+), 12 deletions(-)
a1ef73d
a1ef73d
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
a1ef73d
index 23e26e0768b5..b501dda75dcb 100644
a1ef73d
--- a/drivers/input/mouse/synaptics.c
a1ef73d
+++ b/drivers/input/mouse/synaptics.c
a1ef73d
@@ -343,7 +343,6 @@ static int synaptics_resolution(struct psmouse *psmouse)
a1ef73d
 {
a1ef73d
 	struct synaptics_data *priv = psmouse->private;
a1ef73d
 	unsigned char resp[3];
a1ef73d
-	int i;
a1ef73d
 
a1ef73d
 	if (SYN_ID_MAJOR(priv->identity) < 4)
a1ef73d
 		return 0;
a1ef73d
@@ -355,17 +354,6 @@ static int synaptics_resolution(struct psmouse *psmouse)
a1ef73d
 		}
a1ef73d
 	}
a1ef73d
 
a1ef73d
-	for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
a1ef73d
-		if (psmouse_matches_pnp_id(psmouse,
a1ef73d
-					   min_max_pnpid_table[i].pnp_ids)) {
a1ef73d
-			priv->x_min = min_max_pnpid_table[i].x_min;
a1ef73d
-			priv->x_max = min_max_pnpid_table[i].x_max;
a1ef73d
-			priv->y_min = min_max_pnpid_table[i].y_min;
a1ef73d
-			priv->y_max = min_max_pnpid_table[i].y_max;
a1ef73d
-			return 0;
a1ef73d
-		}
a1ef73d
-	}
a1ef73d
-
a1ef73d
 	if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 5 &&
a1ef73d
 	    SYN_CAP_MAX_DIMENSIONS(priv->ext_cap_0c)) {
a1ef73d
 		if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MAX_COORDS, resp)) {
a1ef73d
@@ -391,6 +379,27 @@ static int synaptics_resolution(struct psmouse *psmouse)
a1ef73d
 	return 0;
a1ef73d
 }
a1ef73d
 
a1ef73d
+/*
a1ef73d
+ * Apply quirk(s) if the hardware matches
a1ef73d
+ */
a1ef73d
+
a1ef73d
+static void synaptics_apply_quirks(struct psmouse *psmouse)
a1ef73d
+{
a1ef73d
+	struct synaptics_data *priv = psmouse->private;
a1ef73d
+	int i;
a1ef73d
+
a1ef73d
+	for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
a1ef73d
+		if (psmouse_matches_pnp_id(psmouse,
a1ef73d
+					   min_max_pnpid_table[i].pnp_ids)) {
a1ef73d
+			priv->x_min = min_max_pnpid_table[i].x_min;
a1ef73d
+			priv->x_max = min_max_pnpid_table[i].x_max;
a1ef73d
+			priv->y_min = min_max_pnpid_table[i].y_min;
a1ef73d
+			priv->y_max = min_max_pnpid_table[i].y_max;
a1ef73d
+			break;
a1ef73d
+		}
a1ef73d
+	}
a1ef73d
+}
a1ef73d
+
a1ef73d
 static int synaptics_query_hardware(struct psmouse *psmouse)
a1ef73d
 {
a1ef73d
 	if (synaptics_identify(psmouse))
a1ef73d
@@ -406,6 +415,8 @@ static int synaptics_query_hardware(struct psmouse *psmouse)
a1ef73d
 	if (synaptics_resolution(psmouse))
a1ef73d
 		return -1;
a1ef73d
 
a1ef73d
+	synaptics_apply_quirks(psmouse);
a1ef73d
+
a1ef73d
 	return 0;
a1ef73d
 }
a1ef73d
 
a1ef73d
-- 
a1ef73d
2.1.0
a1ef73d