]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
HID: mcp2221: cancel last I2C command on read error
authorRomain Sioen <romain.sioen@microchip.com>
Fri, 6 Feb 2026 16:32:58 +0000 (17:32 +0100)
committerJiri Kosina <jkosina@suse.com>
Fri, 27 Feb 2026 17:54:09 +0000 (18:54 +0100)
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>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/hid-mcp2221.c

index 33603b019f975edc60e44615566a0f7efa5a3f25..ef3b5c77c38e3239121c420bc14788b4886d407d 100644 (file)
@@ -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 {