blob: 136be4a7a3c95bddddca581a387542e9b10d046a [file] [log] [blame]
From 65ef175b74710f70b6d89794c261e017f6f5d9ec Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Thu, 21 Mar 2013 12:46:49 +0100
Subject: [PATCH 3/3] 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>
---
drivers/spi/spi-omap2-mcspi.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--- 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 _
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;