public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] iio: imu: inv_mpu6050: Remove duplicate code between labels
@ 2024-09-01 12:08 Gyeyoung Baek
  2024-09-01 14:11 ` Jonathan Cameron
  2024-09-03 23:28 ` Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Gyeyoung Baek @ 2024-09-01 12:08 UTC (permalink / raw)
  To: jic23; +Cc: lars, jean-baptiste.maneyrol, linux-iio, linux-kernel,
	Gyeyoung Baek

'flush_fifo' label performs same task as 'endsession' label
immediately after calling 'env_reset_fifo' function.
So i remove that duplication.

Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
---
I worked on the wrong branch in v1, and reworked on the latest branch.

 drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
index 3d3b27f28c9d..4753016d6ee0 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
@@ -121,15 +121,12 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
 		iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp);
 	}
 
-end_session:
-	mutex_unlock(&st->lock);
-	iio_trigger_notify_done(indio_dev->trig);
-
-	return IRQ_HANDLED;
 
 flush_fifo:
 	/* Flush HW and SW FIFOs. */
 	inv_reset_fifo(indio_dev);
+
+end_session:
 	mutex_unlock(&st->lock);
 	iio_trigger_notify_done(indio_dev->trig);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] iio: imu: inv_mpu6050: Remove duplicate code between labels
  2024-09-01 12:08 [PATCH v2] iio: imu: inv_mpu6050: Remove duplicate code between labels Gyeyoung Baek
@ 2024-09-01 14:11 ` Jonathan Cameron
  2024-09-02  1:53   ` gyeyoung
  2024-09-02 13:35   ` Markus Elfring
  2024-09-03 23:28 ` Andy Shevchenko
  1 sibling, 2 replies; 6+ messages in thread
From: Jonathan Cameron @ 2024-09-01 14:11 UTC (permalink / raw)
  To: Gyeyoung Baek; +Cc: lars, jean-baptiste.maneyrol, linux-iio, linux-kernel

On Sun,  1 Sep 2024 21:08:39 +0900
Gyeyoung Baek <gye976@gmail.com> wrote:

> 'flush_fifo' label performs same task as 'endsession' label
> immediately after calling 'env_reset_fifo' function.
> So i remove that duplication.
> 
> Signed-off-by: Gyeyoung Baek <gye976@gmail.com>

Ok. This doesn't greatly affect readability and the code
ends up a bit shorter.

Applied

Jonathan

> ---
> I worked on the wrong branch in v1, and reworked on the latest branch.
> 
>  drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> index 3d3b27f28c9d..4753016d6ee0 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
> @@ -121,15 +121,12 @@ irqreturn_t inv_mpu6050_read_fifo(int irq, void *p)
>  		iio_push_to_buffers_with_timestamp(indio_dev, data, timestamp);
>  	}
>  
> -end_session:
> -	mutex_unlock(&st->lock);
> -	iio_trigger_notify_done(indio_dev->trig);
> -
> -	return IRQ_HANDLED;
>  
>  flush_fifo:
>  	/* Flush HW and SW FIFOs. */
>  	inv_reset_fifo(indio_dev);
> +
> +end_session:
>  	mutex_unlock(&st->lock);
>  	iio_trigger_notify_done(indio_dev->trig);
>  


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] iio: imu: inv_mpu6050: Remove duplicate code between labels
  2024-09-01 14:11 ` Jonathan Cameron
@ 2024-09-02  1:53   ` gyeyoung
  2024-09-02  9:51     ` Jean-Baptiste Maneyrol
  2024-09-02 13:35   ` Markus Elfring
  1 sibling, 1 reply; 6+ messages in thread
From: gyeyoung @ 2024-09-02  1:53 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: lars, jean-baptiste.maneyrol, linux-iio, linux-kernel

On Sun, Sep 1, 2024 at 11:11 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Sun,  1 Sep 2024 21:08:39 +0900
> Gyeyoung Baek <gye976@gmail.com> wrote:
>
> > 'flush_fifo' label performs same task as 'endsession' label
> > immediately after calling 'env_reset_fifo' function.
> > So i remove that duplication.
> >
> > Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
>
> Ok. This doesn't greatly affect readability and the code
> ends up a bit shorter.
>
> Applied
>
> Jonathan
>

Thank you for approving it.

