diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2021-11-04 11:24:09 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2021-11-17 20:51:42 +0300 |
commit | a5cd0e7f5b3cda94b9f4029b8baef817a7a97226 (patch) | |
tree | 959217cfce5948eafa7091ac26e84014c4e28711 /drivers/iio/adc/ti-adc12138.c | |
parent | 4e9f4c12f1863b890965bfbf81d8d9bc85c12edb (diff) | |
download | linux-a5cd0e7f5b3cda94b9f4029b8baef817a7a97226.tar.xz |
iio: ti-adc12138: 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-10-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc/ti-adc12138.c')
-rw-r--r-- | drivers/iio/adc/ti-adc12138.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iio/adc/ti-adc12138.c b/drivers/iio/adc/ti-adc12138.c index fcd5d39dd03e..5b5d45210539 100644 --- a/drivers/iio/adc/ti-adc12138.c +++ b/drivers/iio/adc/ti-adc12138.c @@ -239,7 +239,8 @@ static int adc12138_read_raw(struct iio_dev *iio, if (ret) return ret; - *value = sign_extend32(be16_to_cpu(data) >> 3, 12); + *value = sign_extend32(be16_to_cpu(data) >> channel->scan_type.shift, + channel->scan_type.realbits - 1); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: |