From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: John Keeping <jkeeping@inmusicbrands.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Input: ili210x - fix ili251x_read_touch_data() return value
Date: Wed, 22 May 2024 12:28:45 -0700 [thread overview]
Message-ID: <Zk5HbaC7FbIia3RV@google.com> (raw)
In-Reply-To: <20240522100341.1650842-1-jkeeping@inmusicbrands.com>
On Wed, May 22, 2024 at 11:03:41AM +0100, John Keeping wrote:
> The caller of this function treats all non-zero values as an error, so
> the return value of i2c_master_recv() cannot be returned directly.
> Follow the same pattern as ili211x_read_touch_data() to return zero when
> the correct number of bytes is read and a negative error code otherwise.
>
> This fixes touch reporting when there are more than 6 active touches.
>
> Signed-off-by: John Keeping <jkeeping@inmusicbrands.com>
> ---
> drivers/input/touchscreen/ili210x.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> index 31ffdc2a93f35..8846c6d10fc0d 100644
> --- a/drivers/input/touchscreen/ili210x.c
> +++ b/drivers/input/touchscreen/ili210x.c
> @@ -255,14 +255,15 @@ static int ili251x_read_reg(struct i2c_client *client,
> static int ili251x_read_touch_data(struct i2c_client *client, u8 *data)
> {
> int error;
> + int ret;
>
> error = ili251x_read_reg_common(client, REG_TOUCHDATA,
> data, ILI251X_DATA_SIZE1, 0);
> if (!error && data[0] == 2) {
> - error = i2c_master_recv(client, data + ILI251X_DATA_SIZE1,
> - ILI251X_DATA_SIZE2);
> - if (error >= 0 && error != ILI251X_DATA_SIZE2)
> - error = -EIO;
Thanks for noticing this. Can we say
if (error >= 0)
error = error != ILI251X_DATA_SIZE2 ? -EIO : 0;
> + ret = i2c_master_recv(client, data + ILI251X_DATA_SIZE1,
> + ILI251X_DATA_SIZE2);
> + if (ret != ILI251X_DATA_SIZE2)
> + error = ret < 0 ? ret : -EIO;
> }
>
> return error;
> --
> 2.45.1
>
Thanks.
--
Dmitry
next prev parent reply other threads:[~2024-05-22 19:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-22 10:03 [PATCH] Input: ili210x - fix ili251x_read_touch_data() return value John Keeping
2024-05-22 19:28 ` Dmitry Torokhov [this message]
2024-05-22 20:25 ` Markus Elfring
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=Zk5HbaC7FbIia3RV@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=jkeeping@inmusicbrands.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.