iio: imu: inv_icm42600: Fix temperature calculation
commit e2f820014239df9360064079ae93f838ff3b7f8c 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: bc3eb0207f
("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
fe68429041
commit
f6a5b84f45
@@ -67,16 +67,18 @@ int inv_icm42600_temp_read_raw(struct iio_dev *indio_dev,
|
|||||||
return IIO_VAL_INT;
|
return IIO_VAL_INT;
|
||||||
/*
|
/*
|
||||||
* T°C = (temp / 132.48) + 25
|
* T°C = (temp / 132.48) + 25
|
||||||
* Tm°C = 1000 * ((temp * 100 / 13248) + 25)
|
* Tm°C = 1000 * ((temp / 132.48) + 25)
|
||||||
|
* Tm°C = 7.548309 * temp + 25000
|
||||||
|
* Tm°C = (temp + 3312) * 7.548309
|
||||||
* scale: 100000 / 13248 ~= 7.548309
|
* scale: 100000 / 13248 ~= 7.548309
|
||||||
* offset: 25000
|
* offset: 3312
|
||||||
*/
|
*/
|
||||||
case IIO_CHAN_INFO_SCALE:
|
case IIO_CHAN_INFO_SCALE:
|
||||||
*val = 7;
|
*val = 7;
|
||||||
*val2 = 548309;
|
*val2 = 548309;
|
||||||
return IIO_VAL_INT_PLUS_MICRO;
|
return IIO_VAL_INT_PLUS_MICRO;
|
||||||
case IIO_CHAN_INFO_OFFSET:
|
case IIO_CHAN_INFO_OFFSET:
|
||||||
*val = 25000;
|
*val = 3312;
|
||||||
return IIO_VAL_INT;
|
return IIO_VAL_INT;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
Reference in New Issue
Block a user