Skip to content

Commit fc522f3

Browse files
committed
Input: libps2 - remove special handling of ACK for command byte
When getting unexpected data while waiting for an acknowledgement it does not matter what command phase is currently executed, and ps2_handle_ack() should indicate that no further processing is needed for the received data byte. Remove PS2_FLAG_ACK_CMD and associated handling. Note that while it is possible to make ps2_handle_ack (and ps2_handle_repsonse) return void, it will be done when the code will be converted to common PS/2 interrupt handler later. Reviewed-by: Raul E Rangel <rrangel@chromium.org> Link: https://lore.kernel.org/r/20230511185252.386941-3-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 100e169 commit fc522f3

2 files changed

Lines changed: 2 additions & 8 deletions

File tree

drivers/input/serio/libps2.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,6 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
253253
for (i = 0; i < receive; i++)
254254
ps2dev->cmdbuf[(receive - 1) - i] = param[i];
255255

256-
/* Signal that we are sending the command byte */
257-
ps2dev->flags |= PS2_FLAG_ACK_CMD;
258-
259256
/*
260257
* Some devices (Synaptics) peform the reset before
261258
* ACKing the reset command, and so it can take a long
@@ -267,9 +264,7 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
267264
if (rc)
268265
goto out_reset_flags;
269266

270-
/* Now we are sending command parameters, if any */
271-
ps2dev->flags &= ~PS2_FLAG_ACK_CMD;
272-
267+
/* Send command parameters, if any. */
273268
for (i = 0; i < send; i++) {
274269
rc = ps2_do_sendbyte(ps2dev, param[i], 200, 2);
275270
if (rc)
@@ -436,7 +431,7 @@ bool ps2_handle_ack(struct ps2dev *ps2dev, u8 data)
436431
*/
437432
dev_dbg(&ps2dev->serio->dev, "unexpected %#02x\n", data);
438433
ps2dev->flags &= ~PS2_FLAG_WAITID;
439-
return ps2dev->flags & PS2_FLAG_ACK_CMD;
434+
return true;
440435
}
441436

442437
if (!ps2dev->nak) {

include/linux/libps2.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#define PS2_FLAG_CMD1 BIT(2) /* Waiting for the first byte of command response */
2929
#define PS2_FLAG_WAITID BIT(3) /* Command executing is GET ID */
3030
#define PS2_FLAG_NAK BIT(4) /* Last transmission was NAKed */
31-
#define PS2_FLAG_ACK_CMD BIT(5) /* Waiting to ACK the command (first) byte */
3231

3332
struct ps2dev {
3433
struct serio *serio;

0 commit comments

Comments
 (0)