All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-i2c@vger.kernel.org
Cc: Andi Shyti <andi.shyti@kernel.org>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCHv2 2/3] i2c: ibm_iic: get the irq early in probe
Date: Wed,  2 Sep 2026 14:24:55 -0700	[thread overview]
Message-ID: <20260902212456.289608-3-rosenp@gmail.com> (raw)
In-Reply-To: <20260902212456.289608-1-rosenp@gmail.com>

Use platform_get_irq() which can return -EPROBE_DEFER, unlike
irq_of_map_and_parse().

Check for iic_force_poll before doing so to avoid pointless work.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/i2c/busses/i2c-ibm_iic.c | 43 ++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 20421ebe73ab..8af666442952 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -648,31 +648,22 @@ static inline u8 iic_clckdiv(unsigned int opb)
 }
 
 static int iic_request_irq(struct platform_device *ofdev,
-				     struct ibm_iic_private *dev)
+			   struct ibm_iic_private *dev)
 {
-	struct device_node *np = ofdev->dev.of_node;
-	int irq;
-
-	if (iic_force_poll)
-		return 0;
-
-	irq = irq_of_parse_and_map(np, 0);
-	if (!irq) {
-		dev_err(&ofdev->dev, "irq_of_parse_and_map failed\n");
-		return 0;
-	}
+	int ret;
 
 	/* Disable interrupts until we finish initialization, assumes
 	 *  level-sensitive IRQ setup...
 	 */
 	iic_interrupt_mode(dev, 0);
-	if (request_irq(irq, iic_handler, 0, "IBM IIC", dev)) {
-		dev_err(&ofdev->dev, "request_irq %d failed\n", irq);
+	ret = request_irq(dev->irq, iic_handler, 0, "IBM IIC", dev)
+	if (ret) {
+		dev_err(&ofdev->dev, "request_irq %d failed\n", dev->irq);
 		/* Fallback to the polling mode */
-		return 0;
+		return ret;
 	}
 
-	return irq;
+	return ret;
 }
 
 /*
@@ -685,12 +676,23 @@ static int iic_probe(struct platform_device *ofdev)
 	struct i2c_adapter *adap;
 	void __iomem *vaddr;
 	const u32 *freq;
+	int irq;
 	int ret;
 
 	vaddr = devm_platform_ioremap_resource(ofdev, 0);
 	if (IS_ERR(vaddr))
 		return PTR_ERR(vaddr);
 
+	if (iic_force_poll) {
+		irq = 0;
+	} else {
+		irq = platform_get_irq(ofdev, 0);
+		if (irq == -EPROBE_DEFER)
+			return irq;
+		if (irq < 0)
+			dev_warn(&ofdev->dev, "using polling mode\n");
+	}
+
 	dev = kzalloc_obj(*dev);
 	if (!dev)
 		return -ENOMEM;
@@ -701,9 +703,12 @@ static int iic_probe(struct platform_device *ofdev)
 
 	init_waitqueue_head(&dev->wq);
 
-	dev->irq = iic_request_irq(ofdev, dev);
-	if (!dev->irq)
-		dev_warn(&ofdev->dev, "using polling mode\n");
+	dev->irq = irq;
+	if (dev->irq > 0) {
+		ret = iic_request_irq(ofdev, dev, irq);
+		if (ret)
+			dev->irq = 0;
+	}
 
 	/* Board specific settings */
 	if (iic_force_fast || of_get_property(np, "fast-mode", NULL))
-- 
2.55.0


  parent reply	other threads:[~2026-09-02 21:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 21:24 [PATCHv2 0/3] use devm and get irq in probe Rosen Penev
2026-09-02 21:24 ` [PATCHv2 1/3] i2c: ibm_iic: ioremap with platform pointer Rosen Penev
2026-09-02 21:24 ` Rosen Penev [this message]
2026-09-02 21:24 ` [PATCHv2 3/3] i2c: ibm_iic: use devm for main allocation Rosen Penev

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=20260902212456.289608-3-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=andi.shyti@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.