public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Hans de Goede <hansg@kernel.org>
Cc: "Svyatoslav Ryhel" <clamor95@gmail.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/1] iio: Fix iio_multiply_value use in iio_read_channel_processed_scale
Date: Sun, 19 Apr 2026 18:04:49 +0100	[thread overview]
Message-ID: <20260419180449.4f4df9ed@jic23-huawei> (raw)
In-Reply-To: <533baaf1-4ae8-4401-b5b0-67e495a426ba@kernel.org>

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


      reply	other threads:[~2026-04-19 17:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260419180449.4f4df9ed@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=clamor95@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=hansg@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox