gpio: realtek-otto: Handle errors from optional IRQ lookup
Subsystems (2)
PATCH 1/4 gpio: realtek-otto: Handle 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. Other errors, such as -EPROBE_DEFER and -EINVAL, should be propagated so that the caller can handle them appropriately.
Propagate negative errors other than -ENXIO.
--- drivers/gpio/gpio-realtek-otto.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpio/gpio-realtek-otto.c +2 -0
@@ -423,6 +423,8 @@ static int realtek_gpio_probe(struct platform_device *pdev) ctrl->chip.gc.owner =THIS_MODULE ; irq =platform_get_irq_optional (pdev,0 ); +if (irq <0 && irq != -ENXIO ) +return irq;if (!(dev_flags &GPIO_INTERRUPTS_DISABLED ) && irq >0 ) { girq = &ctrl->chip.gc.irq;gpio_irq_chip_set_chip (girq, &realtek_gpio_irq_chip);
Signature · 1 line
2.43.0
PATCH 2/4 gpio: mlxbf3: Handle 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. Other errors, such as -EPROBE_DEFER and -EINVAL, should be propagated so that the caller can handle them appropriately.
Propagate negative errors other than -ENXIO.
--- drivers/gpio/gpio-mlxbf3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-mlxbf3.c +3 -1
@@ -231,7 +231,9 @@ static int mlxbf3_gpio_probe(struct platform_device *pdev) gc->add_pin_ranges = mlxbf3_gpio_add_pin_ranges; irq =platform_get_irq_optional (pdev,0 ); -if (irq >=0 ) { +if (irq <0 && irq != -ENXIO ) +return irq; +if (irq >0 ) { girq = &gs->chip.gc.irq;gpio_irq_chip_set_chip (girq, &gpio_mlxbf3_irqchip); girq->default_type =IRQ_TYPE_NONE ;
Signature · 1 line
2.43.0
PATCH 3/4 gpio: mlxbf2: Handle 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. Other errors, such as -EPROBE_DEFER and -EINVAL, should be propagated so that the caller can handle them appropriately.
Propagate negative errors other than -ENXIO.
--- drivers/gpio/gpio-mlxbf2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpio/gpio-mlxbf2.c +3 -1
@@ -394,7 +394,9 @@ mlxbf2_gpio_probe(struct platform_device *pdev) gc->owner =THIS_MODULE ; irq =platform_get_irq_optional (pdev,0 ); -if (irq >=0 ) { +if (irq <0 && irq != -ENXIO ) +return irq; +if (irq >0 ) { girq = &gs->chip.gc.irq;gpio_irq_chip_set_chip (girq, &mlxbf2_gpio_irq_chip); girq->handler = handle_simple_irq;
Signature · 1 line
2.43.0
PATCH 4/4 gpio: altera: Handle 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. Other errors, such as -EPROBE_DEFER and -EINVAL, should be propagated so that the caller can handle them appropriately.
Propagate negative errors other than -ENXIO.
--- drivers/gpio/gpio-altera.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpio-altera.c +4 -1
@@ -220,8 +220,11 @@ static int altera_gpio_probe(struct platform_device *pdev)return -ENOMEM ; mapped_irq =platform_get_irq_optional (pdev,0 ); -if (mapped_irq <0 ) +if (mapped_irq <0 ) { +if (irq != -ENXIO ) +return irq; goto skip_irq; + }if (device_property_read_u32 (dev,"altr,interrupt-type" , ®)) { dev_err(&pdev->dev,
Signature · 1 line
2.43.0
Bartosz Golaszewski
AppliedQuoted 9 lines · On Fri, 14 Aug 2026 11:30:25 +0700, [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,-ENXIOindicates that no optional IRQ is available. Other errors, such as -EPROBE_DEFER and-EINVAL, should be propagated so that the caller can handle them appropriately.Propagate negative errors other than
-ENXIO.[...]
Applied, thanks!
[1/4] gpio: realtek-otto: Handle errors from optional IRQ lookup
https://git.kernel.org/brgl/c/ef0d275786a3c98d1e52f1d4d89183c802af58db [2/4] gpio: mlxbf3: Handle errors from optional IRQ lookup https://git.kernel.org/brgl/c/53ffd779a094d5752551dea2ba7bc787aab29229 [3/4] gpio: mlxbf2: Handle errors from optional IRQ lookup https://git.kernel.org/brgl/c/d8aaf6b0fdc835d10c7def7775803b28ebfd4d81 [4/4] gpio: altera: Handle errors from optional IRQ lookup https://git.kernel.org/brgl/c/6e6e585b603e4f679c2a33c8f0954ec88b52fd7a
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
Quoted 11 lines · On Fri, Aug 14, 2026 at 6:30 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,-ENXIOindicates that no optional IRQ is available. Other errors, such as -EPROBE_DEFER and-EINVAL, should be propagated so that the caller can handle them appropriately.Propagate negative errors other than
-ENXIO.Signed-off-by bui duc phuc <[email protected]>
Looks good to me.
Yours,
Linus Walleij
Quoted 7 lines · On Fri, Aug 14, 2026 at 11:30:25AM +0700, [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,-ENXIOindicates that no optional IRQ is available. Other errors, such as -EPROBE_DEFER and-EINVAL, should be propagated so that the caller can handle them appropriately.Propagate negative errors other than
-ENXIO.
Have you read the discussion [1]?
It would be better to make platform_get_irq_optional() to be actually optional.
[1]: https://lore.kernel.org/lkml/[email protected]/
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi Andy,
Thank you for pointing me to the discussion.
Quoted 6 lines
Have you read the discussion [1]?
It would be better to makeplatform_get_irq_optional()to be actually optional.
However, Regardless of how the API might be redesigned in the future to return 0
or negative error codes, the fundamental requirement at the driver level remains
the same: real errors must be propagated properly.
This patch isn't concerned with the API style discussion, but rather with ensuring
that driver probe doesn't silently swallow genuine errors like -EPROBE_DEFER. Proper error reporting is necessary under any reasonable API design.
Best regards
Phuc
On Sun, Oct 04, 2026 at 08:08:18AM +0700, Bui Duc Phuc wrote:
...
Quoted 13 lines
Thank you for pointing me to the discussion.
Quoted 4 lines
Have you read the discussion [1]?
It would be better to makeplatform_get_irq_optional()to be actually optional.However, Regardless of how the API might be redesigned in the future to return 0
or negative error codes, the fundamental requirement at the driver level remains
the same: real errors must be propagated properly.
Quoted 4 lines
This patch isn't concerned with the API style discussion, but rather with ensuring
that driver probe doesn't silently swallow genuine errors like -EPROBE_DEFER. Proper error reporting is necessary under any reasonable API design.
Yes, but doing specific error handling is usually not a good idea as it adds ambiguity. Like -EINVAL was used to check if the device property is present or not at the time of trying to parse it. This was specifically clarified in the documentation [2]. This is just an example of why the checking over a certain error code is not good.
[2]: 70fa0c308aa2 ("device property: Document how to check for the property presence")
Signature · 2 lines
With Best Regards, Andy Shevchenko