iio: imu: inv_mpu6050: fix FIFO parsing when empty
Subsystems (3)
PATCH v2 1/1 iio: imu: inv_mpu6050: fix FIFO parsing when empty
From: Jean-Baptiste Maneyrol <[email protected]>
Now that we are reading the full FIFO in the interrupt handler, it is possible to have an emply FIFO since we are still receiving 1 interrupt per data. Handle correctly this case instead of having an error causing a reset of the FIFO.
---
V2: add missing stable tag
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +2 -0
@@ -109,6 +109,8 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)/* compute and process only all complete datum */ nb = fifo_count / bytes_per_datum; fifo_count = nb * bytes_per_datum; +if (nb ==0 ) + goto end_session;/* Each FIFO data contains all sensors, so same number for FIFO and sensor data */ fifo_period =NSEC_PER_SEC /INV_MPU6050_DIVIDER_TO_FIFO_RATE (st->chip_config.divider);inv_sensors_timestamp_interrupt (&st->timestamp, fifo_period, nb, nb, pf->timestamp);
--
2.34.1
Jonathan Cameron
maintainerQuoted 10 lines · On Mon, 19 Feb 2024 15:48:25 +0000 [email protected] wrote:
From: Jean-Baptiste Maneyrol <[email protected]>
Now that we are reading the full FIFO in the interrupt handler, it is possible to have an emply FIFO since we are still receiving 1 interrupt per data. Handle correctly this case instead of having an error causing a reset of the FIFO.
Fixes 0829edc43e0a ("iio: imu: inv_mpu6050: read the full fifo when processing data")Signed-off-by Jean-Baptiste Maneyrol <[email protected]>
Would have been nice to call out that the error comes from a zero length read (I think!).
Anyhow, applied to the fixes-togreg branch of iio.git.
I might pull this into my queue for the next merge window as we are getting close to the end of the cycle.
Jonathan
Quoted 22 lines
---
V2: add missing stable tagdrivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 2 ++ 1 file changed, 2 insertions(+)drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +2
-1@@ -109,6 +109,8 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)/* compute and process only all complete datum */ nb = fifo_count / bytes_per_datum; fifo_count = nb * bytes_per_datum; +if (nb ==0 ) + goto end_session;/* Each FIFO data contains all sensors, so same number for FIFO and sensor data */ fifo_period =NSEC_PER_SEC /INV_MPU6050_DIVIDER_TO_FIFO_RATE (st->chip_config.divider);inv_sensors_timestamp_interrupt (&st->timestamp, fifo_period, nb, nb, pf->timestamp); --2.34.1