From 54eb23f4b5c6093916f208772627f7b68f495559 Mon Sep 17 00:00:00 2001 From: Antoniu Miclaus Date: Tue, 5 Nov 2024 11:41:49 +0200 Subject: [PATCH] iio: accel: adxl380: fix raw sample read 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. Link: https://lore.kernel.org/lkml/20241101095202.20121-1-antoniu.miclaus@analog.com/ Fixes: 90a7580768fd ("iio: accel: add ADXL380 driver") Signed-off-by: Antoniu Miclaus --- 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 975e23fc513f36..dbdc03967ee799 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, return ret; ret = adxl380_read_chn(st, chan->address); - if (ret) + if (ret < 0) return ret; iio_device_release_direct_mode(indio_dev);