linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Raul E Rangel <rrangel@chromium.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/7] Input: libps2 - remove special handling of ACK for command byte
Date: Thu, 18 May 2023 11:21:15 -0600	[thread overview]
Message-ID: <ZGZei+KBg+Sn99ZW@google.com> (raw)
In-Reply-To: <20230511185252.386941-3-dmitry.torokhov@gmail.com>

On Thu, May 11, 2023 at 11:52:42AM -0700, Dmitry Torokhov wrote:
> 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.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/serio/libps2.c | 9 ++-------
>  include/linux/libps2.h       | 1 -
>  2 files changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
> index 764990723847..399cda0d34f5 100644
> --- a/drivers/input/serio/libps2.c
> +++ b/drivers/input/serio/libps2.c
> @@ -253,9 +253,6 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
>  		for (i = 0; i < receive; 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
>  	 * 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)
>  		goto out_reset_flags;
>  
> -	/* Now we are sending command parameters, if any */
> -	ps2dev->flags &= ~PS2_FLAG_ACK_CMD;
> -
> +	/* Send command parameters, if any. */
>  	for (i = 0; i < send; i++) {
>  		rc = ps2_do_sendbyte(ps2dev, param[i], 200, 2);
>  		if (rc)
> @@ -436,7 +431,7 @@ bool ps2_handle_ack(struct ps2dev *ps2dev, u8 data)
>  		 */
>  		dev_dbg(&ps2dev->serio->dev, "unexpected %#02x\n", data);
>  		ps2dev->flags &= ~PS2_FLAG_WAITID;
> -		return ps2dev->flags & PS2_FLAG_ACK_CMD;
> +		return true;
>  	}
>  
>  	if (!ps2dev->nak) {
> diff --git a/include/linux/libps2.h b/include/linux/libps2.h
> index 53f7e4d0f4b7..193dd53ad18b 100644
> --- a/include/linux/libps2.h
> +++ b/include/linux/libps2.h
> @@ -28,7 +28,6 @@
>  #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_NAK		BIT(4)	/* Last transmission was NAKed */
> -#define PS2_FLAG_ACK_CMD	BIT(5)	/* Waiting to ACK the command (first) byte */
>  
>  struct ps2dev {
>  	struct serio *serio;
Reviewed-by: Raul E Rangel <rrangel@chromium.org>

  reply	other threads:[~2023-05-18 17:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11 18:52 [PATCH 0/7] libps2: be more tolerant when processing commands Dmitry Torokhov
2023-05-11 18:52 ` [PATCH 1/7] Input: libps2 - attach ps2dev instances as serio port's drvdata Dmitry Torokhov
2023-05-18 17:20   ` Raul E Rangel
2023-05-11 18:52 ` [PATCH 2/7] Input: libps2 - remove special handling of ACK for command byte Dmitry Torokhov
2023-05-18 17:21   ` Raul E Rangel [this message]
2023-05-11 18:52 ` [PATCH 3/7] Input: libps2 - rework handling of command response Dmitry Torokhov
2023-05-18 17:21   ` Raul E Rangel
2023-05-11 18:52 ` [PATCH 4/7] Input: libps2 - fix NAK handling Dmitry Torokhov
2023-05-18 17:22   ` Raul E Rangel
2023-05-11 18:52 ` [PATCH 5/7] Input: libps2 - fix aborting PS/2 commands Dmitry Torokhov
2023-05-18 17:22   ` Raul E Rangel
2023-05-11 18:52 ` [PATCH 6/7] Input: libps2 - introduce common interrupt handler Dmitry Torokhov
2023-05-12  1:01   ` kernel test robot
2023-05-15  1:52   ` kernel test robot
2023-05-15 23:14   ` [PATCH v2 " Dmitry Torokhov
2023-05-18 17:22   ` [PATCH " Raul E Rangel
2023-05-11 18:52 ` [PATCH 7/7] Input: libps2 - do not discard non-ack bytes when controlling LEDs Dmitry Torokhov
2023-05-18 17:24   ` Raul E Rangel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZGZei+KBg+Sn99ZW@google.com \
    --to=rrangel@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).