mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: accel: adxl380: fix raw sample read
@ 2024-11-01  9:52 Antoniu Miclaus
  2024-11-01 15:24 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Antoniu Miclaus @ 2024-11-01  9:52 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Ramona Gradinariu,
	Antoniu Miclaus, Jonathan Cameron, linux-iio, linux-kernel

The adxl380_read_chn function returns either a negative value in case an
error occurs or the actual sample.

Check only for negative values after a channel is read.

Fixes: df36de13677a ("iio: accel: add ADXL380 driver")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 drivers/iio/accel/adxl380.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/accel/adxl380.c b/drivers/iio/accel/adxl380.c
index f80527d899be..b19ee37df7f1 100644
--- a/drivers/iio/accel/adxl380.c
+++ b/drivers/iio/accel/adxl380.c
@@ -1181,7 +1181,7 @@ static int adxl380_read_raw(struct iio_dev *indio_dev,
 
 		ret = adxl380_read_chn(st, chan->address);
 		iio_device_release_direct_mode(indio_dev);
-		if (ret)
+		if (ret < 0)
 			return ret;
 
 		*val = sign_extend32(ret >> chan->scan_type.shift,
-- 
2.47.0


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

end of thread, other threads:[~2024-11-01 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-01  9:52 [PATCH] iio: accel: adxl380: fix raw sample read Antoniu Miclaus
2024-11-01 15:24 ` Jonathan Cameron

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

all inboxes | Powered by JetHome®