diff mbox

[1/1] mmc: fix division by zero when calculate mmc erase time

Message ID 20110224111801.GA7169@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chuanxiao.Dong Feb. 24, 2011, 11:18 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 34a7e8c..12d0eb8 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;