]> www.infradead.org Git - linux.git/commitdiff
Input: cypress_ps2 - report timeouts when reading command status
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 28 Jun 2024 22:47:25 +0000 (15:47 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 3 Jul 2024 20:48:53 +0000 (13:48 -0700)
Report -ETIMEDOUT error code from cypress_ps2_read_cmd_status() when
device does not send enough data within the allotted time in response
to a command.

Link: https://lore.kernel.org/r/20240628224728.2180126-3-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/mouse/cypress_ps2.c

index fcc3921e49e0f2726e08e25a8d75f77395c405d4..8e17cd0bc437dffb72e4d230e3cd64ed5c86579f 100644 (file)
@@ -115,9 +115,12 @@ static int cypress_ps2_read_cmd_status(struct psmouse *psmouse,
        if (rc < 0)
                goto out;
 
-       wait_event_timeout(ps2dev->wait,
-                       (psmouse->pktcnt >= pktsize),
-                       msecs_to_jiffies(CYTP_CMD_TIMEOUT));
+       if (!wait_event_timeout(ps2dev->wait,
+                               psmouse->pktcnt >= pktsize,
+                               msecs_to_jiffies(CYTP_CMD_TIMEOUT))) {
+               rc = -ETIMEDOUT;
+               goto out;
+       }
 
        memcpy(param, psmouse->packet, pktsize);