Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a02a8c42 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron
Browse files

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: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 7b7a4efe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;