Blob Blame History Raw
From 77da21c5d3c698f5c9ce41d57c137244bc8b7b93 Mon Sep 17 00:00:00 2001
From: Jingle Wu <jingle.wu@emc.com.tw>
Date: Wed, 15 Jul 2020 17:40:27 -0700
Subject: [PATCH] Input: elan_i2c - handle firmware not implementing "get pattern" command
Git-commit: 77da21c5d3c698f5c9ce41d57c137244bc8b7b93
Patch-mainline: v5.9-rc1
References: bsc#1180870

Not all versions of firmware implement "get pattern" command. When
encountering those assume that the controllers use older pattern.

Signed-off-by: Jingle Wu <jingle.wu@emc.com.tw>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/input/mouse/elan_i2c_i2c.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/elan_i2c_i2c.c b/drivers/input/mouse/elan_i2c_i2c.c
index 058b35b1f9a9..0d8a6a1b30d7 100644
--- a/drivers/input/mouse/elan_i2c_i2c.c
+++ b/drivers/input/mouse/elan_i2c_i2c.c
@@ -249,7 +249,13 @@ static int elan_i2c_get_pattern(struct i2c_client *client, u8 *pattern)
 		dev_err(&client->dev, "failed to get pattern: %d\n", error);
 		return error;
 	}
-	*pattern = val[1];
+
+	/*
+	 * Not all versions of firmware implement "get pattern" command.
+	 * When this command is not implemented the device will respond
+	 * with 0xFF 0xFF, which we will treat as "old" pattern 0.
+	 */
+	*pattern = val[0] == 0xFF && val[1] == 0xFF ? 0 : val[1];
 
 	return 0;
 }
-- 
2.26.2