Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c37ce86 authored by Linus Walleij's avatar Linus Walleij
Browse files

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: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 3b711e07
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -2005,7 +2005,16 @@ int gpiod_to_irq(const struct gpio_desc *desc)
	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);