Skip to content

Commit 382fd03

Browse files
ViorelSumansashalevin
authored andcommitted
iio: inv_mpu6050: Clear timestamps fifo while resetting hardware fifo
[ Upstream commit 4dac0a8 ] A hardware fifo reset always imply an invalidation of the existing timestamps, so we'll clear timestamps fifo on successfull hardware fifo reset. Signed-off-by: Viorel Suman <viorel.suman@gmail.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent f37f8f4 commit 382fd03

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

‎drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
#include <linux/poll.h>
2525
#include "inv_mpu_iio.h"
2626

27+
static void inv_clear_kfifo(struct inv_mpu6050_state *st)
28+
{
29+
unsigned long flags;
30+
31+
/* take the spin lock sem to avoid interrupt kick in */
32+
spin_lock_irqsave(&st->time_stamp_lock, flags);
33+
kfifo_reset(&st->timestamps);
34+
spin_unlock_irqrestore(&st->time_stamp_lock, flags);
35+
}
36+
2737
int inv_reset_fifo(struct iio_dev *indio_dev)
2838
{
2939
int result;
@@ -50,6 +60,10 @@ int inv_reset_fifo(struct iio_dev *indio_dev)
5060
INV_MPU6050_BIT_FIFO_RST);
5161
if (result)
5262
goto reset_fifo_fail;
63+
64+
/* clear timestamps fifo */
65+
inv_clear_kfifo(st);
66+
5367
/* enable interrupt */
5468
if (st->chip_config.accl_fifo_enable ||
5569
st->chip_config.gyro_fifo_enable) {
@@ -83,16 +97,6 @@ int inv_reset_fifo(struct iio_dev *indio_dev)
8397
return result;
8498
}
8599

86-
static void inv_clear_kfifo(struct inv_mpu6050_state *st)
87-
{
88-
unsigned long flags;
89-
90-
/* take the spin lock sem to avoid interrupt kick in */
91-
spin_lock_irqsave(&st->time_stamp_lock, flags);
92-
kfifo_reset(&st->timestamps);
93-
spin_unlock_irqrestore(&st->time_stamp_lock, flags);
94-
}
95-
96100
/**
97101
* inv_mpu6050_irq_handler() - Cache a timestamp at each data ready interrupt.
98102
*/
@@ -184,7 +188,6 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
184188
flush_fifo:
185189
/* Flush HW and SW FIFOs. */
186190
inv_reset_fifo(indio_dev);
187-
inv_clear_kfifo(st);
188191
mutex_unlock(&indio_dev->mlock);
189192
iio_trigger_notify_done(indio_dev->trig);
190193

0 commit comments

Comments
 (0)