iio: inv_mpu6050: Clear timestamps fifo while resetting hardware fifo
Subsystems (2)
PATCH v2 1/1 iio: inv_mpu6050: Clear timestamps fifo while resetting hardware fifo
A hardware fifo reset always imply an invalidation of the existing timestamps, so we'll clear timestamps fifo on successfull hardware fifo reset.
---
v2: Addressed Jonathan's comment regarding the subject prefix.
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +14 -11
@@ -24,6 +24,16 @@#include <linux/poll.h> #include "inv_mpu_iio.h" +static void inv_clear_kfifo (struct inv_mpu6050_state *st) +{ +unsigned long flags; + +/* take the spin lock sem to avoid interrupt kick in */ +spin_lock_irqsave (&st->time_stamp_lock, flags); +kfifo_reset (&st->timestamps); +spin_unlock_irqrestore (&st->time_stamp_lock, flags); +} +int inv_reset_fifo (struct iio_dev *indio_dev) {int result;
@@ -50,6 +60,10 @@ int inv_reset_fifo(struct iio_dev *indio_dev) INV_MPU6050_BIT_FIFO_RST);if (result) goto reset_fifo_fail; + +/* clear timestamps fifo */ +inv_clear_kfifo (st); +/* enable interrupt */ if (st->chip_config.accl_fifo_enable || st->chip_config.gyro_fifo_enable) {
@@ -83,16 +97,6 @@ reset_fifo_fail:return result; } -static void inv_clear_kfifo (struct inv_mpu6050_state *st) -{ -unsigned long flags; - -/* take the spin lock sem to avoid interrupt kick in */ -spin_lock_irqsave (&st->time_stamp_lock, flags); -kfifo_reset (&st->timestamps); -spin_unlock_irqrestore (&st->time_stamp_lock, flags); -} -/** * inv_mpu6050_irq_handler() - Cache a timestamp at each data ready interrupt. */
@@ -184,7 +188,6 @@ end_session: flush_fifo:/* Flush HW and SW FIFOs. */ inv_reset_fifo (indio_dev); -inv_clear_kfifo (st);mutex_unlock (&indio_dev->mlock);iio_trigger_notify_done (indio_dev->trig);
Signature · 1 line
2.3.0
Jonathan Cameron
maintainerQuoted 5 lines · Viorel Suman
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 <[email protected]>
Looks sensible to me. Ge / Srinivas?
Quoted 64 lines
---
v2: Addressed Jonathan's comment regarding the subject prefix.drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +14
-11@@ -24,6 +24,16 @@#include <linux/poll.h> #include "inv_mpu_iio.h" +static void inv_clear_kfifo (struct inv_mpu6050_state *st) +{ +unsigned long flags; + +/* take the spin lock sem to avoid interrupt kick in */ +spin_lock_irqsave (&st->time_stamp_lock, flags); +kfifo_reset (&st->timestamps); +spin_unlock_irqrestore (&st->time_stamp_lock, flags); +} +int inv_reset_fifo (struct iio_dev *indio_dev) {int result;@@ -50,6 +60,10 @@ int inv_reset_fifo(struct iio_dev *indio_dev) INV_MPU6050_BIT_FIFO_RST);if (result) goto reset_fifo_fail; + +/* clear timestamps fifo */ +inv_clear_kfifo (st); +/* enable interrupt */ if (st->chip_config.accl_fifo_enable || st->chip_config.gyro_fifo_enable) {@@ -83,16 +97,6 @@ reset_fifo_fail:return result; } -static void inv_clear_kfifo (struct inv_mpu6050_state *st) -{ -unsigned long flags; - -/* take the spin lock sem to avoid interrupt kick in */ -spin_lock_irqsave (&st->time_stamp_lock, flags); -kfifo_reset (&st->timestamps); -spin_unlock_irqrestore (&st->time_stamp_lock, flags); -} -/** * inv_mpu6050_irq_handler() - Cache a timestamp at each data ready interrupt. */ @@ -184,7 +188,6 @@ end_session: flush_fifo:/* Flush HW and SW FIFOs. */ inv_reset_fifo (indio_dev); -inv_clear_kfifo (st);mutex_unlock (&indio_dev->mlock);iio_trigger_notify_done (indio_dev->trig);
Look fine to me.
Thanks.
Best Regards,
Ge GAO
-----Original Message-----
From: Jonathan Cameron [mailto:[email protected]]=20
Sent: Saturday, February 21, 2015 11:01 AM
To: Viorel Suman; [email protected]
Cc: [email protected]; Srinivas Pandruvada; Ge Gao
Subject: Re: [PATCH v2] iio: inv_mpu6050: Clear timestamps fifo while reset= ting hardware fifo
Quoted 5 lines · Viorel Suman
A hardware fifo reset always imply an invalidation of the existing=20 timestamps, so we'll clear timestamps fifo on successfull hardware=20 fifo reset.
=20Signed-off-by Viorel Suman <[email protected]>
Looks sensible to me. Ge / Srinivas?
Quoted 42 lines
---
v2: Addressed Jonathan's comment regarding the subject prefix.
=20
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c| 25=20
++++++++++++++-----------1 file changed, 14 insertions(+), 11 deletions(-)=20
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +0
-0@@ -24,6 +24,16 @@#include <linux/poll.h> #include "inv_mpu_iio.h" =20
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +12
-0+static void inv_clear_kfifo (struct inv_mpu6050_state *st) { +unsigned long flags; + +/* take the spin lock sem to avoid interrupt kick in */ +spin_lock_irqsave (&st->time_stamp_lock, flags); +kfifo_reset (&st->timestamps); +spin_unlock_irqrestore (&st->time_stamp_lock, flags); } +int inv_reset_fifo (struct iio_dev *indio_dev) {int result;@@ -50,6 +60,10 @@ int inv_reset_fifo(struct iio_dev *indio_dev) INV_MPU6050_BIT_FIFO_RST);if (result) goto reset_fifo_fail; + +/* clear timestamps fifo */ +inv_clear_kfifo (st); +/* enable interrupt */ if (st->chip_config.accl_fifo_enable || st->chip_config.gyro_fifo_enable) { @@ -83,16 +97,6 @@=20
reset_fifo_fail:
return result;
}
=20drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +0
-1-static void inv_clear_kfifo(struct inv_mpu6050_state *st) -{
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c reset_fifo_fail:
Quoted 10 lines
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +0
-8-unsigned long flags; - -/* take the spin lock sem to avoid interrupt kick in */ -spin_lock_irqsave (&st->time_stamp_lock, flags); -kfifo_reset (&st->timestamps); -spin_unlock_irqrestore (&st->time_stamp_lock, flags); -} -/** * inv_mpu6050_irq_handler() - Cache a timestamp at each data ready inte=
rrupt.
Quoted 10 lines
*/
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +0
-1@@ -184,7 +188,6 @@ end_session: flush_fifo:/* Flush HW and SW FIFOs. */ inv_reset_fifo (indio_dev); -inv_clear_kfifo (st);mutex_unlock (&indio_dev->mlock);iio_trigger_notify_done (indio_dev->trig);=20
=20
Jonathan Cameron
maintainerQuoted 7 lines · Ge Gao
Look fine to me.
Thanks.Best Regards,
Ge GAO
Formal Acks preferred ;)
Anyhow, applied to the fixes-togreg branch of iio.git.
Thanks,
Jonathan
Quoted 78 lines
-----Original Message-----
From: Jonathan Cameron [mailto:[email protected]]
Sent: Saturday, February 21, 2015 11:01 AM
To: Viorel Suman; [email protected]
Cc: [email protected]; Srinivas Pandruvada; Ge Gao
Subject: Re: [PATCH v2] iio:inv_mpu6050: Clear timestamps fifo while resetting hardware fifoQuoted 5 lines · Viorel Suman
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 <[email protected]>Looks sensible to me. Ge / Srinivas?
Quoted 62 lines
---
v2: Addressed Jonathan's comment regarding the subject prefix.drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +12
-0@@ -24,6 +24,16 @@#include <linux/poll.h> #include "inv_mpu_iio.h" +static void inv_clear_kfifo (struct inv_mpu6050_state *st) { +unsigned long flags; + +/* take the spin lock sem to avoid interrupt kick in */ +spin_lock_irqsave (&st->time_stamp_lock, flags); +kfifo_reset (&st->timestamps); +spin_unlock_irqrestore (&st->time_stamp_lock, flags); } +int inv_reset_fifo (struct iio_dev *indio_dev) {int result;@@ -50,6 +60,10 @@ int inv_reset_fifo(struct iio_dev *indio_dev) INV_MPU6050_BIT_FIFO_RST);if (result) goto reset_fifo_fail; + +/* clear timestamps fifo */ +inv_clear_kfifo (st); +/* enable interrupt */ if (st->chip_config.accl_fifo_enable || st->chip_config.gyro_fifo_enable) { @@ -83,16 +97,6 @@
reset_fifo_fail:drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +0
-10return result; } -static void inv_clear_kfifo(struct inv_mpu6050_state *st) -{ -unsigned long flags; - -/* take the spin lock sem to avoid interrupt kick in */ -spin_lock_irqsave (&st->time_stamp_lock, flags); -kfifo_reset (&st->timestamps); -spin_unlock_irqrestore (&st->time_stamp_lock, flags); -} -/** * inv_mpu6050_irq_handler() - Cache a timestamp at each data ready interrupt. */ @@ -184,7 +188,6 @@ end_session: flush_fifo:/* Flush HW and SW FIFOs. */ inv_reset_fifo (indio_dev); -inv_clear_kfifo (st);mutex_unlock (&indio_dev->mlock);iio_trigger_notify_done (indio_dev->trig);
Jonathan Cameron
maintainerQuoted 11 lines · Jonathan Cameron
Quoted 7 lines · Ge Gao
Look fine to me.
Thanks.Best Regards,
Ge GAO
Formal Acks preferred ;)
Anyhow, applied to the fixes-togreg branch of iio.git.
Forgot to say - marked for stable as well.
Quoted 88 lines
Thanks,
Jonathan
Quoted 69 lines
-----Original Message-----
From: Jonathan Cameron [mailto:[email protected]]
Sent: Saturday, February 21, 2015 11:01 AM
To: Viorel Suman; [email protected]
Cc: [email protected]; Srinivas Pandruvada; Ge Gao
Subject: Re: [PATCH v2] iio:inv_mpu6050: Clear timestamps fifo while resetting hardware fifoQuoted 5 lines · Viorel Suman
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 <[email protected]>Looks sensible to me. Ge / Srinivas?
Quoted 54 lines
---
v2: Addressed Jonathan's comment regarding the subject prefix.drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +12
-0@@ -24,6 +24,16 @@#include <linux/poll.h> #include "inv_mpu_iio.h" +static void inv_clear_kfifo (struct inv_mpu6050_state *st) { +unsigned long flags; + +/* take the spin lock sem to avoid interrupt kick in */ +spin_lock_irqsave (&st->time_stamp_lock, flags); +kfifo_reset (&st->timestamps); +spin_unlock_irqrestore (&st->time_stamp_lock, flags); } +int inv_reset_fifo (struct iio_dev *indio_dev) {int result;@@ -50,6 +60,10 @@ int inv_reset_fifo(struct iio_dev *indio_dev) INV_MPU6050_BIT_FIFO_RST);if (result) goto reset_fifo_fail; + +/* clear timestamps fifo */ +inv_clear_kfifo (st); +/* enable interrupt */ if (st->chip_config.accl_fifo_enable || st->chip_config.gyro_fifo_enable) { @@ -83,16 +97,6 @@
reset_fifo_fail:drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +0
-9return result; } -static void inv_clear_kfifo(struct inv_mpu6050_state *st) -{ -unsigned long flags; - -/* take the spin lock sem to avoid interrupt kick in */ -spin_lock_irqsave (&st->time_stamp_lock, flags); -kfifo_reset (&st->timestamps); -spin_unlock_irqrestore (&st->time_stamp_lock, flags); -} -/** * inv_mpu6050_irq_handler() - Cache a timestamp at each data ready interrupt. */ @@ -184,7 +188,6 @@ end_session:Quoted 9 lines
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c end_session: · line 193
Quoted 8 lines
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +0
-1flush_fifo:/* Flush HW and SW FIFOs. */ inv_reset_fifo (indio_dev); -inv_clear_kfifo (st);mutex_unlock (&indio_dev->mlock);iio_trigger_notify_done (indio_dev->trig);--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html