From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Aaron Lu <aaron.lu@intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Alexandre Courbot <gnurou@gmail.com>,
linux-input@vger.kernel.org, linux-gpio@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH] input: gpio_keys_polled: Correct check for invalid gpiod
Date: Fri, 19 Feb 2016 11:04:33 +0100 [thread overview]
Message-ID: <1455876273-5913-1-git-send-email-geert+renesas@glider.be> (raw)
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;
bdata->can_sleep = gpiod_cansleep(button->gpiod);
bdata->last_state = -1;
--
1.9.1
next reply other threads:[~2016-02-19 10:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 10:04 Geert Uytterhoeven [this message]
2016-02-19 10:39 ` [PATCH] input: gpio_keys_polled: Correct check for invalid gpiod Mika Westerberg
2016-02-22 19:54 ` Dmitry Torokhov
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=1455876273-5913-1-git-send-email-geert+renesas@glider.be \
--to=geert+renesas@glider.be \
--cc=aaron.lu@intel.com \
--cc=dmitry.torokhov@gmail.com \
--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).