Skip to contentSkip to conversation

i2c: npcm7xx: bug fix timeout (usec instead of msec)

PATCH Superseded Tali Perry 2 participants 2 messages Aug 30, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Tali Perry

author maintainer
#0 lore raw

PATCH 1/1 i2c: npcm7xx: bug fix timeout (usec instead of msec)

i2c: npcm7xx: bug fix timeout (usec instead of msec)

---
 drivers/i2c/busses/i2c-npcm7xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-npcm7xx.c +1 -1
index 75f07138a6fa..c118f93a2610 100644
@@ -2094,7 +2094,7 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 	}
 
 	/* Adaptive TimeOut: astimated time in usec + 100% margin */
-	timeout_usec = (2 * 10000 / bus->bus_freq) * (2 + nread + nwrite);
+	timeout_usec = (2 * 10000000 / bus->bus_freq) * (2 + nread + nwrite);
 	timeout = max(msecs_to_jiffies(35), usecs_to_jiffies(timeout_usec));
 	if (nwrite >= 32 * 1024 || nread >= 32 * 1024) {
 		dev_err(bus->dev, "i2c%d buffer too big\n", bus->num);

base-commit: d012a7190fc1fd72ed48911e77ca97ba4521bccd

Signature · 1 line
2.22.0
maintainer
#1 lore raw

Hi Tali,

Quoted 13 lines · Tali Perry

i2c: npcm7xx: bug fix timeout (usec instead of msec)

---
 drivers/i2c/busses/i2c-npcm7xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-npcm7xx.c +0 -0
index 75f07138a6fa..c118f93a2610 100644

drivers/i2c/busses/i2c-npcm7xx.c static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, · line 2097

Quoted 4 lines
drivers/i2c/busses/i2c-npcm7xx.c +0 -1
@@ -2094,7 +2094,7 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
        }
 
        /* Adaptive TimeOut: astimated time in usec + 100% margin */
-       timeout_usec = (2 * 10000 / bus->bus_freq) * (2 + nread + nwrite);

I suggest to add a short description like:
2: double the timeout for clock stretching case
9: bits per transaction (including the avk/nack)
1000000: micro second in a second
timeout_usec = (2 * 9 * 1000000 / bus->bus_freq) * (2 + nread + nwrite);

Quoted 9 lines
drivers/i2c/busses/i2c-npcm7xx.c +1 -0
+       timeout_usec = (2 * 10000000 / bus->bus_freq) * (2 + nread + nwrite);
        timeout = max(msecs_to_jiffies(35), usecs_to_jiffies(timeout_usec));
        if (nwrite >= 32 * 1024 || nread >= 32 * 1024) {
                dev_err(bus->dev, "i2c%d buffer too big\n", bus->num);

base-commit: d012a7190fc1fd72ed48911e77ca97ba4521bccd --
2.22.0

Signature · 2 lines
Regards,
Avi