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 3/7] Input: libps2 - rework handling of command response
Date: Thu, 18 May 2023 11:21:34 -0600 [thread overview]
Message-ID: <ZGZenuKMicegjUsZ@google.com> (raw)
In-Reply-To: <20230511185252.386941-4-dmitry.torokhov@gmail.com>
On Thu, May 11, 2023 at 11:52:43AM -0700, Dmitry Torokhov wrote:
> 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.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/input/serio/libps2.c | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
> index 399cda0d34f5..d09450eca9a7 100644
> --- a/drivers/input/serio/libps2.c
> +++ b/drivers/input/serio/libps2.c
> @@ -247,14 +247,19 @@ int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
>
> serio_pause_rx(ps2dev->serio);
>
> + /* Some mice do not ACK the "get ID" command, prepare to handle this. */
> ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0;
> ps2dev->cmdcnt = receive;
> - if (receive && param)
> - for (i = 0; i < receive; i++)
> - ps2dev->cmdbuf[(receive - 1) - i] = param[i];
> + if (receive) {
> + /* Indicate that we expect response to the command. */
> + ps2dev->flags |= PS2_FLAG_CMD | PS2_FLAG_CMD1;
> + if (param)
> + for (i = 0; i < receive; i++)
> + ps2dev->cmdbuf[(receive - 1) - i] = param[i];
> + }
>
> /*
> - * Some devices (Synaptics) peform the reset before
> + * Some devices (Synaptics) perform the reset before
> * ACKing the reset command, and so it can take a long
> * time before the ACK arrives.
> */
> @@ -434,11 +439,8 @@ bool ps2_handle_ack(struct ps2dev *ps2dev, u8 data)
> return true;
> }
>
> - if (!ps2dev->nak) {
> + if (!ps2dev->nak)
> ps2dev->flags &= ~PS2_FLAG_NAK;
> - if (ps2dev->cmdcnt)
> - ps2dev->flags |= PS2_FLAG_CMD | PS2_FLAG_CMD1;
> - }
>
> ps2dev->flags &= ~PS2_FLAG_ACK;
> wake_up(&ps2dev->wait);
Reviewed-by: Raul E Rangel <rrangel@chromium.org>
next prev parent 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
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 [this message]
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=ZGZenuKMicegjUsZ@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).