iio: Fix iio_multiply_value use in iio_read_channel_processed_scale
cover iio: Fix iio_multiply_value use in iio_read_channel_processed_scale
The function iio_multiply_value returns IIO_VAL_INT (1) on success or a negative error number on failure, while iio_read_channel_processed_scale should return an error code or 0. This creates a situation where the expected result is treated as an error. Fix this by checking the iio_multiply_value result separately, instead of passing it as a return value.
Svyatoslav Ryhel (1):
iio: Fix iio_multiply_value use in iio_read_channel_processed_scale
drivers/iio/inkern.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.51.0
PATCH 1/1 iio: Fix iio_multiply_value use in iio_read_channel_processed_scale
The function iio_multiply_value returns IIO_VAL_INT (1) on success or a negative error number on failure, while iio_read_channel_processed_scale should return an error code or 0. This creates a situation where the expected result is treated as an error. Fix this by checking the iio_multiply_value result separately, instead of passing it as a return value.
--- drivers/iio/inkern.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iio/inkern.c +5 -1
@@ -738,7 +738,11 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,if (ret <0 )return ret; -return iio_multiply_value (val, scale, ret, pval, pval2); + ret =iio_multiply_value (val, scale, ret, pval, pval2); +if (ret <0 ) +return ret; + +return 0 ; }else { ret =iio_channel_read (chan, val,NULL ,IIO_CHAN_INFO_RAW );if (ret <0 )
Signature · 1 line
2.51.0
Hi,
Quoted 9 lines · Svyatoslav Ryhel
The function
iio_multiply_valuereturnsIIO_VAL_INT(1) on success or a negative error number on failure, whileiio_read_channel_processed_scaleshould return an error code or 0. This creates a situation where the expected result is treated as an error. Fix this by checking theiio_multiply_valueresult separately, instead of passing it as a return value.Fixes 05f958d003c9 ("iio: Improve iio_read_channel_processed_scale() precision")Signed-off-by Svyatoslav Ryhel <[email protected]>
Thank you, good catch:
Regards,
Hans
Quoted 21 lines
--- drivers/iio/inkern.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/iio/inkern.c +5
-1@@ -738,7 +738,11 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,if (ret <0 )return ret; -return iio_multiply_value (val, scale, ret, pval, pval2); + ret =iio_multiply_value (val, scale, ret, pval, pval2); +if (ret <0 ) +return ret; + +return 0 ; }else { ret =iio_channel_read (chan, val,NULL ,IIO_CHAN_INFO_RAW );if (ret <0 )
Jonathan Cameron
maintainerQuoted 10 lines · On Thu, 16 Apr 2026 14:31:00 +0200 Hans de Goede <[email protected]> wrote:
Hi,
Quoted 7 lines · Svyatoslav Ryhel
The function
iio_multiply_valuereturnsIIO_VAL_INT(1) on success or a negative error number on failure, whileiio_read_channel_processed_scaleshould return an error code or 0. This creates a situation where the expected result is treated as an error. Fix this by checking theiio_multiply_valueresult separately, instead of passing it as a return value.
Quoted 4 lines
Quoted 2 lines
Fixes 05f958d003c9 ("iio: Improve iio_read_channel_processed_scale() precision")Signed-off-by Svyatoslav Ryhel <[email protected]>Thank you, good catch:
Indeed and 'ouch'.
Anyhow, applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
Quoted 32 lines
Reviewed-by Hans de Goede <[email protected]>Regards,
Hans
Quoted 21 lines
--- drivers/iio/inkern.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/iio/inkern.c +5
-1@@ -738,7 +738,11 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,if (ret <0 )return ret; -return iio_multiply_value (val, scale, ret, pval, pval2); + ret =iio_multiply_value (val, scale, ret, pval, pval2); +if (ret <0 ) +return ret; + +return 0 ; }else { ret =iio_channel_read (chan, val,NULL ,IIO_CHAN_INFO_RAW );if (ret <0 )