Re: [PATCH] thermal: qcom-spmi-adc-tm5: fix all temperature reads failing with -EINVAL

Jonathan Cameron <[email protected]>
Newsgroups org.kernel.vger.linux-iio
Message-ID <20260816214800.433a39ec@jic23-huawei>
On Fri,  7 Aug 2026 19:45:52 -0700
Paul Hollinsky <[email protected]> wrote:

> adc_tm5_get_temp() rejects any iio_read_channel_processed() return value
> that is not IIO_VAL_INT. Since commit bb21ee31f575 ("iio: Fix
> iio_multiply_value use in iio_read_channel_processed_scale"),
> iio_read_channel_processed() returns 0 on success, per its documented
> contract, instead of passing through the value type from the underlying
> read.
> 
> Since IIO_VAL_INT is 1, every successful read now takes the error path,
> so get_temp() returns -EINVAL unconditionally and every ADC-TM5 thermal
> zone is dead: with no valid temperature readings the core cannot
> evaluate trip points. Observed on a SC7180 Trogdor Chromebook (Lenovo
> IdeaPad Duet 3 / wormdingler), where the charger and skin-temp zones
> report an error on every read.
> 
> The check no longer serves its original defensive purpose either: since
> commit 05f958d003c9 ("iio: Improve iio_read_channel_processed_scale()
> precision"), fractional value types are folded into the integer result
> by iio_multiply_value() inside the IIO core, so the return value carries
> no information beyond success or failure. Just drop the check and rely
> on the ret < 0 test above it.
> 
> qcom-spmi-adc-tm5 is the only iio_read_channel_processed() consumer in
> tree still testing the return value this way.
> 
> Fixes: bb21ee31f575 ("iio: Fix iio_multiply_value use in iio_read_channel_processed_scale")
> Cc: [email protected] # 6.18+
> Signed-off-by: Paul Hollinsky <[email protected]>

Acked-by: Jonathan Cameron <[email protected]> #from IIO
Sorry about this. I thought we'd checked all of them but seems some slipped through.

> ---
>  drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
> index bb6222c8cc5f..af72db6299cd 100644
> --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
> +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
> @@ -369,9 +369,6 @@ static int adc_tm5_get_temp(struct thermal_zone_device *tz, int *temp)
>  	if (ret < 0)
>  		return ret;
>  
> -	if (ret != IIO_VAL_INT)
> -		return -EINVAL;
> -
>  	return 0;
>  }
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.