Skip to content

Commit 5756791

Browse files
sknseanopsiff
authored andcommitted
iio: accel: fxls8962af: Fix temperature calculation
commit 16038474e3a0263572f36326ef85057aaf341814 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: [email protected] Reviewed-by: Marcelo Schmitt <[email protected]> Signed-off-by: Sean Nyekjaer <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jonathan Cameron <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 39c86833f973d6b7d0fb5ae9ebd557e078a4cce5)
1 parent 6cf0bcc commit 5756791

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
@@ -20,6 +20,7 @@
2020
#include <linux/pm_runtime.h>
2121
#include <linux/regulator/consumer.h>
2222
#include <linux/regmap.h>
23+
#include <linux/units.h>
2324

2425
#include <linux/iio/buffer.h>
2526
#include <linux/iio/events.h>
@@ -434,8 +435,16 @@ static int fxls8962af_read_raw(struct iio_dev *indio_dev,
434435
*val = FXLS8962AF_TEMP_CENTER_VAL;
435436
return IIO_VAL_INT;
436437
case IIO_CHAN_INFO_SCALE:
437-
*val = 0;
438-
return fxls8962af_read_full_scale(data, val2);
438+
switch (chan->type) {
439+
case IIO_TEMP:
440+
*val = MILLIDEGREE_PER_DEGREE;
441+
return IIO_VAL_INT;
442+
case IIO_ACCEL:
443+
*val = 0;
444+
return fxls8962af_read_full_scale(data, val2);
445+
default:
446+
return -EINVAL;
447+
}
439448
case IIO_CHAN_INFO_SAMP_FREQ:
440449
return fxls8962af_read_samp_freq(data, val, val2);
441450
default:
@@ -734,6 +743,7 @@ static const struct iio_event_spec fxls8962af_event[] = {
734743
.type = IIO_TEMP, \
735744
.address = FXLS8962AF_TEMP_OUT, \
736745
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
746+
BIT(IIO_CHAN_INFO_SCALE) | \
737747
BIT(IIO_CHAN_INFO_OFFSET),\
738748
.scan_index = -1, \
739749
.scan_type = { \

0 commit comments

Comments
 (0)