]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mmc: sdhci: Use jiffies instead of a timeout counter
authorJeremie Samuel <jeremie.samuel.ext@parrot.com>
Mon, 21 Oct 2013 19:55:13 +0000 (15:55 -0400)
committerChris Ball <chris@printf.net>
Mon, 21 Oct 2013 19:58:47 +0000 (15:58 -0400)
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>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/host/sdhci.c

index 0602017ac7c4ed7c719925e1a53e8c2cadc2b37b..739dcc2c6e3c475c9869e30252cb54fa66f62cbd 100644 (file)
@@ -209,17 +209,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);
        }
 
@@ -995,7 +994,7 @@ 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))
@@ -1007,7 +1006,7 @@ 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);
@@ -1015,7 +1014,6 @@ 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);
        }
 
@@ -1903,12 +1900,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;
@@ -1979,7 +1976,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);
 
@@ -1987,7 +1983,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);
                err = -EIO;