mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herve Codina <herve.codina@bootlin.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>
Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Luca Ceresoli <luca.ceresoli@bootlin.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Herve Codina <herve.codina@bootlin.com>
Subject: [RFC PATCH 2/3] i2c: i2c-core-of: Move children registration in a dedicated function
Date: Wed,  5 Feb 2025 18:39:15 +0100	[thread overview]
Message-ID: <20250205173918.600037-3-herve.codina@bootlin.com> (raw)
In-Reply-To: <20250205173918.600037-1-herve.codina@bootlin.com>

of_i2c_register_devices() perform the loop for registering child devices.

In order to prepare the support for i2c bus extensions, extract this
registration loop and move it in a dedicated function.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 drivers/i2c/i2c-core-of.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c
index a6c407d36800..b4c9db137f5a 100644
--- a/drivers/i2c/i2c-core-of.c
+++ b/drivers/i2c/i2c-core-of.c
@@ -82,21 +82,15 @@ static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
 	return client;
 }
 
-void of_i2c_register_devices(struct i2c_adapter *adap)
+static void of_i2c_register_children(struct i2c_adapter *adap,
+				     struct device_node *bus)
 {
-	struct device_node *bus, *node;
 	struct i2c_client *client;
+	struct device_node *node;
 
-	/* Only register child devices if the adapter has a node pointer set */
-	if (!adap->dev.of_node)
-		return;
-
-	dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
-
-	bus = of_get_child_by_name(adap->dev.of_node, "i2c-bus");
-	if (!bus)
-		bus = of_node_get(adap->dev.of_node);
+	dev_dbg(&adap->dev, "of_i2c: walking child nodes from %pOF\n", bus);
 
+	/* Register device directly attached to this bus */
 	for_each_available_child_of_node(bus, node) {
 		if (of_node_test_and_set_flag(node, OF_POPULATED))
 			continue;
@@ -109,7 +103,21 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
 			of_node_clear_flag(node, OF_POPULATED);
 		}
 	}
+}
+
+void of_i2c_register_devices(struct i2c_adapter *adap)
+{
+	struct device_node *bus;
+
+	/* Only register child devices if the adapter has a node pointer set */
+	if (!adap->dev.of_node)
+		return;
+
+	bus = of_get_child_by_name(adap->dev.of_node, "i2c-bus");
+	if (!bus)
+		bus = of_node_get(adap->dev.of_node);
 
+	of_i2c_register_children(adap, bus);
 	of_node_put(bus);
 }
 
-- 
2.47.1


  parent reply	other threads:[~2025-02-05 17:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 17:39 [RFC PATCH 0/3] i2c: Introduce i2c bus extensions Herve Codina
2025-02-05 17:39 ` [RFC PATCH 1/3] i2c: core: Follow i2c-parent when retrieving an adapter from node Herve Codina
2025-04-03  9:03   ` Wolfram Sang
2025-04-03 10:50     ` Herve Codina
2025-04-03 11:20       ` Wolfram Sang
2025-04-03 12:21         ` Herve Codina
2025-02-05 17:39 ` Herve Codina [this message]
2025-04-03  9:07   ` [RFC PATCH 2/3] i2c: i2c-core-of: Move children registration in a dedicated function Wolfram Sang
2025-04-03 10:51     ` Herve Codina
2025-02-05 17:39 ` [RFC PATCH 3/3] i2c: i2c-core-of: Handle i2c bus extensions Herve Codina
2025-02-12  5:54   ` Krzysztof Kozlowski
2025-02-12  9:45     ` Herve Codina
2025-04-03  9:09   ` Wolfram Sang
2025-02-19 13:38 ` [RFC PATCH 0/3] i2c: Introduce " Herve Codina
2025-03-20 12:49 ` Wolfram Sang
2025-03-20 16:31   ` Luca Ceresoli
2025-03-20 21:37     ` Wolfram Sang
2025-04-03  9:15 ` Wolfram Sang
2025-06-12  7:52 ` Ayush Singh
2025-06-13  7:30   ` Herve Codina
2025-07-03 11:26     ` Ayush Singh
2025-07-03 15:19       ` Herve Codina

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=20250205173918.600037-3-herve.codina@bootlin.com \
    --to=herve.codina@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=robh@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wsa+renesas@sang-engineering.com \
    /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

Powered by JetHome