* [PATCH] gpio: make gpiod_to_irq() return negative for NO_IRQ
@ 2016-05-02 11:15 Linus Walleij
2016-05-02 11:25 ` Geert Uytterhoeven
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2016-05-02 11:15 UTC (permalink / raw)
To: linux-gpio, Alexandre Courbot; +Cc: Linus Walleij, Geert Uytterhoeven
If a translation returns zero, that means NO_IRQ, so we
should return an error since the function is documented to
return a negative code on error.
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpiolib.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 340b021a3782..a68c6d732818 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1999,13 +1999,22 @@ EXPORT_SYMBOL_GPL(gpiod_cansleep);
*/
int gpiod_to_irq(const struct gpio_desc *desc)
{
- struct gpio_chip *chip;
- int offset;
+ struct gpio_chip *chip;
+ int offset;
VALIDATE_DESC(desc);
chip = desc->gdev->chip;
offset = gpio_chip_hwgpio(desc);
- return chip->to_irq ? chip->to_irq(chip, offset) : -ENXIO;
+ if (chip->to_irq) {
+ int retirq = chip->to_irq(chip, offset);
+
+ /* Zero means NO_IRQ */
+ if (!retirq)
+ return -ENXIO;
+
+ return retirq;
+ }
+ return -ENXIO;
}
EXPORT_SYMBOL_GPL(gpiod_to_irq);
--
2.4.11
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] gpio: make gpiod_to_irq() return negative for NO_IRQ
2016-05-02 11:15 [PATCH] gpio: make gpiod_to_irq() return negative for NO_IRQ Linus Walleij
@ 2016-05-02 11:25 ` Geert Uytterhoeven
0 siblings, 0 replies; 2+ messages in thread
From: Geert Uytterhoeven @ 2016-05-02 11:25 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio@vger.kernel.org, Alexandre Courbot
On Mon, May 2, 2016 at 1:15 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> If a translation returns zero, that means NO_IRQ, so we
> should return an error since the function is documented to
> return a negative code on error.
>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-02 11:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-02 11:15 [PATCH] gpio: make gpiod_to_irq() return negative for NO_IRQ Linus Walleij
2016-05-02 11:25 ` Geert Uytterhoeven
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).