Skip to contentSkip to conversation

iio: imu: inv_mpu6050: Remove duplicate code between labels

PATCH Applied Gyeyoung Baek 5 participants 6 messages Sep 1, 2024 – Sep 3, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio: imu: inv_mpu6050: Remove duplicate code between labels

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

---
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(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +2 -5
index 3d3b27f28c9d..4753016d6ee0 100644
@@ -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);
 
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 5 lines · On Sun, 1 Sep 2024 21:08:39 +0900 Gyeyoung Baek <[email protected]> wrote:

'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.

Applied

Jonathan

Quoted 28 lines

---
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(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +2 -5
index 3d3b27f28c9d..4753016d6ee0 100644
@@ -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);
 
author
#2 lore raw
Quoted 8 lines · Jonathan Cameron
Quoted 4 lines · On Sun, 1 Sep 2024 21:08:39 +0900 Gyeyoung Baek <[email protected]> wrote:

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

Quoted 9 lines
Quoted 1 line

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

Applied

Jonathan

Thank you for approving it.

-Gyeyoung

#3 lore raw

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 <[email protected]>
Sent: Monday, September 2, 2024 03:53
To: Jonathan Cameron <[email protected]>
Cc: [email protected] <[email protected]>; Jean-Baptiste Maneyrol <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]> 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.

Quoted 8 lines · Jonathan Cameron
Quoted 4 lines · On Sun, 1 Sep 2024 21:08:39 +0900 Gyeyoung Baek <[email protected]> wrote:

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

Quoted 9 lines
Quoted 1 line

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

Applied

Jonathan

Thank you for approving it.

-Gyeyoung

#4 lore raw
In reply to Jonathan Cameron
Quoted 3 lines
Quoted 3 lines

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

…

Quoted 2 lines

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

How can you find such a change description acceptable?

Quoted 1 line

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

#5 lore raw
In reply to Gyeyoung Baek

Sun, Sep 01, 2024 at 09:08:39PM +0900, Gyeyoung Baek kirjoitti:

Quoted 3 lines

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

...

drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c irqreturn_t inv_mpu6050_read_fifo(int irq, void *p) · line 128

Quoted 5 lines
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +0 -5
-end_session:
-	mutex_unlock(&st->lock);
-	iio_trigger_notify_done(indio_dev->trig);
-
-	return IRQ_HANDLED;

You missed

	goto end_session;

here.

Quoted 7 lines

flush_fifo:

drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +2 -0
 	/* Flush HW and SW FIFOs. */
 	inv_reset_fifo(indio_dev);
+
+end_session:
 	mutex_unlock(&st->lock);
 	iio_trigger_notify_done(indio_dev->trig);
Signature · 2 lines
With Best Regards,
Andy Shevchenko