aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-01-09 09:01:00 -0500
committerJonathan Cameron <jic23@kernel.org>2013-01-09 16:15:33 -0500
commita02a8c42b588059aa06dff6f614a7afcba12df69 (patch)
tree38dc5486e08fdfe602c369f4f3db833700ee6b3e
parent7b7a4efe76a8a96b20f7ac8047869f43e65b10e4 (diff)
staging:iio:adis16080: Perform sign extension
The adis16080 reports sample values in twos complement. So we need to perform a sign extension on the result, otherwise negative values will be reported incorrectly as large positive values. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/staging/iio/gyro/adis16080_core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c
index 3525a68d6a75..41d7350d030f 100644
--- a/drivers/staging/iio/gyro/adis16080_core.c
+++ b/drivers/staging/iio/gyro/adis16080_core.c
@@ -69,7 +69,7 @@ static int adis16080_spi_read(struct iio_dev *indio_dev,
69 ret = spi_read(st->us, st->buf, 2); 69 ret = spi_read(st->us, st->buf, 2);
70 70
71 if (ret == 0) 71 if (ret == 0)
72 *val = ((st->buf[0] & 0xF) << 8) | st->buf[1]; 72 *val = sign_extend32(((st->buf[0] & 0xF) << 8) | st->buf[1], 11);
73 mutex_unlock(&st->buf_lock); 73 mutex_unlock(&st->buf_lock);
74 74
75 return ret; 75 return ret;