i2c: npcm7xx: Fix timeout calculation
Subsystems (2)
Tali Perry
maintainerPATCH v3 1/1 i2c: npcm7xx: Fix timeout calculation
timeout_usec value calculation was wrong, the calculated value was in msec instead of usec.
Signed-off-by Tali Perry <[email protected]>
Reviewed-by Avi Fishman <[email protected]>
--- drivers/i2c/busses/i2c-npcm7xx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-npcm7xx.c +6 -2
@@ -2093,8 +2093,12 @@ 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); +/* +* Adaptive TimeOut: estimated time in usec + 100% margin: +* 2: double the timeout for clock stretching case +* 9: bits per transaction (including the ack/nack) +*/ + timeout_usec = (2 *9 *USEC_PER_SEC / 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
Quoted 6 lines · Tali Perry
timeout_usecvalue calculation was wrong, the calculated value was in msec instead of usec.Signed-off-by Tali Perry <[email protected]>Reviewed-by Avi Fishman <[email protected]>
Fixes 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
Reviewed-by Joel Stanley <[email protected]>
Cheers,
Joel
Quoted 28 lines
--- drivers/i2c/busses/i2c-npcm7xx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-npcm7xx.c +6
-2@@ -2093,8 +2093,12 @@ 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); +/* +* Adaptive TimeOut: estimated time in usec + 100% margin: +* 2: double the timeout for clock stretching case +* 9: bits per transaction (including the ack/nack) +*/ + timeout_usec = (2 *9 *USEC_PER_SEC / 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
Alex Qiu
Reviewed-byQuoted 11 lines · Joel Stanley
Quoted 6 lines · Tali Perry
timeout_usecvalue calculation was wrong, the calculated value was in msec instead of usec.Signed-off-by Tali Perry <[email protected]>Reviewed-by Avi Fishman <[email protected]>Fixes 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")Reviewed-by Joel Stanley <[email protected]>
Reviewed-by Alex Qiu <[email protected]>
Quoted 33 lines
Cheers,
Joel
Quoted 28 lines
--- drivers/i2c/busses/i2c-npcm7xx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-npcm7xx.c +6
-2@@ -2093,8 +2093,12 @@ 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); +/* +* Adaptive TimeOut: estimated time in usec + 100% margin: +* 2: double the timeout for clock stretching case +* 9: bits per transaction (including the ack/nack) +*/ + timeout_usec = (2 *9 *USEC_PER_SEC / 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
Wolfram Sang
AppliedQuoted 5 lines · Tali Perry
timeout_usecvalue calculation was wrong, the calculated value was in msec instead of usec.Signed-off-by Tali Perry <[email protected]>Reviewed-by Avi Fishman <[email protected]>
Applied to for-current, thanks! And thanks for the Fixes-tag, Joel.