Skip to contentSkip to conversation

gpio: mpc8xxx: Fix IRQ check in mpc8xxx_probe

PATCH Applied Miaoqian Lin 3 participants 3 messages Jan 14, 2022 – Jan 17, 2022 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: mpc8xxx: Fix IRQ check in mpc8xxx_probe

platform_get_irq() returns negative error number instead 0 on failure. And the doc of platform_get_irq() provides a usage example:

    int irq = platform_get_irq(pdev, 0);
    if (irq < 0)
        return irq;

Fix the check of return value to catch errors correctly.

Fixes 76c47d1449fc ("gpio: mpc8xxx: Add ACPI support")
---
 drivers/gpio/gpio-mpc8xxx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-mpc8xxx.c +2 -2
index 70d6ae20b1da..01634c8d27b3 100644
@@ -388,8 +388,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
 	}
 
 	mpc8xxx_gc->irqn = platform_get_irq(pdev, 0);
-	if (!mpc8xxx_gc->irqn)
-		return 0;
+	if (mpc8xxx_gc->irqn < 0)
+		return mpc8xxx_gc->irqn;
 
 	mpc8xxx_gc->irq = irq_domain_create_linear(fwnode,
 						   MPC8XXX_GPIO_PINS,
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Miaoqian Lin

platform_get_irq() returns negative error number instead 0 on failure. And the doc of platform_get_irq() provides a usage example:

    int irq = platform_get_irq(pdev, 0);
    if (irq < 0)
        return irq;

Fix the check of return value to catch errors correctly.

Fixes 76c47d1449fc ("gpio: mpc8xxx: Add ACPI support")

Yours,
Linus Walleij

#2 lore raw
In reply to Miaoqian Lin
Quoted 32 lines · Miaoqian Lin

platform_get_irq() returns negative error number instead 0 on failure. And the doc of platform_get_irq() provides a usage example:

    int irq = platform_get_irq(pdev, 0);
    if (irq < 0)
        return irq;

Fix the check of return value to catch errors correctly.

Fixes 76c47d1449fc ("gpio: mpc8xxx: Add ACPI support")
---
 drivers/gpio/gpio-mpc8xxx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-mpc8xxx.c +2 -3
index 70d6ae20b1da..01634c8d27b3 100644
@@ -388,8 +388,8 @@ static int mpc8xxx_probe(struct platform_device *pdev)
        }
 
        mpc8xxx_gc->irqn = platform_get_irq(pdev, 0);
-       if (!mpc8xxx_gc->irqn)
-               return 0;
+       if (mpc8xxx_gc->irqn < 0)
+               return mpc8xxx_gc->irqn;
 
        mpc8xxx_gc->irq = irq_domain_create_linear(fwnode,
                                                   MPC8XXX_GPIO_PINS,
--
Quoted 2 lines

2.17.1

Queued for fixes, thanks!

Bart