提交 06be6726 编写于 作者: T Tali Perry 提交者: Wolfram Sang

i2c: npcm7xx: Fix timeout calculation

timeout_usec value calculation was wrong, the calculated value
was in msec instead of usec.

Fixes: 56a1485b ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
Signed-off-by: NTali Perry <tali.perry1@gmail.com>
Reviewed-by: NAvi Fishman <avifishman70@gmail.com>
Reviewed-by: NJoel Stanley <joel@jms.id.au>
Reviewed-by: NAlex Qiu <xqiu@google.com>
Signed-off-by: NWolfram Sang <wsa@kernel.org>
上级 f4d51dff
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册