* [PATCH v2] iio: adxrs290: fix data signedness
@ 2021-11-11 14:34 Nuno Sá
2021-11-12 16:23 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Nuno Sá @ 2021-11-11 14:34 UTC (permalink / raw)
To: linux-iio
Cc: Jonathan Cameron, Michael Hennerich, Lars-Peter Clausen,
Nishant Malpani, Andy Shevchenko, Kister Genesis Jimenez
From: Kister Genesis Jimenez <kister.jimenez@analog.com>
Properly sign-extend the rate and temperature data.
Fixes: 2c8920fff1457 ("iio: gyro: Add driver support for ADXRS290")
Signed-off-by: KJimenez <kister.jimenez@analog.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
changes in v2:
* removed redundant temp & 0xFFF.
drivers/iio/gyro/adxrs290.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/gyro/adxrs290.c b/drivers/iio/gyro/adxrs290.c
index 3e0734ddafe3..600e9725da78 100644
--- a/drivers/iio/gyro/adxrs290.c
+++ b/drivers/iio/gyro/adxrs290.c
@@ -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);
--
2.33.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] iio: adxrs290: fix data signedness
2021-11-11 14:34 [PATCH v2] iio: adxrs290: fix data signedness Nuno Sá
@ 2021-11-12 16:23 ` Jonathan Cameron
2021-11-14 16:01 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2021-11-12 16:23 UTC (permalink / raw)
To: Nuno Sá
Cc: linux-iio, Michael Hennerich, Lars-Peter Clausen, Nishant Malpani,
Andy Shevchenko, Kister Genesis Jimenez
On Thu, 11 Nov 2021 15:34:11 +0100
Nuno Sá <nuno.sa@analog.com> wrote:
> From: Kister Genesis Jimenez <kister.jimenez@analog.com>
>
> Properly sign-extend the rate and temperature data.
>
> Fixes: 2c8920fff1457 ("iio: gyro: Add driver support for ADXRS290")
> Signed-off-by: KJimenez <kister.jimenez@analog.com>
Full name needed in Signed-off-by: and should match the From above.
Otherwise this looks fine to me.
Thanks,
Jonathan
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
> changes in v2:
> * removed redundant temp & 0xFFF.
>
> drivers/iio/gyro/adxrs290.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/gyro/adxrs290.c b/drivers/iio/gyro/adxrs290.c
> index 3e0734ddafe3..600e9725da78 100644
> --- a/drivers/iio/gyro/adxrs290.c
> +++ b/drivers/iio/gyro/adxrs290.c
> @@ -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);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] iio: adxrs290: fix data signedness
2021-11-12 16:23 ` Jonathan Cameron
@ 2021-11-14 16:01 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2021-11-14 16:01 UTC (permalink / raw)
To: Nuno Sá
Cc: linux-iio, Michael Hennerich, Lars-Peter Clausen, Nishant Malpani,
Andy Shevchenko, Kister Genesis Jimenez
On Fri, 12 Nov 2021 16:23:46 +0000
Jonathan Cameron <jic23@kernel.org> wrote:
> On Thu, 11 Nov 2021 15:34:11 +0100
> Nuno Sá <nuno.sa@analog.com> wrote:
>
> > From: Kister Genesis Jimenez <kister.jimenez@analog.com>
> >
> > Properly sign-extend the rate and temperature data.
> >
> > Fixes: 2c8920fff1457 ("iio: gyro: Add driver support for ADXRS290")
> > Signed-off-by: KJimenez <kister.jimenez@analog.com>
>
> 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
>
> Thanks,
>
> Jonathan
>
>
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> > changes in v2:
> > * removed redundant temp & 0xFFF.
> >
> > drivers/iio/gyro/adxrs290.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/gyro/adxrs290.c b/drivers/iio/gyro/adxrs290.c
> > index 3e0734ddafe3..600e9725da78 100644
> > --- a/drivers/iio/gyro/adxrs290.c
> > +++ b/drivers/iio/gyro/adxrs290.c
> > @@ -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);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-14 15:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-11 14:34 [PATCH v2] iio: adxrs290: fix data signedness Nuno Sá
2021-11-12 16:23 ` Jonathan Cameron
2021-11-14 16:01 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox