linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeremie Samuel <jeremie.samuel.ext@parrot.com>
To: Chris Ball <cjb@laptop.org>
Cc: linux-mmc@vger.kernel.org, matthieu.castet@parrot.com,
	gregor.boirie@parrot.com,
	Jeremie Samuel <jeremie.samuel.ext@parrot.com>,
	Anton Vorontsov <avorontsov@mvista.com>
Subject: [PATCH 8/8] sdhci: Use jiffies instead of a timeout counter
Date: Tue, 9 Jul 2013 17:44:12 +0200	[thread overview]
Message-ID: <1373384652-21958-9-git-send-email-jeremie.samuel.ext@parrot.com> (raw)
In-Reply-To: <1373384652-21958-1-git-send-email-jeremie.samuel.ext@parrot.com>

Just a cosmetic change, should not affect functionality.

Patch based on: http://thread.gmane.org/gmane.linux.kernel.mmc/2579.

Signed-off-by: Anton Vorontsov <avorontsov@mvista.com>
Signed-off-by: Jeremie Samuel <jeremie.samuel.ext@parrot.com>
---
 drivers/mmc/host/sdhci.c |   22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index cabbe29..b261555 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -210,17 +210,16 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask)
 	}
 
 	/* Wait max 100 ms */
-	timeout = 100;
+	timeout = jiffies + msecs_to_jiffies(100);
 
 	/* hw clears the bit when it's done */
 	while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) & mask) {
-		if (timeout == 0) {
+		if (time_after(jiffies, timeout)) {
 			pr_err("%s: Reset 0x%x never completed.\n",
 				mmc_hostname(host->mmc), (int)mask);
 			sdhci_dumpregs(host);
 			return;
 		}
-		timeout--;
 		msleep(1);
 	}
 
@@ -996,7 +995,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
 	WARN_ON(host->cmd);
 
 	/* Wait max 10 ms */
-	timeout = 10;
+	timeout = jiffies + msecs_to_jiffies(10);
 
 	mask = SDHCI_CMD_INHIBIT;
 	if ((cmd->data != NULL) || (cmd->flags & MMC_RSP_BUSY))
@@ -1008,7 +1007,7 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
 		mask &= ~SDHCI_DATA_INHIBIT;
 
 	while (sdhci_readl(host, SDHCI_PRESENT_STATE) & mask) {
-		if (timeout == 0) {
+		if (time_after(jiffies, timeout)) {
 			pr_err("%s: Controller never released "
 				"inhibit bit(s).\n", mmc_hostname(host->mmc));
 			sdhci_dumpregs(host);
@@ -1016,7 +1015,6 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
 			schedule_work(&host->finish_work);
 			return;
 		}
-		timeout--;
 		mdelay(1);
 	}
 
@@ -1228,16 +1226,15 @@ clock_set:
 	sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
 
 	/* Wait max 20 ms */
-	timeout = 20;
+	timeout = jiffies + msecs_to_jiffies(20);
 	while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
 		& SDHCI_CLOCK_INT_STABLE)) {
-		if (timeout == 0) {
+		if (time_after(jiffies, timeout)) {
 			pr_err("%s: Internal clock never "
 				"stabilised.\n", mmc_hostname(host->mmc));
 			sdhci_dumpregs(host);
 			return;
 		}
-		timeout--;
 		msleep(1);
 	}
 
@@ -1894,12 +1891,12 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	 * Issue CMD19 repeatedly till Execute Tuning is set to 0 or the number
 	 * of loops reaches 40 times or a timeout of 150ms occurs.
 	 */
-	timeout = 150;
+	timeout = jiffies + msecs_to_jiffies(150);
 	do {
 		struct mmc_command cmd = {0};
 		struct mmc_request mrq = {NULL};
 
-		if (!tuning_loop_counter && !timeout)
+		if (!tuning_loop_counter && time_after(jiffies, timeout))
 			break;
 
 		cmd.opcode = opcode;
@@ -1970,7 +1967,6 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
 
 		ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
 		tuning_loop_counter--;
-		timeout--;
 		msleep(1);
 	} while (ctrl & SDHCI_CTRL_EXEC_TUNING);
 
@@ -1978,7 +1974,7 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	 * The Host Driver has exhausted the maximum number of loops allowed,
 	 * so use fixed sampling frequency.
 	 */
-	if (!tuning_loop_counter || !timeout) {
+	if (!tuning_loop_counter || time_after(jiffies, timeout)) {
 		ctrl &= ~SDHCI_CTRL_TUNED_CLK;
 		sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
 	} else {
-- 
1.7.10.4


  parent reply	other threads:[~2013-07-09 15:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09 15:44 [PATCH 0/8] sdhci: Move real work out of an atomic context Jeremie Samuel
2013-07-09 15:44 ` [PATCH 1/8] sdhci: Turn timeout timer into delayed work Jeremie Samuel
2013-07-09 15:44 ` [PATCH 2/8] sdhci: Turn tuning " Jeremie Samuel
2013-07-09 15:44 ` [PATCH 3/8] sdhci: Use work structs instead of tasklets Jeremie Samuel
2013-07-09 15:44 ` [PATCH 4/8] sdhci: Use threaded IRQ handler Jeremie Samuel
2013-07-09 15:44 ` [PATCH 5/8] sdhci: Delay led blinking Jeremie Samuel
2013-07-09 15:44 ` [PATCH 6/8] sdhci: Turn host->lock into a mutex Jeremie Samuel
2013-08-25  1:58   ` Chris Ball
2013-08-26  8:37     ` Jeremie Samuel
2013-07-09 15:44 ` [PATCH 7/8] sdhci: Get rid of mdelay()s where it is safe and makes sense Jeremie Samuel
2013-07-09 15:44 ` Jeremie Samuel [this message]
2013-07-09 15:52 ` [PATCH 0/8] sdhci: Move real work out of an atomic context Philip Rakity
2013-07-11  8:28   ` Jeremie Samuel
  -- strict thread matches above, loose matches on Subject: below --
2013-10-16 16:20 Jeremie Samuel
2013-10-16 16:20 ` [PATCH 8/8] sdhci: Use jiffies instead of a timeout counter Jeremie Samuel
2013-05-24 16:00 [PATCH 0/8] sdhci: Move real work out of an atomic context Jeremie Samuel
2013-05-24 16:00 ` [PATCH 8/8] sdhci: Use jiffies instead of a timeout counter Jeremie Samuel
2010-07-14 13:07 [PATCH 0/8] sdhci: Move real work out of an atomic context Anton Vorontsov
2010-07-14 13:08 ` [PATCH 8/8] sdhci: Use jiffies instead of a timeout counter Anton Vorontsov

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=1373384652-21958-9-git-send-email-jeremie.samuel.ext@parrot.com \
    --to=jeremie.samuel.ext@parrot.com \
    --cc=avorontsov@mvista.com \
    --cc=cjb@laptop.org \
    --cc=gregor.boirie@parrot.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=matthieu.castet@parrot.com \
    /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).