From patchwork Mon Jan 16 06:43:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 6227 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 79DC223E0E for ; Mon, 16 Jan 2012 06:42:33 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 60AB4A185CA for ; Mon, 16 Jan 2012 06:42:33 +0000 (UTC) Received: by bkbzt4 with SMTP id zt4so205764bkb.11 for ; Sun, 15 Jan 2012 22:42:33 -0800 (PST) Received: by 10.205.126.137 with SMTP id gw9mr4180721bkc.135.1326696153053; Sun, 15 Jan 2012 22:42:33 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs83519bkc; Sun, 15 Jan 2012 22:42:32 -0800 (PST) Received: by 10.204.153.12 with SMTP id i12mr4233985bkw.134.1326696151527; Sun, 15 Jan 2012 22:42:31 -0800 (PST) Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id uj2si9522840bkb.92.2012.01.15.22.42.30 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 15 Jan 2012 22:42:31 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of dmitry.antipov@linaro.org) client-ip=209.85.214.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of dmitry.antipov@linaro.org) smtp.mail=dmitry.antipov@linaro.org Received: by bkcjk14 with SMTP id jk14so4704581bkc.37 for ; Sun, 15 Jan 2012 22:42:30 -0800 (PST) Received: by 10.205.141.79 with SMTP id jd15mr4137409bkc.139.1326696150651; Sun, 15 Jan 2012 22:42:30 -0800 (PST) Received: from localhost.localdomain ([78.153.153.8]) by mx.google.com with ESMTPS id b9sm37313216bks.6.2012.01.15.22.42.29 (version=SSLv3 cipher=OTHER); Sun, 15 Jan 2012 22:42:30 -0800 (PST) From: Dmitry Antipov To: Chris Ball Cc: patches@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Antipov Subject: [PATCH] mmc: change mmc_delay() to use usleep_range() Date: Mon, 16 Jan 2012 10:43:20 +0400 Message-Id: <1326696200-514-1-git-send-email-dmitry.antipov@linaro.org> X-Mailer: git-send-email 1.7.7.5 Use the usleep_range() to simplify mmc_delay() and give some more accuracy to it - but with an exception of mmc_card_sleepawake(): for the hosts with very small (<100us) sleep/awake timeout, it's value is rounded up to 100us so usleep_range() always makes sense. --- drivers/mmc/core/core.h | 8 ++------ drivers/mmc/core/mmc_ops.c | 9 ++++++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 3bdafbc..fbd2cba 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -48,12 +48,8 @@ void mmc_power_off(struct mmc_host *host); static inline void mmc_delay(unsigned int ms) { - if (ms < 1000 / HZ) { - cond_resched(); - mdelay(ms); - } else { - msleep(ms); - } + unsigned long us = ms * USEC_PER_MSEC; + usleep_range(us, us + 1000); } void mmc_rescan(struct work_struct *work); diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 4d41fa9..457443a 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -82,9 +82,12 @@ int mmc_card_sleepawake(struct mmc_host *host, int sleep) * SEND_STATUS command to poll the status because that command (and most * others) is invalid while the card sleeps. */ - if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) - mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000)); - + if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) { + /* JEDEC MMCA 4.41 specifies the timeout value is in 200ns..838.86ms + range, which is rounded it up to 100us here. */ + unsigned long us = DIV_ROUND_UP(card->ext_csd.sa_timeout, 1000); + usleep_range(us, us + 100); + } if (!sleep) err = mmc_select_card(card);