From: Jonathan Cameron Date: Sun, 14 Mar 2021 18:15:04 +0000 (+0000) Subject: staging:iio:cdc:ad7150: Shift the _raw readings by 4 bits. X-Git-Tag: accepted/tizen/unified/20230118.172025~7414^2~195^2~44 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f28334febda7f06b97dad2fa61a61831e03c88d1;p=platform%2Fkernel%2Flinux-rpi.git staging:iio:cdc:ad7150: Shift the _raw readings by 4 bits. Every other register related to raw value on the datasheet is described as correpsonding to the 12MSB of the actual data registers + the bottom 4 bits are 0. So lets treat this as what it actually is, which is a 12 bit value. Note that we will have to be a little careful to compensate for the offset and scale values. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20210314181511.531414-18-jic23@kernel.org --- diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 8bdb97a..5abc4e9 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -111,7 +111,7 @@ static int ad7150_read_raw(struct iio_dev *indio_dev, ad7150_addresses[channel][0]); if (ret < 0) return ret; - *val = ret; + *val = ret >> 4; return IIO_VAL_INT; case IIO_CHAN_INFO_AVERAGE_RAW: