diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2021-11-04 11:24:06 +0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2021-11-17 20:51:42 +0300 |
commit | ded408b1135437540d27012da7b6f1afb4f4bf65 (patch) | |
tree | 7eba226902393748450c01d6f43919bb4ae7647c /drivers/iio | |
parent | 571f8d006f39d8159d80f65eeb15603e649f6611 (diff) | |
download | linux-ded408b1135437540d27012da7b6f1afb4f4bf65.tar.xz |
iio: stk8ba50: 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-7-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/accel/stk8ba50.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c index e137a34b5c9a..517c57ed9e94 100644 --- a/drivers/iio/accel/stk8ba50.c +++ b/drivers/iio/accel/stk8ba50.c @@ -227,7 +227,8 @@ static int stk8ba50_read_raw(struct iio_dev *indio_dev, mutex_unlock(&data->lock); return -EINVAL; } - *val = sign_extend32(ret >> STK8BA50_DATA_SHIFT, 9); + *val = sign_extend32(ret >> chan->scan_type.shift, + chan->scan_type.realbits - 1); stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND); mutex_unlock(&data->lock); return IIO_VAL_INT; |