All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: nuno.sa@analog.com
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-input@vger.kernel.org,
	Michael Hennerich <michael.hennerich@analog.com>
Subject: Re: [PATCH] Input: adp5588-keys: fix check on return code
Date: Fri, 20 Sep 2024 08:17:47 +0000	[thread overview]
Message-ID: <Zu0vq0ogr2HzXWv7@google.com> (raw)
In-Reply-To: <20240920-fix-adp5588-err-check-v1-1-81f6e957ef24@analog.com>

On Fri, Sep 20, 2024 at 09:22:52AM +0200, Nuno Sa via B4 Relay wrote:
> From: Nuno Sa <nuno.sa@analog.com>
> 
> During adp5588_setup(), we read all the events to clear the event FIFO.
> However, adp5588_read() just calls i2c_smbus_read_byte_data() which
> returns the byte read in case everything goes well. Hence, we need to
> explicitly check for a negative error code instead of checking for
> something different than 0.
> 
> Fixes: e960309ce318 ("Input: adp5588-keys - bail out on returned error")
> Signed-off-by: Nuno Sa <nuno.sa@analog.com>
> ---
>  drivers/input/keyboard/adp5588-keys.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
> index b5f4becf5cb6f..d25d63a807f23 100644
> --- a/drivers/input/keyboard/adp5588-keys.c
> +++ b/drivers/input/keyboard/adp5588-keys.c
> @@ -620,7 +620,7 @@ static int adp5588_setup(struct adp5588_kpad *kpad)
>  
>  	for (i = 0; i < KEYP_MAX_EVENT; i++) {
>  		ret = adp5588_read(client, KEY_EVENTA);
> -		if (ret)
> +		if (ret < 0)
>  			return ret;
>  	}

Hmm... There are a bunch of places where we do not check result of
adp5588_read(). I wonder if we should:

1. add the checks
2. change it to return error or 0 and return the value through a pointer
argument.

In the meantime I'll apply this patch.

Thanks.

-- 
Dmitry

  reply	other threads:[~2024-09-20  8:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-20  7:22 [PATCH] Input: adp5588-keys: fix check on return code Nuno Sa
2024-09-20  7:22 ` Nuno Sa via B4 Relay
2024-09-20  8:17 ` Dmitry Torokhov [this message]
2024-09-20 11:07   ` Nuno Sá

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=Zu0vq0ogr2HzXWv7@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=nuno.sa@analog.com \
    /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.