summaryrefslogtreecommitdiff
path: root/drivers/spi/spi-mxs.c
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2012-09-04 06:40:18 +0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-06 03:42:29 +0400
commitf13639dc6043eb67e308aa5cf96717a86c10f8b9 (patch)
treeb9db2344a4962138a2ec58acbca40aa8fa5ead6e /drivers/spi/spi-mxs.c
parent727c10e3e54c4404f6842d246b15fe3703d33556 (diff)
downloadlinux-f13639dc6043eb67e308aa5cf96717a86c10f8b9.tar.xz
mxs/spi: Rework the mxs_ssp_timeout to be more readable
Rework the mxs_ssp_timeout() function to make it a bit more readable and hopefully less error prone. Also, have only one successful exit from the function and one failing exit instead of two. Finally, discard the udelay() from this function altogether, as this tightloop is quick enough it's pointless. Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/spi/spi-mxs.c')
-rw-r--r--drivers/spi/spi-mxs.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 21e1dcad3914..556e5ef907fa 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -177,25 +177,23 @@ static inline void mxs_spi_disable(struct mxs_spi *spi)
static int mxs_ssp_wait(struct mxs_spi *spi, int offset, int mask, bool set)
{
- unsigned long timeout = jiffies + msecs_to_jiffies(SSP_TIMEOUT);
+ const unsigned long timeout = jiffies + msecs_to_jiffies(SSP_TIMEOUT);
struct mxs_ssp *ssp = &spi->ssp;
uint32_t reg;
- while (1) {
+ do {
reg = readl_relaxed(ssp->base + offset);
- if (set && ((reg & mask) == mask))
- break;
+ if (!set)
+ reg = ~reg;
- if (!set && ((~reg & mask) == mask))
- break;
+ reg &= mask;
- udelay(1);
+ if (reg == mask)
+ return 0;
+ } while (time_before(jiffies, timeout));
- if (time_after(jiffies, timeout))
- return -ETIMEDOUT;
- }
- return 0;
+ return -ETIMEDOUT;
}
static void mxs_ssp_dma_irq_callback(void *param)