[PATCH 01/12] thermal: of: Add error handling in devm_thermal_*_register()

Andy Shevchenko andy.shevchenko at gmail.com
Fri Sep 5 02:35:33 PDT 2025


On Fri, Sep 5, 2025 at 12:33 PM Andy Shevchenko
<andy.shevchenko at gmail.com> wrote:
> On Fri, Sep 5, 2025 at 10:25 AM Xichao Zhao <zhao.xichao at vivo.com> wrote:

...

> >         ptr = devres_alloc(devm_thermal_of_zone_release, sizeof(*ptr),
> >                            GFP_KERNEL);
> > -       if (!ptr)
> > +       if (!ptr) {
>
> > +               dev_err(dev, "Failed to allocate device resource data\n");
>
> We do not add error messages for ENOMEM.
>
> >                 return ERR_PTR(-ENOMEM);
>
> Even if you want so eagerly to do that, it should be
>
>    return dev_err_probe();
>
> But, it will ignore the ENOMEM error code for printing.
>
> > +       }
>
> So, the bottom line, no need to add this message here.

...

> >         tzd = thermal_of_zone_register(dev->of_node, sensor_id, data, ops);
> >         if (IS_ERR(tzd)) {
> > +               dev_err_probe(dev, PTR_ERR(tzd),
> > +                             "Failed to register thermal zone sensor[%d]\n", sensor_id);
> >                 devres_free(ptr);
> >                 return tzd;
>
> I don't see how ptr is related to the message. Can't we use
>
>   return dev_err_probe(dev, PTR_ERR(...), ...);
>
> instead?

On top of that can we actually use devm_add_action_or_reset()?

-- 
With Best Regards,
Andy Shevchenko



More information about the linux-amlogic mailing list