summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-omap2-mcspi.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2013-03-21 16:22:48 +0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-04-01 17:19:15 +0400
commitff23fa3bb05b296eeab2ccde92c0cdbc05942a1c (patch)
treed1ed38448d84cf9f50493f0b64fca29fc7be22e8 /drivers/spi/spi-omap2-mcspi.c
parente761f4236e94f2dd36316f9892583b29ce986031 (diff)
downloadlinux-ff23fa3bb05b296eeab2ccde92c0cdbc05942a1c.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 the time out is due but the condition it was waiting for might be true as well. Therefore it is necessary to check the condition in case of an time out to be sure that the condition is not true after the time passed by. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r--drivers/spi/spi-omap2-mcspi.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 893c3d78e426..61eef47ae821 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;