Thread (20 messages) 20 messages, 6 authors, 2025-09-05

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

From: Andy Shevchenko <hidden>
Date: 2025-09-05 09:34:31
Also in: imx, linux-amlogic, linux-arm-msm, linux-hwmon, linux-iio, linux-omap, linux-pm, linux-renesas-soc, linux-samsung-soc, linux-sunxi, linux-tegra, lkml

On Fri, Sep 5, 2025 at 10:25 AM Xichao Zhao [off-list ref] wrote:
devm_thermal_of_zone_register() does not print any error message
when registering a thermal zone with a device node sensor fails
and allocating device resource data fails.

This forces each driver to implement redundant error logging.
Additionally, when upper-layer functions propagate these errors
without logging, critical debugging information is lost.

Add dev_err_probe() in devm_thermal_of_zone_register() to unify
error reporting.
...
        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 mesasge. Can't we use

  return dev_err_probe(dev, PTR_ERR(...), ...);

instead?

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help