1
0
Fork 0

gpio: make gpiod_to_irq() return negative for NO_IRQ

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.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
hifive-unleashed-5.1
Linus Walleij 2016-05-02 13:13:10 +02:00
parent 3b711e0781
commit 4c37ce8608
1 changed files with 12 additions and 3 deletions

View File

@ -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);