I2C driver issue #145
-
Hi When reading more than one byte from I2C bus, I see that too much data is read. This causes issues with some I2C device drivers (e.g. atsha204a). "i2ctransfer -y 0 w1@0x6f 0 r1" works as expected, only one byte is read. "i2ctransfer -y 0 w1@0x6f 0 r2" reads 3 bytes instead of two. I2ctransfer returns only 2 bytes but on the I2C bus, 3 bytes are read. In the driver source code, the CTRL_AA flag is cleared when lenght is zero, which causes an additional byte read with NACK. Changing that condition to one seems to solve the issue. I'm not 100% sure if my patch is correct but it would be great if you can check that. diff --git a/drivers/i2c/busses/i2c-microchip.c b/drivers/i2c/busses/i2c-microchip.c
index 3eeda8403b0b..0c7ff5bf35d8 100755
--- a/drivers/i2c/busses/i2c-microchip-core.c
+++ b/drivers/i2c/busses/i2c-microchip-core.c
@@ -207,7 +207,7 @@ static void mchp_corei2c_empty_rx(struct mchp_corei2c_dev *idev)
idev->msg_len--;
}
- if (idev->msg_len == 0) {
+ if (idev->msg_len <= 1) {
ctrl = readb(idev->base + CORE_I2C_CTRL);
ctrl &= ~CTRL_AA;
writeb(ctrl, idev->base + CORE_I2C_CTRL);
-- |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Hey, |
Beta Was this translation helpful? Give feedback.
-
Fixed upstream and in our tree as: |
Beta Was this translation helpful? Give feedback.
Fixed upstream and in our tree as:
linux4microchip/linux@21a3ec9