* [PATCH 1/3] i2c: pca-platform: Handle errors from optional IRQ lookup
2026-08-13 8:52 [PATCH 0/3] Handle optional IRQs correctly phucduc.bui
@ 2026-08-13 8:52 ` phucduc.bui
2026-08-13 8:52 ` [PATCH 2/3] i2c: brcmstb: " phucduc.bui
2026-08-13 8:52 ` [PATCH 3/3] i2c: brcmstb: Correct optional IRQ handling phucduc.bui
2 siblings, 0 replies; 4+ messages in thread
From: phucduc.bui @ 2026-08-13 8:52 UTC (permalink / raw)
To: Kamal Dasu, Broadcom internal kernel review list, Andi Shyti,
Florian Fainelli, linux-i2c, linux-arm-kernel, linux-kernel
Cc: Wolfram Sang, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
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.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
drivers/i2c/busses/i2c-pca-platform.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index c0f35ebbe37d..63c8ca1f1870 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -139,8 +139,11 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
irq = platform_get_irq_optional(pdev, 0);
/* If irq is 0, we do polling. */
- if (irq < 0)
+ if (irq < 0) {
+ if (irq != -ENXIO)
+ return irq;
irq = 0;
+ }
i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL);
if (!i2c)
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/3] i2c: brcmstb: Handle errors from optional IRQ lookup
2026-08-13 8:52 [PATCH 0/3] Handle optional IRQs correctly phucduc.bui
2026-08-13 8:52 ` [PATCH 1/3] i2c: pca-platform: Handle errors from optional IRQ lookup phucduc.bui
@ 2026-08-13 8:52 ` phucduc.bui
2026-08-13 8:52 ` [PATCH 3/3] i2c: brcmstb: Correct optional IRQ handling phucduc.bui
2 siblings, 0 replies; 4+ messages in thread
From: phucduc.bui @ 2026-08-13 8:52 UTC (permalink / raw)
To: Kamal Dasu, Broadcom internal kernel review list, Andi Shyti,
Florian Fainelli, linux-i2c, linux-arm-kernel, linux-kernel
Cc: Wolfram Sang, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
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.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
drivers/i2c/busses/i2c-brcmstb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
index 5fa30e8926c5..91525a36e575 100644
--- a/drivers/i2c/busses/i2c-brcmstb.c
+++ b/drivers/i2c/busses/i2c-brcmstb.c
@@ -648,6 +648,8 @@ static int brcmstb_i2c_probe(struct platform_device *pdev)
/* Get the interrupt number */
dev->irq = platform_get_irq_optional(pdev, 0);
+ if (dev->irq < 0 && dev->irq != -ENXIO)
+ return dev->irq;
/* disable the bsc interrupt line */
brcmstb_i2c_enable_disable_irq(dev, INT_DISABLE);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] i2c: brcmstb: Correct optional IRQ handling
2026-08-13 8:52 [PATCH 0/3] Handle optional IRQs correctly phucduc.bui
2026-08-13 8:52 ` [PATCH 1/3] i2c: pca-platform: Handle errors from optional IRQ lookup phucduc.bui
2026-08-13 8:52 ` [PATCH 2/3] i2c: brcmstb: " phucduc.bui
@ 2026-08-13 8:52 ` phucduc.bui
2 siblings, 0 replies; 4+ messages in thread
From: phucduc.bui @ 2026-08-13 8:52 UTC (permalink / raw)
To: Kamal Dasu, Broadcom internal kernel review list, Andi Shyti,
Florian Fainelli, linux-i2c, linux-arm-kernel, linux-kernel
Cc: Wolfram Sang, bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
dev->irq is assigned from platform_get_irq_optional(), which returns a
non-zero interrupt number on success or a negative error number on
failure. Therefore, 0 is not a valid IRQ number.
Check for a positive IRQ number before requesting the IRQ instead of
treating 0 as a valid IRQ.
Also use a positive IRQ number when reporting the operating mode. The
driver sets dev->irq to -1 when devm_request_irq() fails, so the mode
check should only consider positive IRQ numbers as interrupt mode.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
drivers/i2c/busses/i2c-brcmstb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c
index 91525a36e575..3adc73f3d608 100644
--- a/drivers/i2c/busses/i2c-brcmstb.c
+++ b/drivers/i2c/busses/i2c-brcmstb.c
@@ -655,7 +655,7 @@ static int brcmstb_i2c_probe(struct platform_device *pdev)
brcmstb_i2c_enable_disable_irq(dev, INT_DISABLE);
/* register the ISR handler */
- if (dev->irq >= 0) {
+ if (dev->irq > 0) {
rc = devm_request_irq(&pdev->dev, dev->irq, brcmstb_i2c_isr,
IRQF_SHARED,
int_name ? int_name : pdev->name,
@@ -697,7 +697,7 @@ static int brcmstb_i2c_probe(struct platform_device *pdev)
dev_info(dev->device, "%s@%dhz registered in %s mode\n",
int_name ? int_name : " ", dev->clk_freq_hz,
- (dev->irq >= 0) ? "interrupt" : "polling");
+ (dev->irq > 0) ? "interrupt" : "polling");
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread