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 <bige...@linutronix.de>
---
 drivers/spi/spi-omap2-mcspi.c |    8 ++++++--
 1 file 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;
-- 
1.7.10.4


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general

Reply via email to