public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/1] iio: Fix iio_multiply_value use in iio_read_channel_processed_scale
@ 2026-04-16 11:14 Svyatoslav Ryhel
  2026-04-16 11:14 ` [PATCH v1 1/1] " Svyatoslav Ryhel
  0 siblings, 1 reply; 4+ messages in thread
From: Svyatoslav Ryhel @ 2026-04-16 11:14 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Hans de Goede, Svyatoslav Ryhel
  Cc: linux-iio, linux-kernel

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(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v1 1/1] iio: Fix iio_multiply_value use in iio_read_channel_processed_scale
  2026-04-16 11:14 [PATCH v1 0/1] iio: Fix iio_multiply_value use in iio_read_channel_processed_scale Svyatoslav Ryhel
@ 2026-04-16 11:14 ` Svyatoslav Ryhel
  2026-04-16 12:31   ` Hans de Goede
  0 siblings, 1 reply; 4+ messages in thread
From: Svyatoslav Ryhel @ 2026-04-16 11:14 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Hans de Goede, Svyatoslav Ryhel
  Cc: linux-iio, linux-kernel

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.

Fixes: 05f958d003c9 ("iio: Improve iio_read_channel_processed_scale() precision")
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/iio/inkern.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 0df0ab3de270..9ce20cb05a9b 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -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)
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] iio: Fix iio_multiply_value use in iio_read_channel_processed_scale
  2026-04-16 11:14 ` [PATCH v1 1/1] " Svyatoslav Ryhel
@ 2026-04-16 12:31   ` Hans de Goede
  2026-04-19 17:04     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2026-04-16 12:31 UTC (permalink / raw)
  To: Svyatoslav Ryhel, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko
  Cc: linux-iio, linux-kernel

Hi,

On 16-Apr-26 13:14, Svyatoslav Ryhel wrote:
> 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.
> 
> Fixes: 05f958d003c9 ("iio: Improve iio_read_channel_processed_scale() precision")
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>

Thank you, good catch:

Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

Regards,

Hans



> ---
>  drivers/iio/inkern.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 0df0ab3de270..9ce20cb05a9b 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -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)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] iio: Fix iio_multiply_value use in iio_read_channel_processed_scale
  2026-04-16 12:31   ` Hans de Goede
@ 2026-04-19 17:04     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2026-04-19 17:04 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Svyatoslav Ryhel, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-iio, linux-kernel

On Thu, 16 Apr 2026 14:31:00 +0200
Hans de Goede <hansg@kernel.org> wrote:

> Hi,
> 
> On 16-Apr-26 13:14, Svyatoslav Ryhel wrote:
> > 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.
> > 
> > Fixes: 05f958d003c9 ("iio: Improve iio_read_channel_processed_scale() precision")
> > Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>  
> 
> Thank you, good catch:
Indeed and 'ouch'.

Anyhow, applied to the fixes-togreg branch of iio.git and marked
for stable.

Thanks,

Jonathan

> 
> Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> 
> Regards,
> 
> Hans
> 
> 
> 
> > ---
> >  drivers/iio/inkern.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > index 0df0ab3de270..9ce20cb05a9b 100644
> > --- a/drivers/iio/inkern.c
> > +++ b/drivers/iio/inkern.c
> > @@ -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)  
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-04-19 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16 11:14 [PATCH v1 0/1] iio: Fix iio_multiply_value use in iio_read_channel_processed_scale Svyatoslav Ryhel
2026-04-16 11:14 ` [PATCH v1 1/1] " Svyatoslav Ryhel
2026-04-16 12:31   ` Hans de Goede
2026-04-19 17:04     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox