From: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>,
Fabio Estevam
<fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Mark Brown
<broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>,
Chris Ball <cjb-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH 4/4] mxs/spi: Rework the mxs_ssp_timeout to be more readable
Date: Tue, 4 Sep 2012 04:40:18 +0200 [thread overview]
Message-ID: <1346726418-2856-5-git-send-email-marex@denx.de> (raw)
In-Reply-To: <1346726418-2856-1-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
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-ynQEQJNshbs@public.gmane.org>
Cc: Chris Ball <cjb-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>
Cc: Fabio Estevam <fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: Mark Brown <broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
Cc: Shawn Guo <shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
drivers/spi/spi-mxs.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index 6650ded..2c3665a 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)
--
1.7.10.4
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
next prev parent reply other threads:[~2012-09-04 2:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-04 2:40 [PATCH 0/4] mxs/spi: Fixes and improvements Marek Vasut
[not found] ` <1346726418-2856-1-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
2012-09-04 2:40 ` [PATCH 1/4] mxs/spi: Fix issues when doing long continuous transfer Marek Vasut
2012-09-04 2:40 ` [PATCH 2/4] mxs/spi: Increment the transfer length only if transfer succeeded Marek Vasut
2012-09-04 2:40 ` [PATCH 3/4] mxs/spi: Decrement the DMA/PIO border Marek Vasut
2012-09-04 2:40 ` Marek Vasut [this message]
2012-09-05 23:42 ` [PATCH 0/4] mxs/spi: Fixes and improvements Mark Brown
[not found] ` <20120905234238.GG10580-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-09-06 2:05 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1346726418-2856-5-git-send-email-marex@denx.de \
--to=marex-ynqeqjnshbs@public.gmane.org \
--cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
--cc=cjb-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org \
--cc=fabio.estevam-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=shawn.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).