mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-19 16:06:45 +07:00
i2c: npcm7xx: Fix timeout calculation
timeout_usec value calculation was wrong, the calculated value
was in msec instead of usec.
Fixes: 56a1485b10
("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
Signed-off-by: Tali Perry <tali.perry1@gmail.com>
Reviewed-by: Avi Fishman <avifishman70@gmail.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Alex Qiu <xqiu@google.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
parent
f4d51dffc6
commit
06be67266a
@ -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));
|
timeout = max(msecs_to_jiffies(35), usecs_to_jiffies(timeout_usec));
|
||||||
if (nwrite >= 32 * 1024 || nread >= 32 * 1024) {
|
if (nwrite >= 32 * 1024 || nread >= 32 * 1024) {
|
||||||
dev_err(bus->dev, "i2c%d buffer too big\n", bus->num);
|
dev_err(bus->dev, "i2c%d buffer too big\n", bus->num);
|
||||||
|
Loading…
Reference in New Issue
Block a user