[PATCH 1/4] iio: imu: inv_icm42600: sleep before enabling FIFO data
From: Jean-Baptiste Maneyrol via B4 Relay
Date: Thu Aug 20 2026 - 15:10:35 EST
From: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@xxxxxxx>
When turning accel or gyro on, a sleep is required for letting the
mechanical part stabilize before reporting correct data. Do the sleep
before enabling FIFO data to prevent push of incorrect data. This is
required if the FIFO is already on because a sensor is already running.
Signed-off-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@xxxxxxx>
---
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 12 ++++++++----
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 12 ++++++++----
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
index 4b0e3cd8a506..d889c1dceec1 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c
@@ -254,15 +254,19 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,
fifo_en |= INV_ICM42600_SENSOR_ACCEL;
}
+ /* sleep maximum required time */
+ sleep = max(sleep_accel, sleep_temp);
+ if (sleep) {
+ mutex_unlock(&st->lock);
+ msleep(sleep);
+ mutex_lock(&st->lock);
+ }
+
/* update data FIFO write */
ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en);
out_unlock:
mutex_unlock(&st->lock);
- /* sleep maximum required time */
- sleep = max(sleep_accel, sleep_temp);
- if (sleep)
- msleep(sleep);
return ret;
}
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
index 253bf571439d..34037b9c1f82 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c
@@ -126,15 +126,19 @@ static int inv_icm42600_gyro_update_scan_mode(struct iio_dev *indio_dev,
fifo_en |= INV_ICM42600_SENSOR_GYRO;
}
+ /* sleep maximum required time */
+ sleep = max(sleep_gyro, sleep_temp);
+ if (sleep) {
+ mutex_unlock(&st->lock);
+ msleep(sleep);
+ mutex_lock(&st->lock);
+ }
+
/* update data FIFO write */
ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en);
out_unlock:
mutex_unlock(&st->lock);
- /* sleep maximum required time */
- sleep = max(sleep_gyro, sleep_temp);
- if (sleep)
- msleep(sleep);
return ret;
}
--
2.55.0