linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: sirf: atlas7: fix of_irq_get() error check
@ 2017-07-30 19:38 Sergei Shtylyov
  2017-08-03 21:31 ` Linus Walleij
  0 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2017-07-30 19:38 UTC (permalink / raw)
  To: linux-arm-kernel

of_irq_get() may return  any negative error number as well as 0 on failure,
while the driver only checks for -EPROBE_DEFER, blithely continuing with
the call to gpiochip_set_chained_irqchip() -- that function expects the
parent IRQ as *unsigned int*, so would probably do nothing  when a large
IRQ number resulting from a conversion of a negative error number is passed
to it, however passing 0 would probably work but the driver won't receive
valid GPIO bank interrupts.

Check for 'ret <= 0' instead and return -ENXIO from the driver's probe iff
of_irq_get() returned 0.

Fixes: f9367793293d ("pinctrl: sirf: add sirf atlas7 pinctrl and gpio support")
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
The patch is against the 'fixes' branch of Linus W.'s 'linux-pinctrl.git' repo.

 drivers/pinctrl/sirf/pinctrl-atlas7.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-pinctrl/drivers/pinctrl/sirf/pinctrl-atlas7.c
===================================================================
--- linux-pinctrl.orig/drivers/pinctrl/sirf/pinctrl-atlas7.c
+++ linux-pinctrl/drivers/pinctrl/sirf/pinctrl-atlas7.c
@@ -6081,9 +6081,11 @@ static int atlas7_gpio_probe(struct plat
 
 		/* Get interrupt number from DTS */
 		ret = of_irq_get(np, idx);
-		if (ret == -EPROBE_DEFER) {
+		if (ret <= 0) {
 			dev_err(&pdev->dev,
 				"Unable to find IRQ number. ret=%d\n", ret);
+			if (!ret)
+				ret = -ENXIO;
 			goto failed;
 		}
 		bank->irq = ret;

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

end of thread, other threads:[~2017-08-07 16:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-30 19:38 [PATCH] pinctrl: sirf: atlas7: fix of_irq_get() error check Sergei Shtylyov
2017-08-03 21:31 ` Linus Walleij
2017-08-04 16:58   ` Sergei Shtylyov
2017-08-07  9:07     ` Linus Walleij
2017-08-07  9:53       ` Sergei Shtylyov
2017-08-07 13:30         ` Linus Walleij
2017-08-07 16:20           ` Sergei Shtylyov

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