Skip to content

Commit 77da21c

Browse files
jinglewudtor
authored andcommitted
Input: elan_i2c - handle firmware not implementing "get pattern" command
Not all versions of firmware implement "get pattern" command. When encountering those assume that the controllers use older pattern. Signed-off-by: Jingle Wu <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 3d77e6a commit 77da21c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/input/mouse/elan_i2c_i2c.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,13 @@ static int elan_i2c_get_pattern(struct i2c_client *client, u8 *pattern)
249249
dev_err(&client->dev, "failed to get pattern: %d\n", error);
250250
return error;
251251
}
252-
*pattern = val[1];
252+
253+
/*
254+
* Not all versions of firmware implement "get pattern" command.
255+
* When this command is not implemented the device will respond
256+
* with 0xFF 0xFF, which we will treat as "old" pattern 0.
257+
*/
258+
*pattern = val[0] == 0xFF && val[1] == 0xFF ? 0 : val[1];
253259

254260
return 0;
255261
}

0 commit comments

Comments
 (0)