[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250205173918.600037-3-herve.codina@bootlin.com>
Date: Wed, 5 Feb 2025 18:39:15 +0100
From: Herve Codina <herve.codina@...tlin.com>
To: Wolfram Sang <wsa+renesas@...g-engineering.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>
Cc: linux-i2c@...r.kernel.org,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
Luca Ceresoli <luca.ceresoli@...tlin.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Herve Codina <herve.codina@...tlin.com>
Subject: [RFC PATCH 2/3] i2c: i2c-core-of: Move children registration in a dedicated function
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@...tlin.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
Powered by blists - more mailing lists