80e48d0
From: Daniel Martin <daniel.martin@secunet.com>
80e48d0
Date: Sun, 8 Mar 2015 22:29:15 -0700
80e48d0
Subject: [PATCH] Input: synaptics - support min/max board id in
80e48d0
 min_max_pnpid_table
80e48d0
80e48d0
Add a min/max range for board ids to the min/max coordinates quirk. This
80e48d0
makes it possible to restrict quirks to specific models based upon their
80e48d0
board id. The define ANY_BOARD_ID (0) serves as a wild card.
80e48d0
80e48d0
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=91541
80e48d0
80e48d0
Cc: stable@vger.kernel.org
80e48d0
Signed-off-by: Daniel Martin <daniel.martin@secunet.com>
80e48d0
Acked-by: Hans de Goede <hdegoede@redhat.com>
80e48d0
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
80e48d0
---
80e48d0
 drivers/input/mouse/synaptics.c | 42 +++++++++++++++++++++++++++++------------
80e48d0
 1 file changed, 30 insertions(+), 12 deletions(-)
80e48d0
80e48d0
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
80e48d0
index 382678ae3363..aeccd562a2e3 100644
80e48d0
--- a/drivers/input/mouse/synaptics.c
80e48d0
+++ b/drivers/input/mouse/synaptics.c
80e48d0
@@ -123,32 +123,41 @@ void synaptics_reset(struct psmouse *psmouse)
80e48d0
 
80e48d0
 static bool cr48_profile_sensor;
80e48d0
 
80e48d0
+#define ANY_BOARD_ID 0
80e48d0
 struct min_max_quirk {
80e48d0
 	const char * const *pnp_ids;
80e48d0
+	struct {
80e48d0
+		unsigned long int min, max;
80e48d0
+	} board_id;
80e48d0
 	int x_min, x_max, y_min, y_max;
80e48d0
 };
80e48d0
 
80e48d0
 static const struct min_max_quirk min_max_pnpid_table[] = {
80e48d0
 	{
80e48d0
 		(const char * const []){"LEN0033", NULL},
80e48d0
+		{ANY_BOARD_ID, ANY_BOARD_ID},
80e48d0
 		1024, 5052, 2258, 4832
80e48d0
 	},
80e48d0
 	{
80e48d0
 		(const char * const []){"LEN0042", NULL},
80e48d0
+		{ANY_BOARD_ID, ANY_BOARD_ID},
80e48d0
 		1232, 5710, 1156, 4696
80e48d0
 	},
80e48d0
 	{
80e48d0
 		(const char * const []){"LEN0034", "LEN0036", "LEN0037",
80e48d0
 					"LEN0039", "LEN2002", "LEN2004",
80e48d0
 					NULL},
80e48d0
+		{ANY_BOARD_ID, ANY_BOARD_ID},
80e48d0
 		1024, 5112, 2024, 4832
80e48d0
 	},
80e48d0
 	{
80e48d0
 		(const char * const []){"LEN2001", NULL},
80e48d0
+		{ANY_BOARD_ID, ANY_BOARD_ID},
80e48d0
 		1024, 5022, 2508, 4832
80e48d0
 	},
80e48d0
 	{
80e48d0
 		(const char * const []){"LEN2006", NULL},
80e48d0
+		{ANY_BOARD_ID, ANY_BOARD_ID},
80e48d0
 		1264, 5675, 1171, 4688
80e48d0
 	},
80e48d0
 	{ }
80e48d0
@@ -404,18 +413,27 @@ static void synaptics_apply_quirks(struct psmouse *psmouse)
80e48d0
 	int i;
80e48d0
 
80e48d0
 	for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
80e48d0
-		if (psmouse_matches_pnp_id(psmouse,
80e48d0
-					   min_max_pnpid_table[i].pnp_ids)) {
80e48d0
-			priv->x_min = min_max_pnpid_table[i].x_min;
80e48d0
-			priv->x_max = min_max_pnpid_table[i].x_max;
80e48d0
-			priv->y_min = min_max_pnpid_table[i].y_min;
80e48d0
-			priv->y_max = min_max_pnpid_table[i].y_max;
80e48d0
-			psmouse_info(psmouse,
80e48d0
-				     "quirked min/max coordinates: x [%d..%d], y [%d..%d]\n",
80e48d0
-				     priv->x_min, priv->x_max,
80e48d0
-				     priv->y_min, priv->y_max);
80e48d0
-			break;
80e48d0
-		}
80e48d0
+		if (!psmouse_matches_pnp_id(psmouse,
80e48d0
+					    min_max_pnpid_table[i].pnp_ids))
80e48d0
+			continue;
80e48d0
+
80e48d0
+		if (min_max_pnpid_table[i].board_id.min != ANY_BOARD_ID &&
80e48d0
+		    priv->board_id < min_max_pnpid_table[i].board_id.min)
80e48d0
+			continue;
80e48d0
+
80e48d0
+		if (min_max_pnpid_table[i].board_id.max != ANY_BOARD_ID &&
80e48d0
+		    priv->board_id > min_max_pnpid_table[i].board_id.max)
80e48d0
+			continue;
80e48d0
+
80e48d0
+		priv->x_min = min_max_pnpid_table[i].x_min;
80e48d0
+		priv->x_max = min_max_pnpid_table[i].x_max;
80e48d0
+		priv->y_min = min_max_pnpid_table[i].y_min;
80e48d0
+		priv->y_max = min_max_pnpid_table[i].y_max;
80e48d0
+		psmouse_info(psmouse,
80e48d0
+			     "quirked min/max coordinates: x [%d..%d], y [%d..%d]\n",
80e48d0
+			     priv->x_min, priv->x_max,
80e48d0
+			     priv->y_min, priv->y_max);
80e48d0
+		break;
80e48d0
 	}
80e48d0
 }
80e48d0
 
80e48d0
-- 
80e48d0
2.1.0
80e48d0