Takashi Iwai f32639
From a284e11c371e446371675668d8c8120a27227339 Mon Sep 17 00:00:00 2001
Takashi Iwai f32639
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Takashi Iwai f32639
Date: Mon, 2 Dec 2019 10:08:12 -0800
Takashi Iwai f32639
Subject: [PATCH] Input: synaptics-rmi4 - don't increment rmiaddr for SMBus transfers
Takashi Iwai f32639
Git-commit: a284e11c371e446371675668d8c8120a27227339
Takashi Iwai f32639
Patch-mainline: v5.5-rc1
Takashi Iwai f32639
References: bsc#1051510
Takashi Iwai f32639
Takashi Iwai f32639
This increment of rmi_smbus in rmi_smb_read/write_block() causes
Takashi Iwai f32639
garbage to be read/written.
Takashi Iwai f32639
Takashi Iwai f32639
The first read of SMB_MAX_COUNT bytes is fine, but after that
Takashi Iwai f32639
it is nonsense. Trial-and-error showed that by dropping the
Takashi Iwai f32639
increment of rmiaddr everything is fine and the F54 function
Takashi Iwai f32639
properly works.
Takashi Iwai f32639
Takashi Iwai f32639
I tried a hack with rmi_smb_write_block() as well (writing to the
Takashi Iwai f32639
same F54 touchpad data area, then reading it back), and that
Takashi Iwai f32639
suggests that there too the rmiaddr increment has to be dropped.
Takashi Iwai f32639
It makes sense that if it has to be dropped for read, then it has
Takashi Iwai f32639
to be dropped for write as well.
Takashi Iwai f32639
Takashi Iwai f32639
It looks like the initial work with F54 was done using i2c, not smbus,
Takashi Iwai f32639
and it seems nobody ever tested F54 with smbus. The other functions
Takashi Iwai f32639
all read/write less than SMB_MAX_COUNT as far as I can tell, so this
Takashi Iwai f32639
issue was never noticed with non-F54 functions.
Takashi Iwai f32639
Takashi Iwai f32639
With this change I can read out the touchpad data correctly on my
Takashi Iwai f32639
Lenovo X1 Carbon 6th Gen laptop.
Takashi Iwai f32639
Takashi Iwai f32639
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Takashi Iwai f32639
Link: https://lore.kernel.org/r/8dd22e21-4933-8e9c-a696-d281872c8de7@xs4all.nl
Takashi Iwai f32639
Cc: stable@vger.kernel.org
Takashi Iwai f32639
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Takashi Iwai f32639
Acked-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai f32639
Takashi Iwai f32639
---
Takashi Iwai f32639
 drivers/input/rmi4/rmi_smbus.c | 2 --
Takashi Iwai f32639
 1 file changed, 2 deletions(-)
Takashi Iwai f32639
Takashi Iwai f32639
diff --git a/drivers/input/rmi4/rmi_smbus.c b/drivers/input/rmi4/rmi_smbus.c
Takashi Iwai f32639
index 2407ea43de59..b313c579914f 100644
Takashi Iwai f32639
--- a/drivers/input/rmi4/rmi_smbus.c
Takashi Iwai f32639
+++ b/drivers/input/rmi4/rmi_smbus.c
Takashi Iwai f32639
@@ -163,7 +163,6 @@ static int rmi_smb_write_block(struct rmi_transport_dev *xport, u16 rmiaddr,
Takashi Iwai f32639
 		/* prepare to write next block of bytes */
Takashi Iwai f32639
 		cur_len -= SMB_MAX_COUNT;
Takashi Iwai f32639
 		databuff += SMB_MAX_COUNT;
Takashi Iwai f32639
-		rmiaddr += SMB_MAX_COUNT;
Takashi Iwai f32639
 	}
Takashi Iwai f32639
 exit:
Takashi Iwai f32639
 	mutex_unlock(&rmi_smb->page_mutex);
Takashi Iwai f32639
@@ -215,7 +214,6 @@ static int rmi_smb_read_block(struct rmi_transport_dev *xport, u16 rmiaddr,
Takashi Iwai f32639
 		/* prepare to read next block of bytes */
Takashi Iwai f32639
 		cur_len -= SMB_MAX_COUNT;
Takashi Iwai f32639
 		databuff += SMB_MAX_COUNT;
Takashi Iwai f32639
-		rmiaddr += SMB_MAX_COUNT;
Takashi Iwai f32639
 	}
Takashi Iwai f32639
 
Takashi Iwai f32639
 	retval = 0;
Takashi Iwai f32639
-- 
Takashi Iwai f32639
2.16.4
Takashi Iwai f32639