lkml.org 
[lkml]   [2011]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRE: [PATCH 1/1]mmc: fix division by zero when calculate mmc erase time


> -----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 <chuanxiao.dong@intel.com> [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 <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 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


\
 
 \ /
  Last update: 2011-02-24 13:13    [W:0.043 / U:3.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site