linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] pinctr: microchip-sgpio: Correct the fwnode_irq_get() return value check
@ 2022-09-05 19:08 Andy Shevchenko
  2022-09-05 22:24 ` Michael Walle
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-09-05 19:08 UTC (permalink / raw)
  To: Linus Walleij, Michael Walle, linux-arm-kernel, linux-gpio, linux-kernel
  Cc: Lars Povlsen, Steen Hegelund, UNGLinuxDriver, Andy Shevchenko

fwnode_irq_get() may return all possible signed values, such as Linux
error code. Fix the code to handle this properly.

Fixes: be2dc859abd4 ("pinctrl: pinctrl-microchip-sgpio: Add irq support (for sparx5)")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/pinctrl-microchip-sgpio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c
index 6f55bf7d5e05..0771b743a940 100644
--- a/drivers/pinctrl/pinctrl-microchip-sgpio.c
+++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c
@@ -864,9 +864,10 @@ static int microchip_sgpio_register_bank(struct device *dev,
 	gc->can_sleep		= !bank->is_input;
 
 	if (bank->is_input && priv->properties->flags & SGPIO_FLAGS_HAS_IRQ) {
-		int irq = fwnode_irq_get(fwnode, 0);
+		int irq;
 
-		if (irq) {
+		irq = fwnode_irq_get(fwnode, 0);
+		if (irq > 0) {
 			struct gpio_irq_chip *girq = &gc->irq;
 
 			gpio_irq_chip_set_chip(girq, &microchip_sgpio_irqchip);
-- 
2.35.1


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

* Re: [PATCH v1 1/1] pinctr: microchip-sgpio: Correct the fwnode_irq_get() return value check
  2022-09-05 19:08 [PATCH v1 1/1] pinctr: microchip-sgpio: Correct the fwnode_irq_get() return value check Andy Shevchenko
@ 2022-09-05 22:24 ` Michael Walle
  2022-09-06 11:47   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Walle @ 2022-09-05 22:24 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, linux-arm-kernel, linux-gpio, linux-kernel,
	Lars Povlsen, Steen Hegelund, UNGLinuxDriver

Am 2022-09-05 21:08, schrieb Andy Shevchenko:
> fwnode_irq_get() may return all possible signed values, such as Linux
> error code. Fix the code to handle this properly.
> 
> Fixes: be2dc859abd4 ("pinctrl: pinctrl-microchip-sgpio: Add irq
> support (for sparx5)")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Michael Walle <michael@walle.cc>

Btw. do we care about EPROBE_DEFER?

-michael

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

* Re: [PATCH v1 1/1] pinctr: microchip-sgpio: Correct the fwnode_irq_get() return value check
  2022-09-05 22:24 ` Michael Walle
@ 2022-09-06 11:47   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-09-06 11:47 UTC (permalink / raw)
  To: Michael Walle
  Cc: Linus Walleij, linux-arm-kernel, linux-gpio, linux-kernel,
	Lars Povlsen, Steen Hegelund, UNGLinuxDriver

On Tue, Sep 06, 2022 at 12:24:43AM +0200, Michael Walle wrote:
> Am 2022-09-05 21:08, schrieb Andy Shevchenko:
> > fwnode_irq_get() may return all possible signed values, such as Linux
> > error code. Fix the code to handle this properly.
> > 
> > Fixes: be2dc859abd4 ("pinctrl: pinctrl-microchip-sgpio: Add irq
> > support (for sparx5)")
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Reviewed-by: Michael Walle <michael@walle.cc>

Thanks! I will send a v2 since I have to fix a typo in the Subject.

> Btw. do we care about EPROBE_DEFER?

In the original code this big (unsigned) value was added as parent IRQ and
things wouldn't work, with the proposed change IRQ won't work, but at least
in robust way without any surprises (whatever big parent IRQ number mean).

I think the people who have access to hardware and different configurations
of the kernel may or may not add the support later on.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2022-09-06 11:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05 19:08 [PATCH v1 1/1] pinctr: microchip-sgpio: Correct the fwnode_irq_get() return value check Andy Shevchenko
2022-09-05 22:24 ` Michael Walle
2022-09-06 11:47   ` Andy Shevchenko

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