mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Romain Sioen <romain.sioen@microchip.com>
To: <linux-kernel@vger.kernel.org>
Cc: <gupt21@gmail.com>, <jikos@kernel.org>,
	Romain Sioen <romain.sioen@microchip.com>
Subject: [PATCH] HID: mcp2221: cancel last I2C command on read error
Date: Fri, 6 Feb 2026 17:32:58 +0100	[thread overview]
Message-ID: <20260206163258.130584-1-romain.sioen@microchip.com> (raw)

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


             reply	other threads:[~2026-02-06 16:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06 16:32 Romain Sioen [this message]
2026-02-27 17:54 ` Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260206163258.130584-1-romain.sioen@microchip.com \
    --to=romain.sioen@microchip.com \
    --cc=gupt21@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®