From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Linus Walleij <linus.walleij@linaro.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-gpio@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH] pinctrl: sh-pfc: Let gpio_chip.to_irq() return -ENXIO on error
Date: Fri, 29 Apr 2016 09:24:37 +0200 [thread overview]
Message-ID: <1461914677-24899-1-git-send-email-geert+renesas@glider.be> (raw)
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
next reply other threads:[~2016-04-29 7:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-29 7:24 Geert Uytterhoeven [this message]
2016-05-01 8:48 ` [PATCH] pinctrl: sh-pfc: Let gpio_chip.to_irq() return -ENXIO on error 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461914677-24899-1-git-send-email-geert+renesas@glider.be \
--to=geert+renesas@glider.be \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).