mirror of https://gitee.com/openkylin/linux.git
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:
parent
7b7a4efe76
commit
a02a8c42b5
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue