提交 79bb71bd 编写于 作者: L Linus Walleij

gpio: make sure gpiod_to_irq() returns negative on NULL desc

commit 54d77198
("gpio: bail out silently on NULL descriptors")
doesn't work for gpiod_to_irq(): drivers assume that NULL
descriptors will give negative IRQ numbers in return.

It has been pointed out that returning 0 is NO_IRQ and that
drivers should be amended to treat this as an error, but that
is for the longer term: now let us repair the semantics.

Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Reported-by: NHans de Goede <hdegoede@redhat.com>
Tested-by: NHans de Goede <hdegoede@redhat.com>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 053ae649
...@@ -2056,7 +2056,14 @@ int gpiod_to_irq(const struct gpio_desc *desc) ...@@ -2056,7 +2056,14 @@ int gpiod_to_irq(const struct gpio_desc *desc)
struct gpio_chip *chip; struct gpio_chip *chip;
int offset; int offset;
VALIDATE_DESC(desc); /*
* Cannot VALIDATE_DESC() here as gpiod_to_irq() consumer semantics
* requires this function to not return zero on an invalid descriptor
* but rather a negative error number.
*/
if (!desc || !desc->gdev || !desc->gdev->chip)
return -EINVAL;
chip = desc->gdev->chip; chip = desc->gdev->chip;
offset = gpio_chip_hwgpio(desc); offset = gpio_chip_hwgpio(desc);
if (chip->to_irq) { if (chip->to_irq) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册