Skip to content

Commit 81b4eb6

Browse files
Jinjie RuanPaolo Abeni
authored andcommitted
net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped()
Avoid need to manually handle of_node_put() by using for_each_child_of_node_scoped(), which can simplfy code. Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Signed-off-by: Jinjie Ruan <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent c55f34a commit 81b4eb6

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,8 @@ static int sun8i_dwmac_reset(struct stmmac_priv *priv)
774774
static int get_ephy_nodes(struct stmmac_priv *priv)
775775
{
776776
struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
777-
struct device_node *mdio_mux, *iphynode;
778777
struct device_node *mdio_internal;
778+
struct device_node *mdio_mux;
779779
int ret;
780780

781781
mdio_mux = of_get_child_by_name(priv->device->of_node, "mdio-mux");
@@ -793,22 +793,20 @@ static int get_ephy_nodes(struct stmmac_priv *priv)
793793
}
794794

795795
/* Seek for internal PHY */
796-
for_each_child_of_node(mdio_internal, iphynode) {
796+
for_each_child_of_node_scoped(mdio_internal, iphynode) {
797797
gmac->ephy_clk = of_clk_get(iphynode, 0);
798798
if (IS_ERR(gmac->ephy_clk))
799799
continue;
800800
gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL);
801801
if (IS_ERR(gmac->rst_ephy)) {
802802
ret = PTR_ERR(gmac->rst_ephy);
803803
if (ret == -EPROBE_DEFER) {
804-
of_node_put(iphynode);
805804
of_node_put(mdio_internal);
806805
return ret;
807806
}
808807
continue;
809808
}
810809
dev_info(priv->device, "Found internal PHY node\n");
811-
of_node_put(iphynode);
812810
of_node_put(mdio_internal);
813811
return 0;
814812
}

0 commit comments

Comments
 (0)