mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-01 10:43:43 +00:00
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: df36de1367
("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>
This commit is contained in:
parent
b7d2bc99b3
commit
bfa335f18d
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user