From patchwork Thu Feb 24 11:18:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chuanxiao.Dong" X-Patchwork-Id: 587261 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1OBOtnV020682 for ; Thu, 24 Feb 2011 11:25:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756196Ab1BXLZF (ORCPT ); Thu, 24 Feb 2011 06:25:05 -0500 Received: from mga02.intel.com ([134.134.136.20]:46792 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756165Ab1BXLZF (ORCPT ); Thu, 24 Feb 2011 06:25:05 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 24 Feb 2011 03:25:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.62,216,1297065600"; d="scan'208";a="712700113" Received: from cdong3-fc.bj.intel.com (HELO intel.com) ([172.16.120.198]) by orsmga001.jf.intel.com with ESMTP; 24 Feb 2011 03:25:03 -0800 Date: Thu, 24 Feb 2011 19:18:01 +0800 From: Chuanxiao Dong To: linux-mmc@vger.kernel.org, cjb@laptop.org Cc: adrian.hunter@nokia.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/1]mmc: fix division by zero when calculate mmc erase time Message-ID: <20110224111801.GA7169@intel.com> Reply-To: Chuanxiao Dong MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 24 Feb 2011 11:25:06 +0000 (UTC) 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;