Skip to content

Commit

Permalink
staging:iio:adxrs450: Perform sign extension for the calibbias register
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lars-Peter Clausen authored and Jonathan Cameron committed Feb 2, 2013
1 parent 1a87e4f commit c62b89c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/iio/gyro/adxrs450_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c62b89c

Please sign in to comment.