Skip to content

Commit 943cbf9

Browse files
jmaneyrol-invnjic23
authored andcommitted
iio: imu: inv_icm45600: fix temperature offset reporting
Correct temperature computation is (raw + offset) * scale and not apply scale and offset afterward. Fix temperature offset reporting to the correct value and update commentaries for the new computation. Fixes: 27e072b ("iio: imu: inv_icm45600: add IMU IIO gyroscope device") Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com> Cc: stable@vger.kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent ea6b4fe commit 943cbf9

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

drivers/iio/imu/inv_icm45600/inv_icm45600_core.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -960,16 +960,17 @@ int inv_icm45600_temp_read_raw(struct iio_dev *indio_dev,
960960
return IIO_VAL_INT;
961961
/*
962962
* T°C = (temp / 128) + 25
963-
* Tm°C = 1000 * ((temp * 100 / 12800) + 25)
964-
* scale: 100000 / 13248 = 7.8125
965-
* offset: 25000
963+
* Tm°C = ((temp + 25 * 128) / 128)) * 1000
964+
* Tm°C = (temp + 3200) * (1000 / 128)
965+
* scale: 1000 / 128 = 7.8125
966+
* offset: 3200
966967
*/
967968
case IIO_CHAN_INFO_SCALE:
968969
*val = 7;
969970
*val2 = 812500;
970971
return IIO_VAL_INT_PLUS_MICRO;
971972
case IIO_CHAN_INFO_OFFSET:
972-
*val = 25000;
973+
*val = 3200;
973974
return IIO_VAL_INT;
974975
default:
975976
return -EINVAL;

0 commit comments

Comments
 (0)