diff mbox series

iio: Fix iio_read_channel_processed_scale()

Message ID 20210323122705.1326362-1-linus.walleij@linaro.org (mailing list archive)
State New, archived
Headers show
Series iio: Fix iio_read_channel_processed_scale() | expand

Commit Message

Linus Walleij March 23, 2021, 12:27 p.m. UTC
The code was checking if (ret) from the processed
channel readout, not smart, we need to check if (ret < 0)
as this will likely be something like IIO_VAL_INT.

Fixes: dc98269f7c7d ("iio: Provide iio_read_channel_processed_scale() API")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Jonathan: this Fixes tag is the commit ID found in your
testing branch, feel free to just squash if you prefer
that.
---
 drivers/iio/inkern.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Cameron March 29, 2021, 12:26 p.m. UTC | #1
On Tue, 23 Mar 2021 13:27:05 +0100
Linus Walleij <linus.walleij@linaro.org> wrote:

> The code was checking if (ret) from the processed
> channel readout, not smart, we need to check if (ret < 0)
> as this will likely be something like IIO_VAL_INT.
> 
> Fixes: dc98269f7c7d ("iio: Provide iio_read_channel_processed_scale() API")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> Jonathan: this Fixes tag is the commit ID found in your
> testing branch, feel free to just squash if you prefer
> that.

Applied to the togreg branch of iio.git

Thanks,

Jonathan

> ---
>  drivers/iio/inkern.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index c61fc06f98b8..9c22697b7e83 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -702,7 +702,7 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
>  	if (iio_channel_has_info(chan->channel, IIO_CHAN_INFO_PROCESSED)) {
>  		ret = iio_channel_read(chan, val, NULL,
>  				       IIO_CHAN_INFO_PROCESSED);
> -		if (ret)
> +		if (ret < 0)
>  			goto err_unlock;
>  		*val *= scale;
>  	} else {
diff mbox series

Patch

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index c61fc06f98b8..9c22697b7e83 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -702,7 +702,7 @@  int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
 	if (iio_channel_has_info(chan->channel, IIO_CHAN_INFO_PROCESSED)) {
 		ret = iio_channel_read(chan, val, NULL,
 				       IIO_CHAN_INFO_PROCESSED);
-		if (ret)
+		if (ret < 0)
 			goto err_unlock;
 		*val *= scale;
 	} else {