diff options
author | Marek Vasut <marex@denx.de> | 2012-09-03 22:40:18 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-05 19:42:29 -0400 |
commit | f13639dc6043eb67e308aa5cf96717a86c10f8b9 (patch) | |
tree | b9db2344a4962138a2ec58acbca40aa8fa5ead6e /drivers/spi/spi-mxs.c | |
parent | 727c10e3e54c4404f6842d246b15fe3703d33556 (diff) |
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.c | 20 |
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) | |||
177 | 177 | ||
178 | static int mxs_ssp_wait(struct mxs_spi *spi, int offset, int mask, bool set) | 178 | static int mxs_ssp_wait(struct mxs_spi *spi, int offset, int mask, bool set) |
179 | { | 179 | { |
180 | unsigned long timeout = jiffies + msecs_to_jiffies(SSP_TIMEOUT); | 180 | const unsigned long timeout = jiffies + msecs_to_jiffies(SSP_TIMEOUT); |
181 | struct mxs_ssp *ssp = &spi->ssp; | 181 | struct mxs_ssp *ssp = &spi->ssp; |
182 | uint32_t reg; | 182 | uint32_t reg; |
183 | 183 | ||
184 | while (1) { | 184 | do { |
185 | reg = readl_relaxed(ssp->base + offset); | 185 | reg = readl_relaxed(ssp->base + offset); |
186 | 186 | ||
187 | if (set && ((reg & mask) == mask)) | 187 | if (!set) |
188 | break; | 188 | reg = ~reg; |
189 | 189 | ||
190 | if (!set && ((~reg & mask) == mask)) | 190 | reg &= mask; |
191 | break; | ||
192 | 191 | ||
193 | udelay(1); | 192 | if (reg == mask) |
193 | return 0; | ||
194 | } while (time_before(jiffies, timeout)); | ||
194 | 195 | ||
195 | if (time_after(jiffies, timeout)) | 196 | return -ETIMEDOUT; |
196 | return -ETIMEDOUT; | ||
197 | } | ||
198 | return 0; | ||
199 | } | 197 | } |
200 | 198 | ||
201 | static void mxs_ssp_dma_irq_callback(void *param) | 199 | static void mxs_ssp_dma_irq_callback(void *param) |