Re: [PATCH v2 3/5] thermal/drivers/generic-adc: Allow probe without TZ registration

Andy Shevchenko
2026-02-20T10:50:22Z

On Fri, Feb 20, 2026 at 10:19:07AM +0100, Luca Weiss wrote:
> If the devicetree node is not referenced in a zone under /thermal-zones,
> devm_thermal_of_zone_register will fail with -ENODEV.

devm_thermal_of_zone_register()

> Since the driver is now also registering as an IIO device[0], allow the
> probe to continue without the thermal zone.

Isn't it dangerous?

> We also can't use gadc_thermal_get_temp anymore because we haven't

gadc_thermal_get_temp()

> necessarily initialized tz_dev.

> [0] commit 3762f5851ac5 ("thermal/drivers/thermal-generic-adc: Add temperature sensor channel")

You can make it a Link tag:

Link: https://git.kernel.org/torvalds/c/3762f5851ac5 [0]

> Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>

...

> if (IS_ERR(gti->tz_dev)) {
> ret = PTR_ERR(gti->tz_dev);
> - if (ret != -EPROBE_DEFER)
> - dev_err(dev,
> - "Thermal zone sensor register failed: %d\n",
> - ret);
> - return ret;
> - }
> + if (ret == -EPROBE_DEFER)
> + return ret;

I believe it's better to return all possible errors. If you see the
similarities with regulator APIs, then use an explicit check for -ENODEV.

> - devm_thermal_add_hwmon_sysfs(dev, gti->tz_dev);
> + dev_info(dev, "Thermal zone sensor register failed: %d\n",
> + ret);
> + } else {
> + devm_thermal_add_hwmon_sysfs(dev, gti->tz_dev);
> + }

--
With Best Regards,
Andy Shevchenko