mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] HID: mcp2221: cancel last I2C command on read error
@ 2026-02-06 16:32 Romain Sioen
  2026-02-27 17:54 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Romain Sioen @ 2026-02-06 16:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: gupt21, jikos, Romain Sioen

When an I2C SMBus read operation fails, the MCP2221 internal state machine
may not reset correctly, causing subsequent transactions to fail.

By adding a short delay and explicitly cancelling the last command,
we ensure the device is ready for the next operation.

Fix an issue where i2cdetect was not able to detect all devices correctly
on the bus.

Signed-off-by: Romain Sioen <romain.sioen@microchip.com>
---
 drivers/hid/hid-mcp2221.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index 64dcedbcc0fc9..5eefdcc477b9d 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -353,6 +353,8 @@ static int mcp_i2c_smbus_read(struct mcp2221 *mcp,
 				usleep_range(90, 100);
 				retries++;
 			} else {
+				usleep_range(980, 1000);
+				mcp_cancel_last_cmd(mcp);
 				return ret;
 			}
 		} else {
-- 
2.53.0


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

* Re: [PATCH] HID: mcp2221: cancel last I2C command on read error
  2026-02-06 16:32 [PATCH] HID: mcp2221: cancel last I2C command on read error Romain Sioen
@ 2026-02-27 17:54 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2026-02-27 17:54 UTC (permalink / raw)
  To: Romain Sioen; +Cc: linux-kernel, gupt21

On Fri, 6 Feb 2026, Romain Sioen wrote:

> When an I2C SMBus read operation fails, the MCP2221 internal state machine
> may not reset correctly, causing subsequent transactions to fail.
> 
> By adding a short delay and explicitly cancelling the last command,
> we ensure the device is ready for the next operation.
> 
> Fix an issue where i2cdetect was not able to detect all devices correctly
> on the bus.
> 
> Signed-off-by: Romain Sioen <romain.sioen@microchip.com>
> ---
>  drivers/hid/hid-mcp2221.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
> index 64dcedbcc0fc9..5eefdcc477b9d 100644
> --- a/drivers/hid/hid-mcp2221.c
> +++ b/drivers/hid/hid-mcp2221.c
> @@ -353,6 +353,8 @@ static int mcp_i2c_smbus_read(struct mcp2221 *mcp,
>  				usleep_range(90, 100);
>  				retries++;
>  			} else {
> +				usleep_range(980, 1000);
> +				mcp_cancel_last_cmd(mcp);
>  				return ret;

Applied to hid.git#for-7.0/upstream-fixes, thanks.

-- 
Jiri Kosina
SUSE Labs


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

end of thread, other threads:[~2026-02-27 17:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-06 16:32 [PATCH] HID: mcp2221: cancel last I2C command on read error Romain Sioen
2026-02-27 17:54 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®