linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: sh-pfc: Let gpio_chip.to_irq() return -ENXIO on error
@ 2016-04-29  7:24 Geert Uytterhoeven
  2016-05-01  8:48 ` Linus Walleij
  0 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2016-04-29  7:24 UTC (permalink / raw)
  To: Linus Walleij, Laurent Pinchart
  Cc: linux-gpio, linux-renesas-soc, Geert Uytterhoeven

Currrently the gpio_chip.to_irq() callback returns -ENOSYS on error,
which causes bad interactions with the serial_mctrl_gpio helpers.

mctrl_gpio_init() returns -ENOSYS if GPIOLIB is not enabled, which is
intended to be ignored by its callers. However, ignoring -ENOSYS when it
was caused by a gpiod_to_irq() failure will lead to a crash later:

    Unable to handle kernel paging request at virtual address ffffffde
    ...
    PC is at mctrl_gpio_set+0x14/0x78

Fix this by returning -ENXIO instead.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Is -ENXIO the right error code?

  - Most drivers seem to return -ENXIO on failure, just like
    gpiod_to_irq() does when no .to_irq() callback is provided by the
    driver,
  - Some drivers use -EINVAL,
  - Drivers that call irq_find_mapping(), irq_create_mapping(), or
    irq_create_fwspec_mapping() return zero!  This also applies to the
    core helper gpiochip_to_irq().
---
 drivers/pinctrl/sh-pfc/gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c
index a6681b8b17c3b30c..2fffb9c32231adb3 100644
--- a/drivers/pinctrl/sh-pfc/gpio.c
+++ b/drivers/pinctrl/sh-pfc/gpio.c
@@ -212,7 +212,7 @@ static int gpio_pin_to_irq(struct gpio_chip *gc, unsigned offset)
 		}
 	}
 
-	return -ENOSYS;
+	return -ENXIO;
 
 found:
 	return pfc->irqs[i];
-- 
1.9.1

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

end of thread, other threads:[~2016-05-02 11:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-29  7:24 [PATCH] pinctrl: sh-pfc: Let gpio_chip.to_irq() return -ENXIO on error Geert Uytterhoeven
2016-05-01  8:48 ` Linus Walleij
2016-05-02  8:03   ` Geert Uytterhoeven
2016-05-02  8:30     ` Linus Walleij
2016-05-02  8:53       ` Geert Uytterhoeven
2016-05-02  9:04         ` Geert Uytterhoeven
2016-05-02  9:06           ` Linus Walleij
2016-05-02  9:10             ` Geert Uytterhoeven
2016-05-02  9:25               ` Linus Walleij
2016-05-02 10:05                 ` Geert Uytterhoeven
2016-05-02 11:16                   ` Linus Walleij

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).