Skip to content

Commit fde272e

Browse files
kister-jimenezjic23
authored andcommitted
iio: gyro: adxrs290: fix data signedness
Properly sign-extend the rate and temperature data. Fixes: 2c8920f ("iio: gyro: Add driver support for ADXRS290") Signed-off-by: Kister Genesis Jimenez <[email protected]> Signed-off-by: Nuno Sá <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 6661146 commit fde272e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/iio/gyro/adxrs290.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
#include <linux/bitfield.h>
10+
#include <linux/bitops.h>
1011
#include <linux/delay.h>
1112
#include <linux/device.h>
1213
#include <linux/kernel.h>
@@ -124,7 +125,7 @@ static int adxrs290_get_rate_data(struct iio_dev *indio_dev, const u8 cmd, int *
124125
goto err_unlock;
125126
}
126127

127-
*val = temp;
128+
*val = sign_extend32(temp, 15);
128129

129130
err_unlock:
130131
mutex_unlock(&st->lock);
@@ -146,7 +147,7 @@ static int adxrs290_get_temp_data(struct iio_dev *indio_dev, int *val)
146147
}
147148

148149
/* extract lower 12 bits temperature reading */
149-
*val = temp & 0x0FFF;
150+
*val = sign_extend32(temp, 11);
150151

151152
err_unlock:
152153
mutex_unlock(&st->lock);

0 commit comments

Comments
 (0)