Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] Input: joydev - replace ev_match boolean with goto for early exit
@ 2026-07-09  4:18 Ashton Warner
  2026-07-11 22:47 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Ashton Warner @ 2026-07-09  4:18 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, linux-kernel

The joydev_dev_is_absolute_mouse runs unnecessary Event type checks to
determine whether a joydev device is an absolute mouse. Change ev_match
to a goto statement to exit early.

Signed-off-by: Ashton Warner <drflamemontgomery@gmail.com>
---
 drivers/input/joydev.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 32459fd8a7c1..a726ba0be05b 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -819,7 +819,6 @@ static bool joydev_dev_is_blacklisted(struct input_dev *dev)
 static bool joydev_dev_is_absolute_mouse(struct input_dev *dev)
 {
 	DECLARE_BITMAP(jd_scratch, KEY_CNT);
-	bool ev_match = false;
 
 	BUILD_BUG_ON(ABS_CNT > KEY_CNT || EV_CNT > KEY_CNT);
 
@@ -855,20 +854,21 @@ static bool joydev_dev_is_absolute_mouse(struct input_dev *dev)
 	__set_bit(EV_KEY, jd_scratch);
 	__set_bit(EV_SYN, jd_scratch);
 	if (bitmap_equal(jd_scratch, dev->evbit, EV_CNT))
-		ev_match = true;
+		goto ev_match_pass;
 
 	/* HP ILO2, AMI BMC firmware */
 	__set_bit(EV_MSC, jd_scratch);
 	if (bitmap_equal(jd_scratch, dev->evbit, EV_CNT))
-		ev_match = true;
+		goto ev_match_pass;
 
 	/* VMware Virtual USB Mouse, QEMU USB Tablet, ATEN BMC firmware */
 	__set_bit(EV_REL, jd_scratch);
 	if (bitmap_equal(jd_scratch, dev->evbit, EV_CNT))
-		ev_match = true;
+		goto ev_match_pass;
 
-	if (!ev_match)
-		return false;
+	return false;
+
+ev_match_pass:
 
 	bitmap_zero(jd_scratch, ABS_CNT);
 	__set_bit(ABS_X, jd_scratch);
-- 
2.55.0


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

* Re: [PATCH] Input: joydev - replace ev_match boolean with goto for early exit
  2026-07-09  4:18 [PATCH] Input: joydev - replace ev_match boolean with goto for early exit Ashton Warner
@ 2026-07-11 22:47 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-07-11 22:47 UTC (permalink / raw)
  To: linux-input, linux-kernel

Hi Ashton,

On Thu, Jul 09, 2026 at 04:18:49PM +1200, Ashton Warner wrote:
> The joydev_dev_is_absolute_mouse runs unnecessary Event type checks to
> determine whether a joydev device is an absolute mouse. Change ev_match
> to a goto statement to exit early.
> 
> Signed-off-by: Ashton Warner <drflamemontgomery@gmail.com>

I think this is one of the cases where I'd avoid using goto. The extra
computation is not in hot path and will be unnoticeable. 

Thanks.

-- 
Dmitry

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

end of thread, other threads:[~2026-07-11 22:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-09  4:18 [PATCH] Input: joydev - replace ev_match boolean with goto for early exit Ashton Warner
2026-07-11 22:47 ` Dmitry Torokhov

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