Commit fc522f3b authored by Dmitry Torokhov's avatar Dmitry Torokhov
Browse files

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: default avatarRaul E Rangel <rrangel@chromium.org>
Link: https://lore.kernel.org/r/20230511185252.386941-3-dmitry.torokhov@gmail.com


Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 100e1695
Loading
Loading
Loading
Loading
+2 −7
Original line number Original line Diff line number Diff line
@@ -253,9 +253,6 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
		for (i = 0; i < receive; i++)
		for (i = 0; i < receive; i++)
			ps2dev->cmdbuf[(receive - 1) - i] = param[i];
			ps2dev->cmdbuf[(receive - 1) - i] = param[i];


	/* Signal that we are sending the command byte */
	ps2dev->flags |= PS2_FLAG_ACK_CMD;

	/*
	/*
	 * Some devices (Synaptics) peform the reset before
	 * Some devices (Synaptics) peform the reset before
	 * ACKing the reset command, and so it can take a long
	 * 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)
	if (rc)
	if (rc)
		goto out_reset_flags;
		goto out_reset_flags;


	/* Now we are sending command parameters, if any */
	/* Send command parameters, if any. */
	ps2dev->flags &= ~PS2_FLAG_ACK_CMD;

	for (i = 0; i < send; i++) {
	for (i = 0; i < send; i++) {
		rc = ps2_do_sendbyte(ps2dev, param[i], 200, 2);
		rc = ps2_do_sendbyte(ps2dev, param[i], 200, 2);
		if (rc)
		if (rc)
@@ -436,7 +431,7 @@ bool ps2_handle_ack(struct ps2dev *ps2dev, u8 data)
		 */
		 */
		dev_dbg(&ps2dev->serio->dev, "unexpected %#02x\n", data);
		dev_dbg(&ps2dev->serio->dev, "unexpected %#02x\n", data);
		ps2dev->flags &= ~PS2_FLAG_WAITID;
		ps2dev->flags &= ~PS2_FLAG_WAITID;
		return ps2dev->flags & PS2_FLAG_ACK_CMD;
		return true;
	}
	}


	if (!ps2dev->nak) {
	if (!ps2dev->nak) {
+0 −1
Original line number Original line Diff line number Diff line
@@ -28,7 +28,6 @@
#define PS2_FLAG_CMD1		BIT(2)	/* Waiting for the first byte of command response */
#define PS2_FLAG_CMD1		BIT(2)	/* Waiting for the first byte of command response */
#define PS2_FLAG_WAITID		BIT(3)	/* Command executing is GET ID */
#define PS2_FLAG_WAITID		BIT(3)	/* Command executing is GET ID */
#define PS2_FLAG_NAK		BIT(4)	/* Last transmission was NAKed */
#define PS2_FLAG_NAK		BIT(4)	/* Last transmission was NAKed */
#define PS2_FLAG_ACK_CMD	BIT(5)	/* Waiting to ACK the command (first) byte */


struct ps2dev {
struct ps2dev {
	struct serio *serio;
	struct serio *serio;