Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: libps2 - rework handling of command response

It is not entirely correct that libps2 sets PS2_FLAG_CMD1 after
the device acknowledges each byte sent to the device by the host.
Rework the code so that PS2_FLAG_CMD1 and PS2_FLAG_CMD are set only once,
at the beginning of PS/2 command execution.

Reviewed-by: Raul E Rangel <rrangel@chromium.org>
Link: https://lore.kernel.org/r/20230511185252.386941-4-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+10 -8
+10 -8
drivers/input/serio/libps2.c
··· 247 247 248 248 serio_pause_rx(ps2dev->serio); 249 249 250 + /* Some mice do not ACK the "get ID" command, prepare to handle this. */ 250 251 ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0; 251 252 ps2dev->cmdcnt = receive; 252 - if (receive && param) 253 - for (i = 0; i < receive; i++) 254 - ps2dev->cmdbuf[(receive - 1) - i] = param[i]; 253 + if (receive) { 254 + /* Indicate that we expect response to the command. */ 255 + ps2dev->flags |= PS2_FLAG_CMD | PS2_FLAG_CMD1; 256 + if (param) 257 + for (i = 0; i < receive; i++) 258 + ps2dev->cmdbuf[(receive - 1) - i] = param[i]; 259 + } 255 260 256 261 /* 257 - * Some devices (Synaptics) peform the reset before 262 + * Some devices (Synaptics) perform the reset before 258 263 * ACKing the reset command, and so it can take a long 259 264 * time before the ACK arrives. 260 265 */ ··· 439 434 return true; 440 435 } 441 436 442 - if (!ps2dev->nak) { 437 + if (!ps2dev->nak) 443 438 ps2dev->flags &= ~PS2_FLAG_NAK; 444 - if (ps2dev->cmdcnt) 445 - ps2dev->flags |= PS2_FLAG_CMD | PS2_FLAG_CMD1; 446 - } 447 439 448 440 ps2dev->flags &= ~PS2_FLAG_ACK; 449 441 wake_up(&ps2dev->wait);