[PATCH v2 2/2] iio: accel: fxls8962af: Fix sign temperature scan element

Sean Nyekjaer posted 2 patches 9 months, 1 week ago
There is a newer version of this series
[PATCH v2 2/2] iio: accel: fxls8962af: Fix sign temperature scan element
Posted by Sean Nyekjaer 9 months, 1 week ago
TEMP_OUT register contains the 8-bit, 2's complement temperature value.
Let's mark the temperature scan element signed.

Fixes: a3e0b51884ee ("iio: accel: add support for FXLS8962AF/FXLS8964AF accelerometers")
Suggested-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
---
 drivers/iio/accel/fxls8962af-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
index f515222e008493687921879a0b0ef44fd4ae5d10..e1b752e202b877db606a55a978d63ef52894c60d 100644
--- a/drivers/iio/accel/fxls8962af-core.c
+++ b/drivers/iio/accel/fxls8962af-core.c
@@ -750,6 +750,7 @@ static const struct iio_event_spec fxls8962af_event[] = {
 			      BIT(IIO_CHAN_INFO_OFFSET),\
 	.scan_index = -1, \
 	.scan_type = { \
+		.sign = 's', \
 		.realbits = 8, \
 		.storagebits = 8, \
 	}, \

-- 
2.47.1
Re: [PATCH v2 2/2] iio: accel: fxls8962af: Fix sign temperature scan element
Posted by Marcelo Schmitt 9 months, 1 week ago
On 05/02, Sean Nyekjaer wrote:
> TEMP_OUT register contains the 8-bit, 2's complement temperature value.
> Let's mark the temperature scan element signed.
> 
> Fixes: a3e0b51884ee ("iio: accel: add support for FXLS8962AF/FXLS8964AF accelerometers")
> Suggested-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Sean Nyekjaer <sean@geanix.com>

Sort of nitpinking but I think the commit description could be more assertive.
The main idea is that we want to make the scan element signed because the
data read from the TEMP_OUT register is in two's complement format and not
having the scan element marked as a signed number may cause it to be mishandled
and miss displayed. Nevertheless, I do think the patch is good so

Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Re: [PATCH v2 2/2] iio: accel: fxls8962af: Fix sign temperature scan element
Posted by Jonathan Cameron 9 months, 1 week ago
On Sat, 3 May 2025 10:57:09 -0300
Marcelo Schmitt <marcelo.schmitt1@gmail.com> wrote:

> On 05/02, Sean Nyekjaer wrote:
> > TEMP_OUT register contains the 8-bit, 2's complement temperature value.
> > Let's mark the temperature scan element signed.
> > 
> > Fixes: a3e0b51884ee ("iio: accel: add support for FXLS8962AF/FXLS8964AF accelerometers")
> > Suggested-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Sean Nyekjaer <sean@geanix.com>  
> 
> Sort of nitpinking but I think the commit description could be more assertive.

Agreed.  I might have just tweaked it to
"Mark the temperature element signed."  + some of what Marcelo has below.
but given Andy's request on patch 1 means you are probably doing a v3, please
tidy this up as well.

Thanks and good catches on both of them!

Jonathan

> The main idea is that we want to make the scan element signed because the
> data read from the TEMP_OUT register is in two's complement format and not
> having the scan element marked as a signed number may cause it to be mishandled
> and miss displayed. Nevertheless, I do think the patch is good so
> 
> Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
>