Skip to content

Commit c763072

Browse files
tlebAndi Shyti
authored andcommitted
i2c: nomadik: replace jiffies by ktime for FIFO flushing timeout
The FIFO flush function uses a jiffies amount to detect timeouts as the flushing is async. Replace with ktime to get more accurate precision and support short timeouts. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent 7489cd4 commit c763072

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/i2c/busses/i2c-nomadik.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ static inline void i2c_clr_bit(void __iomem *reg, u32 mask)
225225
static int flush_i2c_fifo(struct nmk_i2c_dev *priv)
226226
{
227227
#define LOOP_ATTEMPTS 10
228+
ktime_t timeout;
228229
int i;
229-
unsigned long timeout;
230230

231231
/*
232232
* flush the transmit and receive FIFO. The flushing
@@ -238,9 +238,9 @@ static int flush_i2c_fifo(struct nmk_i2c_dev *priv)
238238
writel((I2C_CR_FTX | I2C_CR_FRX), priv->virtbase + I2C_CR);
239239

240240
for (i = 0; i < LOOP_ATTEMPTS; i++) {
241-
timeout = jiffies + priv->adap.timeout;
241+
timeout = ktime_add_us(ktime_get(), priv->timeout_usecs);
242242

243-
while (!time_after(jiffies, timeout)) {
243+
while (ktime_after(timeout, ktime_get())) {
244244
if ((readl(priv->virtbase + I2C_CR) &
245245
(I2C_CR_FTX | I2C_CR_FRX)) == 0)
246246
return 0;

0 commit comments

Comments
 (0)