[Concept,03/18] input: Correct handling of mouse clicks

Message ID 20251010034255.1099728-4-sjg@u-boot.org
State New
Headers
Series expo: Extend the boot menu |

Commit Message

Simon Glass Oct. 10, 2025, 3:42 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

It is possible that there is already a mouse click available, so
mouse_get_click() should check that first, before reading any further
events.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 90e109789e3 ("mouse: Move click detection into mouse_get_event()")
---

 drivers/input/mouse-uclass.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
  

Patch

diff --git a/drivers/input/mouse-uclass.c b/drivers/input/mouse-uclass.c
index 7cbe961af35..16a391532ae 100644
--- a/drivers/input/mouse-uclass.c
+++ b/drivers/input/mouse-uclass.c
@@ -57,15 +57,14 @@  int mouse_get_click(struct udevice *dev, struct vid_pos *pos)
 
 	/* Process all available events until we find a click */
 	while (true) {
-		if (mouse_get_event(dev, &event))
-			return -EAGAIN;  /* No more events */
-
-		/* Check if this event resulted in a click */
 		if (uc_priv->click_pending) {
 			*pos = uc_priv->click_pos;
 			uc_priv->click_pending = false;
 			break;
 		}
+
+		if (mouse_get_event(dev, &event))
+			return -EAGAIN;  /* No more events */
 	}
 
 	return 0;