From: Lars-Peter Clausen Date: Wed, 9 Jan 2013 14:01:00 +0000 (+0000) Subject: staging:iio:adis16080: Perform sign extension X-Git-Tag: MMI-PSA29.97-13-9~15159^2~2^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a02a8c42b588059aa06dff6f614a7afcba12df69;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.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 Signed-off-by: Jonathan Cameron --- 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, 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;