mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 16:12:59 +02:00
net: dsa: sja1105: 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: Jinjie Ruan <ruanjinjie@huawei.com> Link: https://patch.msgid.link/20240820075047.681223-1-ruanjinjie@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
e58c3f3d51
commit
2d86ecb64b
|
|
@ -1188,9 +1188,8 @@ static int sja1105_parse_ports_node(struct sja1105_private *priv,
|
|||
struct device_node *ports_node)
|
||||
{
|
||||
struct device *dev = &priv->spidev->dev;
|
||||
struct device_node *child;
|
||||
|
||||
for_each_available_child_of_node(ports_node, child) {
|
||||
for_each_available_child_of_node_scoped(ports_node, child) {
|
||||
struct device_node *phy_node;
|
||||
phy_interface_t phy_mode;
|
||||
u32 index;
|
||||
|
|
@ -1200,7 +1199,6 @@ static int sja1105_parse_ports_node(struct sja1105_private *priv,
|
|||
if (of_property_read_u32(child, "reg", &index) < 0) {
|
||||
dev_err(dev, "Port number not defined in device tree "
|
||||
"(property \"reg\")\n");
|
||||
of_node_put(child);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
|
@ -1210,7 +1208,6 @@ static int sja1105_parse_ports_node(struct sja1105_private *priv,
|
|||
dev_err(dev, "Failed to read phy-mode or "
|
||||
"phy-interface-type property for port %d\n",
|
||||
index);
|
||||
of_node_put(child);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
|
@ -1219,7 +1216,6 @@ static int sja1105_parse_ports_node(struct sja1105_private *priv,
|
|||
if (!of_phy_is_fixed_link(child)) {
|
||||
dev_err(dev, "phy-handle or fixed-link "
|
||||
"properties missing!\n");
|
||||
of_node_put(child);
|
||||
return -ENODEV;
|
||||
}
|
||||
/* phy-handle is missing, but fixed-link isn't.
|
||||
|
|
@ -1233,10 +1229,8 @@ static int sja1105_parse_ports_node(struct sja1105_private *priv,
|
|||
priv->phy_mode[index] = phy_mode;
|
||||
|
||||
err = sja1105_parse_rgmii_delays(priv, index, child);
|
||||
if (err) {
|
||||
of_node_put(child);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user