* [PATCH] iio: imu: inv_icm45600: fix temperature offset reporting
@ 2025-12-18 10:30 Jean-Baptiste Maneyrol via B4 Relay
2025-12-21 18:41 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Jean-Baptiste Maneyrol via B4 Relay @ 2025-12-18 10:30 UTC (permalink / raw)
To: Remi Buisson, Jonathan Cameron, David Lechner, Nuno Sá,
Andy Shevchenko
Cc: Jonathan Cameron, linux-iio, linux-kernel, Jean-Baptiste Maneyrol,
stable
From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
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: 27e072bc34d1 ("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
---
drivers/iio/imu/inv_icm45600/inv_icm45600_core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c b/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
index ab1cb7b9dba435a3280e50ab77cd16e903c7816c..25bd9757a594d0180d7f53b49f959a49a50c64a9 100644
--- a/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
+++ b/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
@@ -960,16 +960,17 @@ int inv_icm45600_temp_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT;
/*
* T°C = (temp / 128) + 25
- * Tm°C = 1000 * ((temp * 100 / 12800) + 25)
- * scale: 100000 / 13248 = 7.8125
- * offset: 25000
+ * Tm°C = ((temp + 25 * 128) / 128)) * 1000
+ * Tm°C = (temp + 3200) * (1000 / 128)
+ * scale: 1000 / 128 = 7.8125
+ * offset: 3200
*/
case IIO_CHAN_INFO_SCALE:
*val = 7;
*val2 = 812500;
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_OFFSET:
- *val = 25000;
+ *val = 3200;
return IIO_VAL_INT;
default:
return -EINVAL;
---
base-commit: a7b10f0963c651a6406d958a5f64b9c5594f84da
change-id: 20251218-inv-icm45600-fix-temperature-offset-reporting-190a09adfdad
Best regards,
--
Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] iio: imu: inv_icm45600: fix temperature offset reporting
2025-12-18 10:30 [PATCH] iio: imu: inv_icm45600: fix temperature offset reporting Jean-Baptiste Maneyrol via B4 Relay
@ 2025-12-21 18:41 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2025-12-21 18:41 UTC (permalink / raw)
To: Jean-Baptiste Maneyrol via B4 Relay
Cc: jean-baptiste.maneyrol, Remi Buisson, David Lechner, Nuno Sá,
Andy Shevchenko, Jonathan Cameron, linux-iio, linux-kernel,
stable
On Thu, 18 Dec 2025 11:30:59 +0100
Jean-Baptiste Maneyrol via B4 Relay <devnull+jean-baptiste.maneyrol.tdk.com@kernel.org> wrote:
> From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
>
> 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: 27e072bc34d1 ("iio: imu: inv_icm45600: add IMU IIO gyroscope device")
>
No blank line here. That breaks a bunch of scripts and is checked for
in upstream trees so with the line break this would be rejected.
> Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
> Cc: stable@vger.kernel.org
Applied to the fixes-togreg tree.
Thanks,
Jonathan
> ---
> drivers/iio/imu/inv_icm45600/inv_icm45600_core.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c b/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
> index ab1cb7b9dba435a3280e50ab77cd16e903c7816c..25bd9757a594d0180d7f53b49f959a49a50c64a9 100644
> --- a/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
> +++ b/drivers/iio/imu/inv_icm45600/inv_icm45600_core.c
> @@ -960,16 +960,17 @@ int inv_icm45600_temp_read_raw(struct iio_dev *indio_dev,
> return IIO_VAL_INT;
> /*
> * T°C = (temp / 128) + 25
> - * Tm°C = 1000 * ((temp * 100 / 12800) + 25)
> - * scale: 100000 / 13248 = 7.8125
> - * offset: 25000
> + * Tm°C = ((temp + 25 * 128) / 128)) * 1000
> + * Tm°C = (temp + 3200) * (1000 / 128)
> + * scale: 1000 / 128 = 7.8125
> + * offset: 3200
> */
> case IIO_CHAN_INFO_SCALE:
> *val = 7;
> *val2 = 812500;
> return IIO_VAL_INT_PLUS_MICRO;
> case IIO_CHAN_INFO_OFFSET:
> - *val = 25000;
> + *val = 3200;
> return IIO_VAL_INT;
> default:
> return -EINVAL;
>
> ---
> base-commit: a7b10f0963c651a6406d958a5f64b9c5594f84da
> change-id: 20251218-inv-icm45600-fix-temperature-offset-reporting-190a09adfdad
>
> Best regards,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-21 18:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18 10:30 [PATCH] iio: imu: inv_icm45600: fix temperature offset reporting Jean-Baptiste Maneyrol via B4 Relay
2025-12-21 18:41 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox