[PATCH] pwm: xilinx: Simplify using devm_ functions

Uwe Kleine-König u.kleine-koenig at baylibre.com
Sat Jun 29 01:17:24 PDT 2024


Hello Sean,

On Fri, Jun 28, 2024 at 05:04:47PM -0400, Sean Anderson wrote:
> On 6/28/24 02:35, Uwe Kleine-König wrote:
> > -     ret = clk_prepare_enable(priv->clk);
> > +     ret = devm_clk_rate_exclusive_get(dev, priv->clk);
> >       if (ret)
> > -             return dev_err_probe(dev, ret, "Clock enable failed\n");
> > -     clk_rate_exclusive_get(priv->clk);
> > +             return dev_err_probe(dev, ret,
> > +                                  "Failed to lock clock rate\n");
> 
> Isn't this actually "failed to allocate memory"? clk_rate_exclusive_get can't fail.

There was a thread about clk_rate_exclusive_get() and its return code
some time ago[1]. I intend to pick up the discussion from there, this is
a preparation for it.

So yes, devm_clk_rate_exclusive_get() can only fail with -ENOMEM, but as
this isn't obvious for a casual reader, I like having the error handling
using dev_err_probe() in place. And since commit 2f3cfd2f4b7c ("driver
core: Make dev_err_probe() silent for -ENOMEM") this is also fine (at
least IMHO, I don't expect to have the agreement from everyone).

> Anyway,
> 
> Reviewed-by: Sean Anderson <sean.anderson at seco.com>

Thanks!

Best regards
Uwe

[1] https://lore.kernel.org/all/cover.1702400947.git.u.kleine-koenig@pengutronix.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20240629/dd179895/attachment.sig>


More information about the linux-arm-kernel mailing list