public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] Revert "gpio: bail out silently on NULL descriptors"
@ 2016-06-15 18:22 Hans de Goede
  2016-06-15 18:46 ` Maxime Ripard
  2016-06-15 21:04 ` Linus Walleij
  0 siblings, 2 replies; 9+ messages in thread
From: Hans de Goede @ 2016-06-15 18:22 UTC (permalink / raw)
  To: linux-arm-kernel

This reverts commit 54d77198fdfb("gpio: bail out silently on NULL
descriptors").

This commit causes the following code to fail:

gpio_desc = devm_gpiod_get_optional(dev, ...);
gpio_irq  = gpiod_to_irq(gpio_desc);
if (gpio_irq >= 0) {
	ret = devm_request_irq(dev, gpio_irq, ...);

And now ret is an error causing the probe function in question to bail.

The problem here is that gpiod_to_irq now returns 0 for a NULL
gpio_desc while 0 is a valid irq-nr. Also see:
commit 4c37ce8608a8("gpio: make gpiod_to_irq() return negative for NO_IRQ")
which specifically avoids returning 0.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/gpio/gpiolib.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 24f60d2..6c33a07 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1367,13 +1367,10 @@ done:
 /*
  * This descriptor validation needs to be inserted verbatim into each
  * function taking a descriptor, so we need to use a preprocessor
- * macro to avoid endless duplication. If the desc is NULL it is an
- * optional GPIO and calls should just bail out.
+ * macro to avoid endless duplication.
  */
 #define VALIDATE_DESC(desc) do { \
-	if (!desc) \
-		return 0; \
-	if (!desc->gdev) { \
+	if (!desc || !desc->gdev) { \
 		pr_warn("%s: invalid GPIO\n", __func__); \
 		return -EINVAL; \
 	} \
@@ -1384,9 +1381,7 @@ done:
 	} } while (0)
 
 #define VALIDATE_DESC_VOID(desc) do { \
-	if (!desc) \
-		return; \
-	if (!desc->gdev) { \
+	if (!desc || !desc->gdev) { \
 		pr_warn("%s: invalid GPIO\n", __func__); \
 		return; \
 	} \
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-06-17  8:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-15 18:22 [PATCH] Revert "gpio: bail out silently on NULL descriptors" Hans de Goede
2016-06-15 18:46 ` Maxime Ripard
2016-06-15 19:08   ` Hans de Goede
2016-06-16  9:23     ` Grygorii Strashko
2016-06-16  9:53       ` Linus Walleij
2016-06-17  8:05         ` Hans de Goede
2016-06-17  8:04       ` Hans de Goede
2016-06-15 21:04 ` Linus Walleij
2016-06-17  8:07   ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox