[PATCH 1/2] clk: Add a devm variant of clk_rate_exclusive_get()

Stephen Boyd sboyd at kernel.org
Thu Jan 4 13:38:27 PST 2024


Quoting Uwe Kleine-König (2024-01-04 10:06:29)
> Hello Stephen,
> 
> On Mon, Dec 18, 2023 at 02:01:41PM +0100, Uwe Kleine-K�nig wrote:
> > [Cc += Maxime]
> > 
> > Hello Stephen,
> > 
> > On Sun, Dec 17, 2023 at 04:17:41PM -0800, Stephen Boyd wrote:
> > > Quoting Uwe Kleine-K�nig (2023-12-12 10:09:42)
> > > > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > > > index af2011c2a93b..78249ca2341c 100644
> > > > --- a/drivers/clk/clk.c
> > > > +++ b/drivers/clk/clk.c
> > > > @@ -937,6 +937,21 @@ void clk_rate_exclusive_get(struct clk *clk)
> > > >  }
> > > >  EXPORT_SYMBOL_GPL(clk_rate_exclusive_get);
> > > >  
> > > > +static void devm_clk_rate_exclusive_put(void *data)
> > > > +{
> > > > +       struct clk *clk = data;
> > > > +
> > > > +       clk_rate_exclusive_put(clk);
> > > > +}
> > > > +
> > > > +int devm_clk_rate_exclusive_get(struct device *dev, struct clk *clk)
> > > > +{
> > > > +       clk_rate_exclusive_get(clk);
> > > 
> > > It seems the other thread wants this to return an error value.
> > 
> > The status quo is that clk_rate_exclusive_get() always returns zero.
> > Some users do error handling (which is dead code until Maxime reworks
> > the call that it might return something non-zero), others just call it
> > without checking.
> > 
> > If you don't require to add something like:
> > 
> >       ret = clk_rate_exclusive_get(clk);
> >       if (ret)
> >               return ret;
> > 
> > where we currently have just
> > 
> >       clk_rate_exclusive_get(clk);
> > 
> > the patch can just be applied (using git am -3) not even hitting a merge
> > conflict without that other series.
> 
> I wonder what you think about this. This devm_clk_rate_exclusive_get()
> would be very useful and simplify a few more drivers.
> 
> Do you intend to take the patch as is, or should I rework it to check
> for the zero it returns?
> 

Please check the return value even if it is always zero. The discussion
about handling the return value can continue in parallel.



More information about the linux-arm-kernel mailing list