Skip to contentSkip to conversation

net: ethernet: ti: netcp_core: use for_each_available_child_of_node_scoped() in netcp_probe()

PATCH In review Manush Prajwal 2 participants 2 messages Aug 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: ethernet: ti: netcp_core: use for_each_available_child_of_node_scoped() in netcp_probe()

Rework the interfaces loop in netcp_probe() around for_each_available_child_of_node_scoped() instead of adding a manual of_node_put(child) at the probe_quit_interface error label, so the reference on the current child node is released automatically on every exit path from the loop, including the early goto on a netcp_create_interface() failure. child is never used outside the loop, so the now-unused outer child declaration is dropped along with it; no extra of_node_get() is needed.

---
v2: Rework around for_each_available_child_of_node_scoped() instead
of the manual of_node_put(child) from v1, per Andrew Lunn's review.

---
 drivers/net/ethernet/ti/netcp_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/netcp_core.c +2 -2
index eb8fc2e..fbc011f 100644
@@ -2204,7 +2204,7 @@ static int netcp_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct netcp_intf *netcp_intf, *netcp_tmp;
-	struct device_node *child, *interfaces;
+	struct device_node *interfaces;
 	struct netcp_device *netcp_device;
 	struct device *dev = &pdev->dev;
 	struct netcp_module *module;
@@ -2246,7 +2246,7 @@ static int netcp_probe(struct platform_device *pdev)
 		goto probe_quit;
 	}
 
-	for_each_available_child_of_node(interfaces, child) {
+	for_each_available_child_of_node_scoped(interfaces, child) {
 		ret = netcp_create_interface(netcp_device, child);
 		if (ret) {
 			dev_err(dev, "could not create interface(%pOFn)\n",

--
2.46.2.windows.1

#1 lore raw
Quoted 24 lines · Manush Prajwal

Rework the interfaces loop in netcp_probe() around for_each_available_child_of_node_scoped() instead of adding a manual of_node_put(child) at the probe_quit_interface error label, so the reference on the current child node is released automatically on every exit path from the loop, including the early goto on a netcp_create_interface() failure. child is never used outside the loop, so the now-unused outer child declaration is dropped along with it; no extra of_node_get() is needed.

---
v2: Rework around for_each_available_child_of_node_scoped() instead
of the manual of_node_put(child) from v1, per Andrew Lunn's review.

---
 drivers/net/ethernet/ti/netcp_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/netcp_core.c +0 -0
index eb8fc2e..fbc011f 100644

drivers/net/ethernet/ti/netcp_core.c static int netcp_probe(struct platform_device *pdev) · line 2210

Quoted 8 lines
drivers/net/ethernet/ti/netcp_core.c +1 -1
@@ -2204,7 +2204,7 @@ static int netcp_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
 	struct netcp_intf *netcp_intf, *netcp_tmp;
-	struct device_node *child, *interfaces;
+	struct device_node *interfaces;
 	struct netcp_device *netcp_device;
 	struct device *dev = &pdev->dev;
 	struct netcp_module *module;

Reverse Christmas tree. You need to keep these sorted, long first, shortest last.

Andrew