Message ID | 20211104082413.3681212-8-gwendal@chromium.org (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | iio: Use scan_type shift and realbits when processing raw data | expand |
diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index a8ec3efd659ed..1d345d66742d8 100644 --- a/drivers/iio/adc/ad7266.c +++ b/drivers/iio/adc/ad7266.c @@ -159,7 +159,8 @@ static int ad7266_read_raw(struct iio_dev *indio_dev, *val = (*val >> 2) & 0xfff; if (chan->scan_type.sign == 's') - *val = sign_extend32(*val, 11); + *val = sign_extend32(*val, + chan->scan_type.realbits - 1); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE:
Use channel definition as root of trust and replace constant when reading elements directly using the raw sysfs attributes. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> --- drivers/iio/adc/ad7266.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)