Commit ff23fa3b authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Mark Brown

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: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent e761f423
...@@ -285,8 +285,12 @@ static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit) ...@@ -285,8 +285,12 @@ static int mcspi_wait_for_reg_bit(void __iomem *reg, unsigned long bit)
timeout = jiffies + msecs_to_jiffies(1000); timeout = jiffies + msecs_to_jiffies(1000);
while (!(__raw_readl(reg) & bit)) { while (!(__raw_readl(reg) & bit)) {
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout)) {
return -1; if (!(__raw_readl(reg) & bit))
return -ETIMEDOUT;
else
return 0;
}
cpu_relax(); cpu_relax();
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment