From: phucduc.bui@gmail.com
To: Kamal Dasu <kamal.dasu@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Andi Shyti <andi.shyti@kernel.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: Wolfram Sang <wsa@kernel.org>, bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH 3/3] i2c: brcmstb: Correct optional IRQ handling
Date: Thu, 13 Aug 2026 15:52:13 +0700 [thread overview]
Message-ID: <20260813085213.44001-4-phucduc.bui@gmail.com> (raw)
In-Reply-To: <20260813085213.44001-1-phucduc.bui@gmail.com>
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
prev parent reply other threads:[~2026-08-13 8:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260813085213.44001-4-phucduc.bui@gmail.com \
--to=phucduc.bui@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=florian.fainelli@broadcom.com \
--cc=kamal.dasu@broadcom.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox