Skip to contentSkip to conversation

i2c: microchip-core: re-fix fake detections w/ i2cdetect

PATCH Applied Conor Dooley 2 participants 2 messages Jun 30, 2025 – Jul 1, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 i2c: microchip-core: re-fix fake detections w/ i2cdetect

From: Conor Dooley <[email protected]>

Introducing support for smbus re-broke i2cdetect, causing it to detect devices at every i2c address, just as it did prior to being fixed in commit 49e1f0fd0d4cb ("i2c: microchip-core: fix "ghost" detections"). This was caused by an oversight, where the new smbus code failed to check the return value of mchp_corei2c_xfer(). Check it, and propagate any errors.

Fixes d6ceb40538263 ("i2c: microchip-corei2c: add smbus support")

---
v3:
- actually set ret before returning it, not whatever my debug code was doing...

v2:
- replace "if (ret)" with "if (ret < 0)" because the xfer callback, which the smbus code re-uses, can return positive numbers in success cases.

CC Conor Dooley <[email protected]>
CC Daire McNamara <[email protected]>
CC Andi Shyti <[email protected]>
---
 drivers/i2c/busses/i2c-microchip-corei2c.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-microchip-corei2c.c +5 -1
index 492bf4c34722c..2be9e8c720b10 100644
@@ -435,6 +435,7 @@ static int mchp_corei2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned
 	u8 tx_buf[I2C_SMBUS_BLOCK_MAX + 2];
 	u8 rx_buf[I2C_SMBUS_BLOCK_MAX + 1];
 	int num_msgs = 1;
+	int ret;
 
 	msgs[CORE_I2C_SMBUS_MSG_WR].addr = addr;
 	msgs[CORE_I2C_SMBUS_MSG_WR].flags = 0;
@@ -505,7 +506,10 @@ static int mchp_corei2c_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned
 		return -EOPNOTSUPP;
 	}
 
-	mchp_corei2c_xfer(&idev->adapter, msgs, num_msgs);
+	ret = mchp_corei2c_xfer(&idev->adapter, msgs, num_msgs);
+	if (ret < 0)
+		return ret;
+
 	if (read_write == I2C_SMBUS_WRITE || size <= I2C_SMBUS_BYTE_DATA)
 		return 0;
 
Signature · 1 line
2.45.2
maintainer Applied
#1 lore raw

Hi Conor,

Quoted 11 lines · Conor Dooley

From: Conor Dooley <[email protected]>

Introducing support for smbus re-broke i2cdetect, causing it to detect devices at every i2c address, just as it did prior to being fixed in commit 49e1f0fd0d4cb ("i2c: microchip-core: fix "ghost" detections"). This was caused by an oversight, where the new smbus code failed to check the return value of mchp_corei2c_xfer(). Check it, and propagate any errors.

Fixes d6ceb40538263 ("i2c: microchip-corei2c: add smbus support")

merged to i2c/i2c-host-fixes.

Thanks,
Andi