[PATCH 1/2] iio: imu: inv_icm42600: return -EBUSY for temperature reads when idle

From: Joe LeVeque

Date: Thu Nov 19 2026 - 21:10:58 EST


The temperature sensor only measures while the accel or gyro is on.
With both off, its data register keeps the last measurement, so a
temperature read returns stale data. On an ICM-42688-P, a value held at
about 52 C was returned while the chip was at about 62 C. The data only
reads as invalid before the first measurement after power-up.

The temperature is the die temperature, used for accel and gyro
compensation, so return -EBUSY when both are off instead of stale data.

Suggested-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@xxxxxxx>
Signed-off-by: Joe LeVeque <joe.l@xxxxxxxxxxxxxxxxxx>
---
drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c
index 7f80bda471c3..b35706bb1c8f 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_temp.c
@@ -23,6 +23,16 @@ static int inv_icm42600_temp_read(struct inv_icm42600_state *st, s16 *temp)
pm_runtime_get_sync(dev);
mutex_lock(&st->lock);

+ /*
+ * The temperature sensor only measures while the accel or gyro is
+ * on; with both off, its data register holds a stale value.
+ */
+ if (st->conf.gyro.mode == INV_ICM42600_SENSOR_MODE_OFF &&
+ st->conf.accel.mode == INV_ICM42600_SENSOR_MODE_OFF) {
+ ret = -EBUSY;
+ goto exit;
+ }
+
ret = inv_icm42600_set_temp_conf(st, true, NULL);
if (ret)
goto exit;
--
2.34.1