aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAntoniu Miclaus <antoniu.miclaus@analog.com>2024-11-01 11:52:01 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2024-11-01 15:24:01 +0000
commitbfa335f18d91c52fa0f8ba3e4d49afebbd9ee792 (patch)
tree0a6a0b52ac7e72fb87ec1f8d887a92a029e6dd9c
parentiio: accel: kx022a: Fix raw read format (diff)
downloadwireguard-linux-bfa335f18d91c52fa0f8ba3e4d49afebbd9ee792.tar.xz
wireguard-linux-bfa335f18d91c52fa0f8ba3e4d49afebbd9ee792.zip
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. Fixes: df36de13677a ("iio: accel: add ADXL380 driver") Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Link: https://patch.msgid.link/20241101095202.20121-1-antoniu.miclaus@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/accel/adxl380.c2
1 files changed, 1 insertions, 1 deletions
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,