From: Chuanxiao Dong <chuanxiao.dong@intel.com>
To: linux-mmc@vger.kernel.org, cjb@laptop.org
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
adrian.hunter@nokia.com
Subject: [PATCH v4 3/3]mmc: fix division by zero when cal erase timeout
Date: Sat, 12 Feb 2011 14:22:26 +0800 [thread overview]
Message-ID: <20110212062226.GD25519@intel.com> (raw)
Since if clock gating feature is enabled, the clock frequency may be zero when
host clock is gated. In such scenario, mmc_set_mmc_erase_timeout() may have a
division by zero bug.
So this patch used mmc_host_clk_rate() to fix this.
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
---
drivers/mmc/core/core.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 0eb27aa..2f4576d 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1201,8 +1201,14 @@ static void mmc_set_mmc_erase_timeout(struct mmc_card *card,
* less but not that much less, so fudge it by multiplying by 2.
*/
timeout_clks <<= 1;
- timeout_us += (timeout_clks * 1000) /
- (card->host->ios.clock / 1000);
+
+ /*
+ * at this moment, host controller maybe clock gated, so make
+ * sure we can get a correct host clock freq.
+ */
+ if (mmc_host_clk_rate(card->host))
+ timeout_us += (timeout_clks * 1000) /
+ (mmc_host_clk_rate(card->host) / 1000);
erase_timeout = timeout_us / 1000;
--
1.6.6.1
reply other threads:[~2011-02-12 6:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20110212062226.GD25519@intel.com \
--to=chuanxiao.dong@intel.com \
--cc=adrian.hunter@nokia.com \
--cc=akpm@linux-foundation.org \
--cc=cjb@laptop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.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