From patchwork Wed Oct 16 16:20:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremie Samuel X-Patchwork-Id: 3054371 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 34BD5BF924 for ; Wed, 16 Oct 2013 16:23:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DC2820125 for ; Wed, 16 Oct 2013 16:22:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB5D1204AD for ; Wed, 16 Oct 2013 16:22:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760004Ab3JPQWw (ORCPT ); Wed, 16 Oct 2013 12:22:52 -0400 Received: from co202.xi-lite.net ([149.6.83.202]:33778 "EHLO co202.xi-lite.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932593Ab3JPQWg (ORCPT ); Wed, 16 Oct 2013 12:22:36 -0400 Received: from localhost (localhost [127.0.0.1]) by co202.xi-lite.net (Postfix) with ESMTP id 0381A4809C2; Wed, 16 Oct 2013 18:22:36 +0200 (CEST) X-Virus-Scanned: amavisd-new at fw.aswsp.net Received: from co202.xi-lite.net ([127.0.0.1]) by localhost (fw.aswsp.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZSVF-qBBQw2W; Wed, 16 Oct 2013 18:22:35 +0200 (CEST) Received: from HCAS2.aswsp.lan (unknown [193.34.35.150]) by co202.xi-lite.net (Postfix) with ESMTPS id E71104809BF; Wed, 16 Oct 2013 18:22:35 +0200 (CEST) Received: from jerk.parrot.biz (46.218.109.88) by smtp.aswsp.com (193.34.32.148) with Microsoft SMTP Server id 14.2.342.3; Wed, 16 Oct 2013 18:22:59 +0200 From: Jeremie Samuel To: Chris Ball CC: , =?UTF-8?q?Gr=C3=A9gor=20Boirie?= , Matthieu Castet , Jeremie Samuel , Anton Vorontsov Subject: [PATCH 8/8] sdhci: Use jiffies instead of a timeout counter Date: Wed, 16 Oct 2013 18:20:58 +0200 Message-ID: <1381940458-12628-9-git-send-email-jeremie.samuel.ext@parrot.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1381940458-12628-1-git-send-email-jeremie.samuel.ext@parrot.com> References: <1381940458-12628-1-git-send-email-jeremie.samuel.ext@parrot.com> MIME-Version: 1.0 X-Originating-IP: [46.218.109.88] Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Jeremie Samuel --- 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 843e99d..3e148c0 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -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); } @@ -1902,12 +1899,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; @@ -1978,7 +1975,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); @@ -1986,7 +1982,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 {