Skip to contentSkip to conversation

pinctr: microchip-sgpio: Correct the fwnode_irq_get() return value check

PATCH In review Andy Shevchenko 2 participants 3 messages Sep 5, 2022 – Sep 6, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctr: microchip-sgpio: Correct the fwnode_irq_get() return value check

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)")
---
 drivers/pinctrl/pinctrl-microchip-sgpio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pinctrl/pinctrl-microchip-sgpio.c +3 -2
index 6f55bf7d5e05..0771b743a940 100644
@@ -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);
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw

Am 2022-09-05 21:08, schrieb Andy Shevchenko:

Quoted 6 lines

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

Btw. do we care about EPROBE_DEFER?

-michael

#2 lore raw
Quoted 9 lines · Michael Walle

Am 2022-09-05 21:08, schrieb Andy Shevchenko:

Quoted 6 lines

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

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

Quoted 1 line

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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko