Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: Fix iio_read_channel_processed_scale()
@ 2021-03-23 12:27 Linus Walleij
  2021-03-29 12:26 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2021-03-23 12:27 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Linus Walleij

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

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 {
-- 
2.29.2


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

end of thread, other threads:[~2021-03-29 12:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-23 12:27 [PATCH] iio: Fix iio_read_channel_processed_scale() Linus Walleij
2021-03-29 12:26 ` Jonathan Cameron

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