diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2013-03-21 11:46:49 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2013-04-04 22:09:40 (GMT) |
commit | cc102fc6cd3425a8b56e62665331c67e7ce29149 (patch) | |
tree | badcd31ea67d160810f31b385b0ff80a9d41c347 /drivers | |
parent | aa2effa1ca6da72f93fca3158079a10d8a592dac (diff) | |
download | linux-fsl-qoriq-cc102fc6cd3425a8b56e62665331c67e7ce29149.tar.xz |
spi/omap-mcspi: check condition also after timeout
It is possible that the handler gets interrupted after checking the
status. After it resumes it the time out is due but the condition it was
waiting for might be true. Therefore it is necessary to check the
condition in case of an time out to be sure that the condition is not
true _and_ the time passed by.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/spi/spi-omap2-mcspi.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index b610f52..56c4166 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -285,8 +285,12 @@ static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit) timeout = jiffies + msecs_to_jiffies(1000); while (!(__raw_readl(reg) & bit)) { - if (time_after(jiffies, timeout)) - return -1; + if (time_after(jiffies, timeout)) { + if (!(__raw_readl(reg) & bit)) + return -ETIMEDOUT; + else + return 0; + } cpu_relax(); } return 0; |