Commit 571f8d00 authored by Gwendal Grignou's avatar Gwendal Grignou Committed by Jonathan Cameron

iio: stk8312: 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-6-gwendal@chromium.orgSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 5405c9b4
...@@ -355,7 +355,7 @@ static int stk8312_read_raw(struct iio_dev *indio_dev, ...@@ -355,7 +355,7 @@ static int stk8312_read_raw(struct iio_dev *indio_dev,
mutex_unlock(&data->lock); mutex_unlock(&data->lock);
return ret; return ret;
} }
*val = sign_extend32(ret, 7); *val = sign_extend32(ret, chan->scan_type.realbits - 1);
ret = stk8312_set_mode(data, ret = stk8312_set_mode(data,
data->mode & (~STK8312_MODE_ACTIVE)); data->mode & (~STK8312_MODE_ACTIVE));
mutex_unlock(&data->lock); mutex_unlock(&data->lock);
......
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