From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Aaron Lu <aaron.lu@intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <gnurou@gmail.com>,
linux-input@vger.kernel.org, linux-gpio@vger.kernel.org
Subject: Re: [PATCH] input: gpio_keys_polled: Correct check for invalid gpiod
Date: Mon, 22 Feb 2016 11:54:02 -0800 [thread overview]
Message-ID: <20160222195402.GA28343@dtor-ws> (raw)
In-Reply-To: <1455876273-5913-1-git-send-email-geert+renesas@glider.be>
On Fri, Feb 19, 2016 at 11:04:33AM +0100, Geert Uytterhoeven wrote:
> At this point in gpio_keys_polled_probe(), button->gpiod contains either
> a pointer to a GPIO descriptor or NULL, because:
> - gpio_keys_polled_get_devtree_pdata() fills in button->gpiod only if
> devm_get_gpiod_from_child() succeeded,
> - gpio_to_desc() returns NULL on failure, not an ERR_PTR(),
> - button->gpiod is untouched if it was NULL, and button->gpio is not
> valid.
>
> Hence check for NULL only, and return -EINVAL on failure.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Question: Should it return -ENOENT instead?
>
> next-20160219:drivers/leds/leds-gpio.c uses -EINVAL, too.
> ---
> drivers/input/keyboard/gpio_keys_polled.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
> index 62bdb1d48c49dbd9..1ef3c66099a50d72 100644
> --- a/drivers/input/keyboard/gpio_keys_polled.c
> +++ b/drivers/input/keyboard/gpio_keys_polled.c
> @@ -330,8 +330,8 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
> button->gpiod = gpio_to_desc(button->gpio);
> }
>
> - if (IS_ERR(button->gpiod))
> - return PTR_ERR(button->gpiod);
> + if (!button->gpiod)
> + return -EINVAL;
I wonder if we should move this check into body of
if (!button->gpiod && gpio_is_valid(button->gpio)) {
...
}
Thanks.
--
Dmitry
next prev parent reply other threads:[~2016-02-22 19:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 10:04 [PATCH] input: gpio_keys_polled: Correct check for invalid gpiod Geert Uytterhoeven
2016-02-19 10:39 ` Mika Westerberg
2016-02-22 19:54 ` Dmitry Torokhov [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-02-19 9:58 Geert Uytterhoeven
2016-02-19 10:01 ` Geert Uytterhoeven
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=20160222195402.GA28343@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=aaron.lu@intel.com \
--cc=geert+renesas@glider.be \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=rafael.j.wysocki@intel.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 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).