Commit a5cd0e7f authored by Gwendal Grignou's avatar Gwendal Grignou Committed by Jonathan Cameron

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: default avatarGwendal Grignou <gwendal@chromium.org>
Link: https://lore.kernel.org/r/20211104082413.3681212-10-gwendal@chromium.orgSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 4e9f4c12
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment