diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2021-11-04 11:24:07 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2021-11-17 20:51:42 +0300 |
commit | 4e9f4c12f1863b890965bfbf81d8d9bc85c12edb (patch) | |
tree | 7cc38bc3d54732953810420b3d562cabac1e37f0 /drivers/iio/adc/ad7266.c | |
parent | ded408b1135437540d27012da7b6f1afb4f4bf65 (diff) | |
download | linux-4e9f4c12f1863b890965bfbf81d8d9bc85c12edb.tar.xz |
iio: ad7266: Use scan_type when processing raw data
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>
Link: https://lore.kernel.org/r/20211104082413.3681212-8-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc/ad7266.c')
-rw-r--r-- | drivers/iio/adc/ad7266.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index a8ec3efd659e..1d345d66742d 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: |