dect
/
linux-2.6
Archived
13
0
Fork 0

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>
This commit is contained in:
Lars-Peter Clausen 2013-01-09 14:01:00 +00:00 committed by Jonathan Cameron
parent 7b7a4efe76
commit a02a8c42b5
1 changed files with 1 additions and 1 deletions

View File

@ -69,7 +69,7 @@ static int adis16080_spi_read(struct iio_dev *indio_dev,
ret = spi_read(st->us, st->buf, 2);
if (ret == 0)
*val = ((st->buf[0] & 0xF) << 8) | st->buf[1];
*val = sign_extend32(((st->buf[0] & 0xF) << 8) | st->buf[1], 11);
mutex_unlock(&st->buf_lock);
return ret;