Re: [PATCH v3 3/5] thermal/drivers/generic-adc: Allow probe without TZ registration
From: Jonathan Cameron
Date: Fri Nov 13 2026 - 19:16:19 EST
On Fri, 13 Nov 2026 16:56:44 +0100
Luca Weiss <luca.weiss@xxxxxxxxxxxxx> wrote:
> If the devicetree node is not referenced in a zone under /thermal-zones,
> devm_thermal_of_zone_register() will fail with -ENODEV.
>
> Since the driver is now also registering as an IIO device[0], allow the
> probe to continue without the thermal zone.
Papering over problems, or expected path for some devices? If it's
expected path we probably don't want to print a message with the
word failed in it.
>
> We also can't use gadc_thermal_get_temp() anymore because we haven't
> necessarily initialized tz_dev.
>
> Link: https://git.kernel.org/torvalds/c/3762f5851ac5 [0]
> Signed-off-by: Luca Weiss <luca.weiss@xxxxxxxxxxxxx>
> ---
> drivers/thermal/thermal-generic-adc.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c
> index c6a7a65aa6a6..40a34e97a515 100644
> --- a/drivers/thermal/thermal-generic-adc.c
> +++ b/drivers/thermal/thermal-generic-adc.c
> @@ -86,14 +86,16 @@ static int gadc_thermal_read_raw(struct iio_dev *indio_dev,
> int *val, int *val2, long mask)
> {
> struct gadc_thermal_info *gtinfo = iio_priv(indio_dev);
> + int iio_val;
> int ret;
>
> switch (mask) {
> case IIO_CHAN_INFO_PROCESSED:
> - ret = gadc_thermal_get_temp(gtinfo->tz_dev, val);
> - if (ret)
> + ret = iio_read_channel_processed(gtinfo->channel, &iio_val);
> + if (ret < 0)
> return ret;
>
> + *val = gadc_thermal_adc_to_temp(gtinfo, iio_val);
Maybe spin a helper that is used both in adc_thermal_get_get_temp()
and here? Whilst it won't save much code (may actually be a touch longer)
it will put the two relevant steps in one place.
> return IIO_VAL_INT;
>
> default:
> @@ -195,14 +197,14 @@ static int gadc_thermal_probe(struct platform_device *pdev)
> &gadc_thermal_ops);
> 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 != -ENODEV)
> + return ret;
>
> - 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);
> + }
>
> return gadc_iio_register(&pdev->dev, gti);
> }
>