staging:iio:adxrs450: Perform sign extension for the calibbias register
authorLars-Peter Clausen <lars@metafoo.de>
Thu, 31 Jan 2013 14:27:00 +0000 (14:27 +0000)
committerJonathan Cameron <jic23@kernel.org>
Sat, 2 Feb 2013 09:20:56 +0000 (09:20 +0000)
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 <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/gyro/adxrs450_core.c

index 91a2fae1abbe2abd57c3a166d338c7d2e16d18fb..4c462d36dac95d7eb0ce1f00a012211b48a7fc26 100644 (file)
@@ -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: