Subject: [PATCH 01/11] ARM: omap: clk: add clk_prepare and clk_unprepare

From: [email-masked] (Rajendra Nayak)
Date: Mon, 25 Jun 2012 11:06:04 +0530

On Friday 22 June 2012 11:12 PM, Pankaj Jangra wrote:
>> diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
>> >  index 5fb47a1..e5f8e48 100644
>> >  --- a/arch/arm/mach-omap2/display.c
>> >  +++ b/arch/arm/mach-omap2/display.c
>> >  @@ -471,7 +471,7 @@ int omap_dss_reset(struct omap_hwmod *oh)
>> >
>> >          for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i>  0; i--, oc++)
>> >                  if (oc->_clk)
>> >  -                       clk_enable(oc->_clk);
>> >  +                       clk_prepare_enable(oc->_clk);
>> >
>> >          dispc_disable_outputs();
>> >
>> >  @@ -498,7 +498,7 @@ int omap_dss_reset(struct omap_hwmod *oh)
>> >
>> >          for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i>  0; i--, oc++)
>> >                  if (oc->_clk)
>> >  -                       clk_disable(oc->_clk);
>> >  +                       clk_disable_unprepare(oc->_clk);
>> >
> Just a doubt. Isn't it the same clocks you are preparing in omap_hwmod.c ?

Yes, but different users can and should prepare and enable clocks
independently, and hence the framework does usecounting to keep track.

>
>> >          r = (c == MAX_MODULE_SOFTRESET_WAIT) ? -ETIMEDOUT : 0;
>> >
> d>  diff --git a/arch/arm/mach-omap2/omap_hwmod.c
> b/arch/arm/mach-omap2/omap_hwmod.c
>> >  index bf86f7e..2746bce 100644
>> >  --- a/arch/arm/mach-omap2/omap_hwmod.c
>> >  +++ b/arch/arm/mach-omap2/omap_hwmod.c
>> >  @@ -608,6 +608,7 @@ static int _init_main_clk(struct omap_hwmod *oh)
>> >                             oh->name, oh->main_clk);
>> >                  return -EINVAL;
>> >          }
>> >  +       clk_prepare(oh->_clk);
>> >
>> >          if (!oh->_clk->clkdm)
>> >                  pr_warning("omap_hwmod: %s: missing clockdomain for %s.\n",
>> >  @@ -644,6 +645,7 @@ static int _init_interface_clks(struct omap_hwmod *oh)
>> >                                     oh->name, os->clk);
>> >                          ret = -EINVAL;
>> >                  }
>> >  +               clk_prepare(os->_clk);
>> >                  os->_clk = c;
> You should do clk_prepare() after os->_clk = c statement. Otherwise
> you are operating on a uninitialized structure pointer.

yes, that was really stupid of me :(. Thanks for catching this.

>> >          }
>> >
>> >  @@ -671,6 +673,7 @@ static int _init_opt_clks(struct omap_hwmod *oh)
>> >                                     oh->name, oc->clk);
>> >                          ret = -EINVAL;
>> >                  }
>> >  +               clk_prepare(oc->_clk);
> Same here. You are preparing the uninitialized clk structure.

Thanks, will fix.