Commit e58c3f3d authored by Jinjie Ruan's avatar Jinjie Ruan Committed by Jakub Kicinski

net: dsa: ocelot: Simplify with scoped for each OF child loop

Use scoped for_each_available_child_of_node_scoped() when iterating over
device nodes to make code a bit simpler.
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
Link: https://patch.msgid.link/20240820074805.680674-1-ruanjinjie@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 488d3464
...@@ -1265,9 +1265,8 @@ static int felix_parse_ports_node(struct felix *felix, ...@@ -1265,9 +1265,8 @@ static int felix_parse_ports_node(struct felix *felix,
phy_interface_t *port_phy_modes) phy_interface_t *port_phy_modes)
{ {
struct device *dev = felix->ocelot.dev; struct device *dev = felix->ocelot.dev;
struct device_node *child;
for_each_available_child_of_node(ports_node, child) { for_each_available_child_of_node_scoped(ports_node, child) {
phy_interface_t phy_mode; phy_interface_t phy_mode;
u32 port; u32 port;
int err; int err;
...@@ -1276,7 +1275,6 @@ static int felix_parse_ports_node(struct felix *felix, ...@@ -1276,7 +1275,6 @@ static int felix_parse_ports_node(struct felix *felix,
if (of_property_read_u32(child, "reg", &port) < 0) { if (of_property_read_u32(child, "reg", &port) < 0) {
dev_err(dev, "Port number not defined in device tree " dev_err(dev, "Port number not defined in device tree "
"(property \"reg\")\n"); "(property \"reg\")\n");
of_node_put(child);
return -ENODEV; return -ENODEV;
} }
...@@ -1286,7 +1284,6 @@ static int felix_parse_ports_node(struct felix *felix, ...@@ -1286,7 +1284,6 @@ static int felix_parse_ports_node(struct felix *felix,
dev_err(dev, "Failed to read phy-mode or " dev_err(dev, "Failed to read phy-mode or "
"phy-interface-type property for port %d\n", "phy-interface-type property for port %d\n",
port); port);
of_node_put(child);
return -ENODEV; return -ENODEV;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment