Skip to content

Commit

Permalink
spi/rockchip: Fix the wait_for_idle() timeout
Browse files Browse the repository at this point in the history
The wait_for_idle() could get unlucky and timeout too quickly.
Specifically, the old calculation was effectively:
  timeout = jiffies + 1;
  if (jiffies >= timeout) print warning;

From the above it should be obvious that if jiffies ticks in just the
wrong place then we'll have an effective timeout of 0.

Fix this by effectively changing the above ">=" to a ">".  That gives
us an extra jiffy to finish.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Doug Anderson authored and Mark Brown committed Sep 4, 2014
1 parent 7d1311b commit 64bc011
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/spi/spi-rockchip.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static inline void wait_for_idle(struct rockchip_spi *rs)
do {
if (!(readl_relaxed(rs->regs + ROCKCHIP_SPI_SR) & SR_BUSY))
return;
} while (time_before(jiffies, timeout));
} while (!time_after(jiffies, timeout));

dev_warn(rs->dev, "spi controller is in busy state!\n");
}
Expand Down

0 comments on commit 64bc011

Please sign in to comment.