Skip to contentSkip to conversation

gpio: mxc: use platform_get_irq_optional() to avoid an error message

PATCH In review Shenwei Wang 2 participants 3 messages May 9, 2023

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

PATCH v2 1/1 gpio: mxc: use platform_get_irq_optional() to avoid an error message

From: Fugang Duan <[email protected]>

Use platform_get_irq_optional() to avoid an error message for the optional irq.

Restructuring the codes to ask for the first mandatory IRQ before the optional one.

Fixes 7723f4c5ecdb ("driver core: platform: Add an error message to platform_get_irq*()")

---
v2:
- restructuring the codes per Andy Shevchenko's review

 drivers/gpio/gpio-mxc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpio/gpio-mxc.c +6 -6
index 9d0cec4b82a3..b8fa44a3fd4c 100644
@@ -405,16 +405,16 @@ static int mxc_gpio_probe(struct platform_device *pdev)
 	if (irq_count < 0)
 		return irq_count;
 
-	if (irq_count > 1) {
-		port->irq_high = platform_get_irq(pdev, 1);
-		if (port->irq_high < 0)
-			port->irq_high = 0;
-	}
-
 	port->irq = platform_get_irq(pdev, 0);
 	if (port->irq < 0)
 		return port->irq;
 
+	if (irq_count > 1) {
+		err = platform_get_irq_optional(pdev, 1);
+		if (err > 0)
+			port->irq_high = err;
+	}
+
 	/* the controller clock is optional */
 	port->clk = devm_clk_get_optional(&pdev->dev, NULL);
 	if (IS_ERR(port->clk))

--
2.34.1

#1 lore raw
Quoted 5 lines · Shenwei Wang

From: Fugang Duan <[email protected]>

Use platform_get_irq_optional() to avoid an error message for the optional irq.

Looking into the code more, this won't happen as the first operation is to check how many IRQs the device already has. So, you may go further and kill that irq_count variable completely with your suggestion.

Quoted 4 lines

Restructuring the codes to ask for the first mandatory IRQ before the optional one.

Fixes 7723f4c5ecdb ("driver core: platform: Add an error message to platform_get_irq*()")

Hmm...
With the above, the proposed change does not fix anything, I believe. And I'm not sure that this commit is what we want to actually fix.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 34 lines

-----Original Message-----
From: Andy Shevchenko <[email protected]>
Sent: Tuesday, May 9, 2023 11:09 AM
To: Shenwei Wang <[email protected]>
Cc: Linus Walleij <[email protected]>; Bartosz Golaszewski <[email protected]>; Stephen Boyd <[email protected]>; Greg Kroah- Hartman <[email protected]>; Rafael J. Wysocki <[email protected]>; [email protected]; [email protected]; dl-linux-imx <[email protected]>; Fugang Duan <[email protected]>
Subject: [EXT] Re: [PATCH v2 1/1] gpio: mxc: use platform_get_irq_optional() to avoid an error message

Caution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button

Quoted 5 lines · Shenwei Wang

From: Fugang Duan <[email protected]>

Use platform_get_irq_optional() to avoid an error message for the optional irq.

Looking into the code more, this won't happen as the first operation is to check how many IRQs the device already has. So, you may go further and kill that irq_count variable completely with your suggestion.

Quoted 3 lines

Restructuring the codes to ask for the first mandatory IRQ before the optional one.

Quoted 7 lines
Quoted 2 lines
Fixes 7723f4c5ecdb ("driver core: platform: Add an error message to

platform_get_irq*()")

Hmm...
With the above, the proposed change does not fix anything, I believe. And I'm not sure that this commit is what we want to actually fix.

After re-thinking the logic here, I think you are right. As it has already checked the irqcount before asking for the irq, this patch doesn't fix anything.

Thanks,
Shenwei

Quoted 3 lines

--
With Best Regards,
Andy Shevchenko