Skip to content

Commit 5577ad8

Browse files
sknseanpopcornmix
authored andcommitted
iio: accel: fxls8962af: Fix temperature calculation
commit 1603847 upstream. According to spec temperature should be returned in milli degrees Celsius. Add in_temp_scale to calculate from Celsius to milli Celsius. Fixes: a3e0b51 ("iio: accel: add support for FXLS8962AF/FXLS8964AF accelerometers") Cc: stable@vger.kernel.org Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Signed-off-by: Sean Nyekjaer <sean@geanix.com> Link: https://patch.msgid.link/20250505-fxls-v4-1-a38652e21738@geanix.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 22a79bb commit 5577ad8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/iio/accel/fxls8962af-core.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/property.h>
2323
#include <linux/regulator/consumer.h>
2424
#include <linux/regmap.h>
25+
#include <linux/units.h>
2526

2627
#include <linux/iio/buffer.h>
2728
#include <linux/iio/events.h>
@@ -436,8 +437,16 @@ static int fxls8962af_read_raw(struct iio_dev *indio_dev,
436437
*val = FXLS8962AF_TEMP_CENTER_VAL;
437438
return IIO_VAL_INT;
438439
case IIO_CHAN_INFO_SCALE:
439-
*val = 0;
440-
return fxls8962af_read_full_scale(data, val2);
440+
switch (chan->type) {
441+
case IIO_TEMP:
442+
*val = MILLIDEGREE_PER_DEGREE;
443+
return IIO_VAL_INT;
444+
case IIO_ACCEL:
445+
*val = 0;
446+
return fxls8962af_read_full_scale(data, val2);
447+
default:
448+
return -EINVAL;
449+
}
441450
case IIO_CHAN_INFO_SAMP_FREQ:
442451
return fxls8962af_read_samp_freq(data, val, val2);
443452
default:
@@ -736,6 +745,7 @@ static const struct iio_event_spec fxls8962af_event[] = {
736745
.type = IIO_TEMP, \
737746
.address = FXLS8962AF_TEMP_OUT, \
738747
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
748+
BIT(IIO_CHAN_INFO_SCALE) | \
739749
BIT(IIO_CHAN_INFO_OFFSET),\
740750
.scan_index = -1, \
741751
.scan_type = { \

0 commit comments

Comments
 (0)