-Gyeyoung

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] iio: imu: inv_mpu6050: Remove duplicate code between labels
  2024-09-02  1:53   ` gyeyoung
@ 2024-09-02  9:51     ` Jean-Baptiste Maneyrol
  0 siblings, 0 replies; 6+ messages in thread
From: Jean-Baptiste Maneyrol @ 2024-09-02  9:51 UTC (permalink / raw)
  To: gyeyoung, Jonathan Cameron
  Cc: lars@metafoo.de, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org

Hello,

thanks for the patch, but beware that this modification is breaking the code!

You are deleting the normal function path return IRQ_HANDLED (without the goto end_session). With this patch, the reset fifo function code inv_reset_fifo() will be called even if the IRQ handler is functioning correctly.

This is a no go for me, I don't think we can easily change these 2 labels anyway.

Best regards,
JB

________________________________________
From: gyeyoung <gye976@gmail.com>
Sent: Monday, September 2, 2024 03:53
To: Jonathan Cameron <jic23@kernel.org>
Cc: lars@metafoo.de <lars@metafoo.de>; Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] iio: imu: inv_mpu6050: Remove duplicate code between labels
 
This Message Is From an Untrusted Sender
You have not previously corresponded with this sender.
 
On Sun, Sep 1, 2024 at 11:11 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Sun,  1 Sep 2024 21:08:39 +0900
> Gyeyoung Baek <gye976@gmail.com> wrote:
>
> > 'flush_fifo' label performs same task as 'endsession' label
> > immediately after calling 'env_reset_fifo' function.
> > So i remove that duplication.
> >
> > Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
>
> Ok. This doesn't greatly affect readability and the code
> ends up a bit shorter.
>
> Applied
>
> Jonathan
>

Thank you for approving it.

-Gyeyoung

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] iio: imu: inv_mpu6050: Remove duplicate code between labels
  2024-09-01 14:11 ` Jonathan Cameron
  2024-09-02  1:53   ` gyeyoung
@ 2024-09-02 13:35   ` Markus Elfring
  1 sibling, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2024-09-02 13:35 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, linux-iio
  Cc: LKML, Gyeyoung Baek, Jean-Baptiste Maneyrol

> > 'flush_fifo' label performs same task as 'endsession' label
> > immediately after calling 'env_reset_fifo' function.
> > So i remove that duplication.
> Ok. This doesn't greatly affect readability and the code
> ends up a bit shorter.

How can you find such a change description acceptable?


> Applied

Please reconsider this positive feedback once more.

It temporarily looked too promising to apply a goto chain.
But the original control flow needs other development considerations
if you would like to reduce the explicit repetition of common actions.

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] iio: imu: inv_mpu6050: Remove duplicate code between labels
  2024-09-01 12:08 [PATCH v2] iio: imu: inv_mpu6050: Remove duplicate code between labels Gyeyoung Baek
  2024-09-01 14:11 ` Jonathan Cameron
@ 2024-09-03 23:28 ` Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-09-03 23:28 UTC (permalink / raw)
  To: Gyeyoung Baek
  Cc: jic23, lars, jean-baptiste.maneyrol, linux-iio, linux-kernel

Sun, Sep 01, 2024 at 09:08:39PM +0900, Gyeyoung Baek kirjoitti:
> 'flush_fifo' label performs same task as 'endsession' label
> immediately after calling 'env_reset_fifo' function.
> So i remove that duplication.

...

> -end_session:
> -	mutex_unlock(&st->lock);
> -	iio_trigger_notify_done(indio_dev->trig);
> -
> -	return IRQ_HANDLED;

You missed

	goto end_session;

here.

>  flush_fifo:
>  	/* Flush HW and SW FIFOs. */
>  	inv_reset_fifo(indio_dev);
> +
> +end_session:
>  	mutex_unlock(&st->lock);
>  	iio_trigger_notify_done(indio_dev->trig);

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-03 23:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-01 12:08 [PATCH v2] iio: imu: inv_mpu6050: Remove duplicate code between labels Gyeyoung Baek
2024-09-01 14:11 ` Jonathan Cameron
2024-09-02  1:53   ` gyeyoung
2024-09-02  9:51     ` Jean-Baptiste Maneyrol
2024-09-02 13:35   ` Markus Elfring
2024-09-03 23:28 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox