diff options
Diffstat (limited to 'drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c')
-rw-r--r-- | drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c index 0cd306a72a6e..ba27e277511f 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | |||
@@ -24,6 +24,16 @@ | |||
24 | #include <linux/poll.h> | 24 | #include <linux/poll.h> |
25 | #include "inv_mpu_iio.h" | 25 | #include "inv_mpu_iio.h" |
26 | 26 | ||
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 | |||
27 | int inv_reset_fifo(struct iio_dev *indio_dev) | 37 | int inv_reset_fifo(struct iio_dev *indio_dev) |
28 | { | 38 | { |
29 | int result; | 39 | int result; |
@@ -50,6 +60,10 @@ int inv_reset_fifo(struct iio_dev *indio_dev) | |||
50 | INV_MPU6050_BIT_FIFO_RST); | 60 | INV_MPU6050_BIT_FIFO_RST); |
51 | if (result) | 61 | if (result) |
52 | goto reset_fifo_fail; | 62 | goto reset_fifo_fail; |
63 | |||
64 | /* clear timestamps fifo */ | ||
65 | inv_clear_kfifo(st); | ||
66 | |||
53 | /* enable interrupt */ | 67 | /* enable interrupt */ |
54 | if (st->chip_config.accl_fifo_enable || | 68 | if (st->chip_config.accl_fifo_enable || |
55 | st->chip_config.gyro_fifo_enable) { | 69 | st->chip_config.gyro_fifo_enable) { |
@@ -83,16 +97,6 @@ reset_fifo_fail: | |||
83 | return result; | 97 | return result; |
84 | } | 98 | } |
85 | 99 | ||
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 | |||
96 | /** | 100 | /** |
97 | * inv_mpu6050_irq_handler() - Cache a timestamp at each data ready interrupt. | 101 | * inv_mpu6050_irq_handler() - Cache a timestamp at each data ready interrupt. |
98 | */ | 102 | */ |
@@ -184,7 +188,6 @@ end_session: | |||
184 | flush_fifo: | 188 | flush_fifo: |
185 | /* Flush HW and SW FIFOs. */ | 189 | /* Flush HW and SW FIFOs. */ |
186 | inv_reset_fifo(indio_dev); | 190 | inv_reset_fifo(indio_dev); |
187 | inv_clear_kfifo(st); | ||
188 | mutex_unlock(&indio_dev->mlock); | 191 | mutex_unlock(&indio_dev->mlock); |
189 | iio_trigger_notify_done(indio_dev->trig); | 192 | iio_trigger_notify_done(indio_dev->trig); |
190 | 193 | ||