From c62b89c713ebd5e4a67c9b9229591adab8953a3c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 31 Jan 2013 14:27:00 +0000 Subject: [PATCH] staging:iio:adxrs450: Perform sign extension for the calibbias register The calibbias (DNC) register contains a 10-bit twos complement value. Perform a proper sign extension when reading the register, otherwise negative will incorrectly be displayed as large positive values. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adxrs450_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index 91a2fae1abbe..4c462d36dac9 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c @@ -326,7 +326,7 @@ static int adxrs450_read_raw(struct iio_dev *indio_dev, ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_DNC1, &t); if (ret) break; - *val = t; + *val = sign_extend32(t, 9); ret = IIO_VAL_INT; break; default: -- 2.30.2