summaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2021-11-04 01:24:03 -0700
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2021-11-17 17:51:41 +0000
commit1aa2f96abbcc7e68a13ce53deaf41cb2fd2debfa (patch)
tree6c69b769869d628928d4aa9ea66e6dbff576e811 /drivers/iio
parent9105079db67a64fa58c10e699aabfe4703f5ac3f (diff)
downloadlinux-stable-1aa2f96abbcc7e68a13ce53deaf41cb2fd2debfa.tar.gz
linux-stable-1aa2f96abbcc7e68a13ce53deaf41cb2fd2debfa.tar.bz2
linux-stable-1aa2f96abbcc7e68a13ce53deaf41cb2fd2debfa.zip
iio: mma7455: 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-4-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/accel/mma7455_core.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c
index 777c6c384b09..e6739ba74edf 100644
--- a/drivers/iio/accel/mma7455_core.c
+++ b/drivers/iio/accel/mma7455_core.c
@@ -134,7 +134,8 @@ static int mma7455_read_raw(struct iio_dev *indio_dev,
if (ret)
return ret;
- *val = sign_extend32(le16_to_cpu(data), 9);
+ *val = sign_extend32(le16_to_cpu(data),
+ chan->scan_type.realbits - 1);
return IIO_VAL_INT;