Skip to content

Commit ea66a9e

Browse files
sknseangregkh
authored andcommitted
iio: imu: inv_icm42600: Fix temperature calculation
commit e2f8200 upstream. >From the documentation: "offset to be added to <type>[Y]_raw prior toscaling by <type>[Y]_scale" Offset should be applied before multiplying scale, so divide offset by scale to make this correct. Fixes: bc3eb02 ("iio: imu: inv_icm42600: add temperature sensor support") Signed-off-by: Sean Nyekjaer <sean@geanix.com> Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Link: https://patch.msgid.link/20250502-imu-v1-1-129b8391a4e3@geanix.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 034a52b commit ea66a9e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,18 @@ int inv_icm42600_temp_read_raw(struct iio_dev *indio_dev,
6767
return IIO_VAL_INT;
6868
/*
6969
* T°C = (temp / 132.48) + 25
70-
* Tm°C = 1000 * ((temp * 100 / 13248) + 25)
70+
* Tm°C = 1000 * ((temp / 132.48) + 25)
71+
* Tm°C = 7.548309 * temp + 25000
72+
* Tm°C = (temp + 3312) * 7.548309
7173
* scale: 100000 / 13248 ~= 7.548309
72-
* offset: 25000
74+
* offset: 3312
7375
*/
7476
case IIO_CHAN_INFO_SCALE:
7577
*val = 7;
7678
*val2 = 548309;
7779
return IIO_VAL_INT_PLUS_MICRO;
7880
case IIO_CHAN_INFO_OFFSET:
79-
*val = 25000;
81+
*val = 3312;
8082
return IIO_VAL_INT;
8183
default:
8284
return -EINVAL;

0 commit comments

Comments
 (0)