iio: adxrs290: fix data signedness
Subsystems (3)
Nuno Sá
maintainerPATCH v2 1/1 iio: adxrs290: fix data signedness
From: Kister Genesis Jimenez <[email protected]>
Properly sign-extend the rate and temperature data.
---
changes in v2:
* removed redundant temp & 0xFFF.
drivers/iio/gyro/adxrs290.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iio/gyro/adxrs290.c +3 -2
@@ -7,6 +7,7 @@*/ #include <linux/bitfield.h> +#include <linux/bitops.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/kernel.h>
@@ -124,7 +125,7 @@ static int adxrs290_get_rate_data(struct iio_dev *indio_dev, const u8 cmd, int * goto err_unlock; } - *val = temp; + *val =sign_extend32 (temp,15 ); err_unlock:mutex_unlock (&st->lock);
@@ -146,7 +147,7 @@ static int adxrs290_get_temp_data(struct iio_dev *indio_dev, int *val) }/* extract lower 12 bits temperature reading */ - *val = temp &0x0FFF ; + *val =sign_extend32 (temp,11 ); err_unlock:mutex_unlock (&st->lock);
Signature · 1 line
2.33.1
Jonathan Cameron
maintainerQuoted 6 lines · On Thu, 11 Nov 2021 15:34:11 +0100 Nuno Sá <[email protected]> wrote:
From: Kister Genesis Jimenez <[email protected]>
Properly sign-extend the rate and temperature data.
Fixes 2c8920fff1457 ("iio: gyro: Add driver support for ADXRS290")Signed-off-by KJimenez <[email protected]>
Full name needed in Signed-off-by: and should match the From above.
Otherwise this looks fine to me.
Thanks,
Jonathan
Quoted 38 lines
Signed-off-by Nuno Sá <[email protected]>---
changes in v2:
* removed redundant temp &0xFFF.drivers/iio/gyro/adxrs290.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/iio/gyro/adxrs290.c +3
-2@@ -7,6 +7,7 @@*/ #include <linux/bitfield.h> +#include <linux/bitops.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/kernel.h> @@ -124,7 +125,7 @@ static int adxrs290_get_rate_data(struct iio_dev *indio_dev, const u8 cmd, int * goto err_unlock; } - *val = temp; + *val =sign_extend32 (temp,15 ); err_unlock:mutex_unlock (&st->lock);@@ -146,7 +147,7 @@ static int adxrs290_get_temp_data(struct iio_dev *indio_dev, int *val) }/* extract lower 12 bits temperature reading */ - *val = temp &0x0FFF ; + *val =sign_extend32 (temp,11 ); err_unlock:mutex_unlock (&st->lock);
Jonathan Cameron
maintainerQuoted 5 lines · On Fri, 12 Nov 2021 16:23:46 +0000 Jonathan Cameron <[email protected]> wrote:
Quoted 2 lines · On Thu, 11 Nov 2021 15:34:11 +0100 Nuno Sá <[email protected]> wrote:
From: Kister Genesis Jimenez <[email protected]>
Quoted 8 lines
Quoted 4 lines
Properly sign-extend the rate and temperature data.
Fixes 2c8920fff1457 ("iio: gyro: Add driver support for ADXRS290")Signed-off-by KJimenez <[email protected]>Full name needed in Signed-off-by: and should match the From above.
Otherwise this looks fine to me.
By which I mean send a v3 with that fixed. I don't like messing with tags whilst applying because there are legal implications etc of messing with DCO related parts.
Thanks,
Jonathan
Quoted 45 lines
Thanks,
Jonathan
Quoted 38 lines
Signed-off-by Nuno Sá <[email protected]>---
changes in v2:
* removed redundant temp &0xFFF.drivers/iio/gyro/adxrs290.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/iio/gyro/adxrs290.c +3
-2@@ -7,6 +7,7 @@*/ #include <linux/bitfield.h> +#include <linux/bitops.h> #include <linux/delay.h> #include <linux/device.h> #include <linux/kernel.h> @@ -124,7 +125,7 @@ static int adxrs290_get_rate_data(struct iio_dev *indio_dev, const u8 cmd, int * goto err_unlock; } - *val = temp; + *val =sign_extend32 (temp,15 ); err_unlock:mutex_unlock (&st->lock);@@ -146,7 +147,7 @@ static int adxrs290_get_temp_data(struct iio_dev *indio_dev, int *val) }/* extract lower 12 bits temperature reading */ - *val = temp &0x0FFF ; + *val =sign_extend32 (temp,11 ); err_unlock:mutex_unlock (&st->lock);