Skip to contentSkip to conversation

pinctrl: ocelot: Propagate errors from optional IRQ lookup

PATCH Superseded [email protected] 3 participants 12 messages Aug 10 – Aug 12

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 pinctrl: ocelot: Propagate errors from optional IRQ lookup

From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

---
 drivers/pinctrl/pinctrl-ocelot.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pinctrl/pinctrl-ocelot.c +2 -0
index 0fe0527863b8..02824da6bcdf 100644
@@ -2369,6 +2369,8 @@ static int ocelot_gpiochip_register(struct platform_device *pdev,
 	gc->label = "ocelot-gpio";
 
 	irq = platform_get_irq_optional(pdev, 0);
+	if (irq < 0 && irq != -ENXIO)
+		return irq;
 	if (irq > 0) {
 		girq = &gc->irq;
 		gpio_irq_chip_set_chip(girq, &ocelot_irqchip);
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/5 pinctrl: keembay: Propagate errors from optional IRQ lookup

From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

---
 drivers/pinctrl/pinctrl-keembay.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-keembay.c +3 -1
index 3241d3ae6219..0b65b186e3c1 100644
@@ -1497,8 +1497,10 @@ static int keembay_gpiochip_probe(struct keembay_pinctrl *kpc,
 		int irq;
 
 		irq = platform_get_irq_optional(pdev, i);
-		if (irq <= 0)
+		if (irq == -ENXIO)
 			continue;
+		if (irq < 0)
+			return irq;
 
 		girq->parents[i]	= irq;
 		kmb_irq->line	= girq->parents[i];
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 2/5] pinctrl: keembay: Propagate errors from optional IRQ lookup

Quoted 7 lines · On Mon, Aug 10, 2026 at 8:32 AM <[email protected]> wrote:

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

While this looks okay, have you considered actually having the platform_get_irq_optional() to be optional in this sense?

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

Re: [PATCH 2/5] pinctrl: keembay: Propagate errors from optional IRQ lookup

Hi Andy,
Thank you for your review .

Quoted 4 lines

While this looks okay, have you considered actually having the platform_get_irq_optional() to be optional in this sense?

As I understand it, if we decide to use platform_get_irq_optional(), then -ENXIO should be handled as the expected case where the IRQ is not available.
If we do not want to handle -ENXIO as an optional IRQ, then I think we should use platform_get_irq() instead, which matches its intended semantics:

https://elixir.bootlin.com/linux/v7.2-rc6/source/drivers/base/platform.c#L301

-------------------------------
ret = platform_get_irq_optional(dev, num);
if (ret < 0)

        return dev_err_probe(&dev->dev, ret,
                                            "IRQ index %u not found\n", num);

-------------------------------

In my opinion, we should not use an optional API if the IRQ is not actually intended to be optional.

Best regards,
Phuc

#4 lore raw

Re: [PATCH 2/5] pinctrl: keembay: Propagate errors from optional IRQ lookup

Quoted 6 lines · Bui Duc Phuc
Quoted 2 lines

While this looks okay, have you considered actually having the platform_get_irq_optional() to be optional in this sense?

As I understand it, if we decide to use platform_get_irq_optional(), then -ENXIO should be handled as the expected case where the IRQ is not available.

If platform_get_irq_optional() was optional, it would return 0 instead of ENXIO (and avoid printing any message in such a case).

Quoted 9 lines

If we do not want to handle -ENXIO as an optional IRQ, then I think we should use platform_get_irq() instead, which matches its intended semantics:

https://elixir.bootlin.com/linux/v7.2-rc6/source/drivers/base/platform.c#L301

-------------------------------
ret = platform_get_irq_optional(dev, num);
if (ret < 0)

Quoted 6 lines
        return dev_err_probe(&dev->dev, ret,
                                            "IRQ index %u not found\n", num);

-------------------------------

In my opinion, we should not use an optional API if the IRQ is not actually intended to be optional.

Right. But does it suit for this driver?

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

PATCH 3/5 pinctrl: lynxpoint: Propagate errors from optional IRQ lookup

In reply to [email protected]

From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

---
 drivers/pinctrl/intel/pinctrl-lynxpoint.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pinctrl/intel/pinctrl-lynxpoint.c +2 -0
index 299ee4f22bdc..29df00c86250 100644
@@ -777,6 +777,8 @@ static int lp_gpio_probe(struct platform_device *pdev)
 
 	/* set up interrupts  */
 	irq = platform_get_irq_optional(pdev, 0);
+	if (irq < 0 && irq != -ENXIO)
+		return irq;
 	if (irq > 0) {
 		struct gpio_irq_chip *girq;
 
Signature · 1 line
2.43.0
#6 lore raw

Re: [PATCH 3/5] pinctrl: lynxpoint: Propagate errors from optional IRQ lookup

Quoted 6 lines · On Mon, Aug 10, 2026 at 8:32 AM <[email protected]> wrote:

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

Same comment as per Bay Trail version.

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

PATCH 4/5 pinctrl: baytrail: Propagate errors from optional IRQ lookup

In reply to [email protected]

From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

---
 drivers/pinctrl/intel/pinctrl-baytrail.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pinctrl/intel/pinctrl-baytrail.c +2 -0
index b733ec31ad9d..bcc77bf6e811 100644
@@ -1533,6 +1533,8 @@ static int byt_gpio_probe(struct intel_pinctrl *vg)
 
 	/* set up interrupts  */
 	irq = platform_get_irq_optional(pdev, 0);
+	if (irq < 0 && irq != -ENXIO)
+		return irq;
 	if (irq > 0) {
 		struct gpio_irq_chip *girq;
 
Signature · 1 line
2.43.0
#8 lore raw

Re: [PATCH 4/5] pinctrl: baytrail: Propagate errors from optional IRQ lookup

Quoted 9 lines · On Mon, Aug 10, 2026 at 8:32 AM <[email protected]> wrote:

From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

On this platform (ACPI-based) there are no other possibilities to get something meaningful that can be returned (deferred probe). The rest of the error codes will actually regress since the user won't have a pin control driver at all, instead of having it IRQ-less (which is doubtfully useful, though). Have you considered that scenario?

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

PATCH 5/5 pinctrl: bcm: iproc-gpio: Propagate errors from optional IRQ lookup

In reply to [email protected]

From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

---
 drivers/pinctrl/bcm/pinctrl-iproc-gpio.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pinctrl/bcm/pinctrl-iproc-gpio.c +2 -0
index e20f7dc79d43..025476e251c2 100644
@@ -873,6 +873,8 @@ static int iproc_gpio_probe(struct platform_device *pdev)
 
 	/* optional GPIO interrupt support */
 	irq = platform_get_irq_optional(pdev, 0);
+	if (irq < 0 && irq != -ENXIO)
+		return irq;
 	if (irq > 0) {
 		struct gpio_irq_chip *girq;
 
Signature · 1 line
2.43.0
#10 lore raw

Re: [PATCH 5/5] pinctrl: bcm: iproc-gpio: Propagate errors from optional IRQ lookup

Quoted 9 lines · On Mon, Aug 10, 2026 at 8:32 AM <[email protected]> wrote:

From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

...

drivers/pinctrl/bcm/pinctrl-iproc-gpio.c static int iproc_gpio_probe(struct platform_device *pdev) · line 877

Quoted 4 lines
        /* optional GPIO interrupt support */
        irq = platform_get_irq_optional(pdev, 0);
drivers/pinctrl/bcm/pinctrl-iproc-gpio.c +2 -0
+       if (irq < 0 && irq != -ENXIO)
+               return irq;

Here and everywhere else in the similar contributions you made all over the kernel:

Quoted 2 lines
        if (irq > 0) {
                struct gpio_irq_chip *girq;

Use the 'else' branch instead of the above.

} else if (irq != -ENXIO) {
return irq;

But before doing that, check carefully if this is really what we want to have and how it will affect the driver behaviour in such a case.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw
In reply to [email protected]
Quoted 7 lines · On Mon, Aug 10, 2026 at 8:32 AM <[email protected]> wrote:

platform_get_irq_optional() returns a positive IRQ number on success or a negative error code on failure. For an optional IRQ, -ENXIO indicates that no optional IRQ is available, while other errors should be propagated.

Propagate all error codes returned by platform_get_irq_optional() other than -ENXIO.

Same comments. It may or may not be okay to have such a change. The less disruptive one is to check only for a deferred probe.

Signature · 2 lines
With Best Regards,
Andy Shevchenko