Skip to contentSkip to conversation

iio: imu: inv_icm42600: fix odr change not caught in certain cases

PATCH Applied Jean-Baptiste Maneyrol 2 participants 2 messages Sep 3 – Sep 6

Subsystems (3)
lore
Share & tools
lore

Jean-Baptiste Maneyrol

author maintainer
#0 lore raw

PATCH 1/1 iio: imu: inv_icm42600: fix odr change not caught in certain cases

When using both accel and gyro with different frequencies, the ODR change flag in the FIFO header can be sometime in a packet with invalid data. Since we are ignoring these packets, we miss the ODR change and any further change are blocked until sensor is turned off.

Fix this by moving the packet data validity check after the ODR change flag check.

Fixes ec74ae9fd37c ("iio: imu: inv_icm42600: add accurate timestamping")
---
 drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 8 ++++----
 drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c  | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +4 -4
index 3197081a808a..65d29de8ecf9 100644
@@ -1235,15 +1235,15 @@ int inv_icm42600_accel_parse_fifo(struct iio_dev *indio_dev)
 		if (size <= 0)
 			return size;
 
-		/* skip packet if no accel data or data is invalid */
-		if (accel == NULL || !inv_icm42600_fifo_is_data_valid(accel))
-			continue;
-
 		/* update odr */
 		if (odr & INV_ICM42600_SENSOR_ACCEL)
 			inv_sensors_timestamp_apply_odr(ts, st->fifo.period,
 							st->fifo.nb.total, no);
 
+		/* skip packet if no accel data or data is invalid */
+		if (accel == NULL || !inv_icm42600_fifo_is_data_valid(accel))
+			continue;
+
 		memcpy(&buffer.accel, accel, sizeof(buffer.accel));
 		/* convert 8 bits FIFO temperature in high resolution format */
 		buffer.temp = temp ? (*temp * 64) : 0;
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +4 -4
index 9de5c383665f..4e20d61d897b 100644
@@ -816,15 +816,15 @@ int inv_icm42600_gyro_parse_fifo(struct iio_dev *indio_dev)
 		if (size <= 0)
 			return size;
 
-		/* skip packet if no gyro data or data is invalid */
-		if (gyro == NULL || !inv_icm42600_fifo_is_data_valid(gyro))
-			continue;
-
 		/* update odr */
 		if (odr & INV_ICM42600_SENSOR_GYRO)
 			inv_sensors_timestamp_apply_odr(ts, st->fifo.period,
 							st->fifo.nb.total, no);
 
+		/* skip packet if no gyro data or data is invalid */
+		if (gyro == NULL || !inv_icm42600_fifo_is_data_valid(gyro))
+			continue;
+
 		memcpy(&buffer.gyro, gyro, sizeof(buffer.gyro));
 		/* convert 8 bits FIFO temperature in high resolution format */
 		buffer.temp = temp ? (*temp * 64) : 0;

---
base-commit: 183f05a300eab41e4578337eac59335730dfebf9
change-id: 20260903-iio-imu-inv-icm42600-fix-odr-change-never-caught-bd624725ade7

Best regards,

Signature · 1 line
Jean-Baptiste Maneyrol <[email protected]>
maintainer Applied
#1 lore raw
Quoted 7 lines · On Thu, 03 Sep 2026 21:37:13 +0200 Jean-Baptiste Maneyrol via B4 Relay…

From: Jean-Baptiste Maneyrol <[email protected]>

When using both accel and gyro with different frequencies, the ODR change flag in the FIFO header can be sometime in a packet with invalid data. Since we are ignoring these packets, we miss the ODR change and any further change are blocked until sensor is turned off.

Quoted 6 lines

Fix this by moving the packet data validity check after the ODR change flag check.

Fixes ec74ae9fd37c ("iio: imu: inv_icm42600: add accurate timestamping")

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan