Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753467Ab1BXMK1 (ORCPT ); Thu, 24 Feb 2011 07:10:27 -0500 Received: from mga11.intel.com ([192.55.52.93]:23573 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752286Ab1BXMKZ convert rfc822-to-8bit (ORCPT ); Thu, 24 Feb 2011 07:10:25 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.62,217,1297065600"; d="scan'208";a="661034094" From: "Dong, Chuanxiao" To: Marc Koschewski CC: "linux-mmc@vger.kernel.org" , "cjb@laptop.org" , "adrian.hunter@nokia.com" , "linus.walleij@linaro.org" , "linux-kernel@vger.kernel.org" Date: Thu, 24 Feb 2011 20:09:59 +0800 Subject: RE: [PATCH 1/1]mmc: fix division by zero when calculate mmc erase time Thread-Topic: [PATCH 1/1]mmc: fix division by zero when calculate mmc erase time Thread-Index: AcvUF0vEdzksXaqvRjeXPoVmoG4C6gABB2vw Message-ID: <5D8008F58939784290FAB48F5497519835CE59FE52@shsmsx502.ccr.corp.intel.com> References: <20110224111801.GA7169@intel.com> <20110224113756.GB7260@marc.osknowledge.org> In-Reply-To: <20110224113756.GB7260@marc.osknowledge.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2127 Lines: 55 > -----Original Message----- > From: Marc Koschewski [mailto:marc@osknowledge.org] > Sent: Thursday, February 24, 2011 7:38 PM > To: Dong, Chuanxiao > Cc: linux-mmc@vger.kernel.org; cjb@laptop.org; adrian.hunter@nokia.com; > linus.walleij@linaro.org; linux-kernel@vger.kernel.org > Subject: Re: [PATCH 1/1]mmc: fix division by zero when calculate mmc erase time > > Hi, > > * Chuanxiao Dong [2011-02-24 19:18:01 +0800]: > > > 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 > > --- > > 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 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); > > Why don't you just reuse mmc_host_clk_rate()'s result instead of calling it twice? This is a incline function and just return host->ios.clock. Reuse mmc_host_clk_rate()'s result need to add a new variable to save the value. Thanks Chuanxiao -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/