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@xxxxxxxxxxx> --- 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