All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: i801: Fix a refactoring that broke a touchpad on Lenovo P1
@ 2024-03-21 14:19 Maxim Levitsky
  2024-03-21 16:11 ` Heiner Kallweit
  2024-03-21 20:41 ` Andi Shyti
  0 siblings, 2 replies; 3+ messages in thread
From: Maxim Levitsky @ 2024-03-21 14:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jean Delvare, Andi Shyti, Heiner Kallweit, linux-i2c, Maxim Levitsky

Commit 857cc04cdf50 ("i2c: i801: Add helper i801_get_block_len")
introduced a slight functional change: the status variable is now
overwritten with the length of an SMBUS tranasaction,
even in case of success.

This breaks the touchpad on at least my Lenovo P1:

rmi4_physical rmi4-00: Read PDT entry at 0x00e9 failed, code: -6.
rmi4_physical rmi4-00: RMI initial reset failed! Continuing in spite of this.
rmi4_physical rmi4-00: Read PDT entry at 0x00e9 failed, code: -6.
rmi4_physical rmi4-00: IRQ counting failed with code -6.

Fixes: 857cc04cdf50 ("i2c: i801: Add helper i801_get_block_len")

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 drivers/i2c/busses/i2c-i801.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index a6861660cb8c..79870dd7a014 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -536,11 +536,12 @@ static int i801_block_transaction_by_block(struct i801_priv *priv,
 
 	if (read_write == I2C_SMBUS_READ ||
 	    command == I2C_SMBUS_BLOCK_PROC_CALL) {
-		status = i801_get_block_len(priv);
-		if (status < 0)
+		len = i801_get_block_len(priv);
+		if (len < 0) {
+			status = len;
 			goto out;
+		}
 
-		len = status;
 		data->block[0] = len;
 		inb_p(SMBHSTCNT(priv));	/* reset the data buffer index */
 		for (i = 0; i < len; i++)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: i801: Fix a refactoring that broke a touchpad on Lenovo P1
  2024-03-21 14:19 [PATCH] i2c: i801: Fix a refactoring that broke a touchpad on Lenovo P1 Maxim Levitsky
@ 2024-03-21 16:11 ` Heiner Kallweit
  2024-03-21 20:41 ` Andi Shyti
  1 sibling, 0 replies; 3+ messages in thread
From: Heiner Kallweit @ 2024-03-21 16:11 UTC (permalink / raw)
  To: Maxim Levitsky, Jean Delvare, Andi Shyti; +Cc: linux-i2c, linux-kernel

On 21.03.2024 15:19, Maxim Levitsky wrote:
> Commit 857cc04cdf50 ("i2c: i801: Add helper i801_get_block_len")
> introduced a slight functional change: the status variable is now
> overwritten with the length of an SMBUS tranasaction,
> even in case of success.
> 
> This breaks the touchpad on at least my Lenovo P1:
> 
> rmi4_physical rmi4-00: Read PDT entry at 0x00e9 failed, code: -6.
> rmi4_physical rmi4-00: RMI initial reset failed! Continuing in spite of this.
> rmi4_physical rmi4-00: Read PDT entry at 0x00e9 failed, code: -6.
> rmi4_physical rmi4-00: IRQ counting failed with code -6.
> 
> Fixes: 857cc04cdf50 ("i2c: i801: Add helper i801_get_block_len")
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  drivers/i2c/busses/i2c-i801.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
> index a6861660cb8c..79870dd7a014 100644
> --- a/drivers/i2c/busses/i2c-i801.c
> +++ b/drivers/i2c/busses/i2c-i801.c
> @@ -536,11 +536,12 @@ static int i801_block_transaction_by_block(struct i801_priv *priv,
>  
>  	if (read_write == I2C_SMBUS_READ ||
>  	    command == I2C_SMBUS_BLOCK_PROC_CALL) {
> -		status = i801_get_block_len(priv);
> -		if (status < 0)
> +		len = i801_get_block_len(priv);
> +		if (len < 0) {
> +			status = len;
>  			goto out;
> +		}
>  
> -		len = status;
>  		data->block[0] = len;
>  		inb_p(SMBHSTCNT(priv));	/* reset the data buffer index */
>  		for (i = 0; i < len; i++)

Indeed, my bad.

Reviewed-by: Heiner Kallweit <hkallweit1@gmail.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: i801: Fix a refactoring that broke a touchpad on Lenovo P1
  2024-03-21 14:19 [PATCH] i2c: i801: Fix a refactoring that broke a touchpad on Lenovo P1 Maxim Levitsky
  2024-03-21 16:11 ` Heiner Kallweit
@ 2024-03-21 20:41 ` Andi Shyti
  1 sibling, 0 replies; 3+ messages in thread
From: Andi Shyti @ 2024-03-21 20:41 UTC (permalink / raw)
  To: Maxim Levitsky; +Cc: linux-kernel, Jean Delvare, Heiner Kallweit, linux-i2c

Hi Maxim,

On Thu, Mar 21, 2024 at 10:19:19AM -0400, Maxim Levitsky wrote:
> Commit 857cc04cdf50 ("i2c: i801: Add helper i801_get_block_len")
> introduced a slight functional change: the status variable is now
> overwritten with the length of an SMBUS tranasaction,
> even in case of success.
> 
> This breaks the touchpad on at least my Lenovo P1:
> 
> rmi4_physical rmi4-00: Read PDT entry at 0x00e9 failed, code: -6.
> rmi4_physical rmi4-00: RMI initial reset failed! Continuing in spite of this.
> rmi4_physical rmi4-00: Read PDT entry at 0x00e9 failed, code: -6.
> rmi4_physical rmi4-00: IRQ counting failed with code -6.
> 
> Fixes: 857cc04cdf50 ("i2c: i801: Add helper i801_get_block_len")
> 

next time please drop this blank line here.

Applied to i2c/i2c-host-fixes on

git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git

Thank you,
Andi

Patches applied
===============
[1/1] i2c: i801: Fix a refactoring that broke a touchpad on Lenovo P1
      commit: a5894bc48f64caa86dbea1744d067c925303c5fc

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-21 20:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-21 14:19 [PATCH] i2c: i801: Fix a refactoring that broke a touchpad on Lenovo P1 Maxim Levitsky
2024-03-21 16:11 ` Heiner Kallweit
2024-03-21 20:41 ` Andi Shyti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.