Commit 81b4eb62 authored by Jinjie Ruan's avatar Jinjie Ruan Committed by Paolo Abeni
Browse files

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: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent c55f34a7
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -774,8 +774,8 @@ static int sun8i_dwmac_reset(struct stmmac_priv *priv)
static int get_ephy_nodes(struct stmmac_priv *priv)
{
	struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
	struct device_node *mdio_mux, *iphynode;
	struct device_node *mdio_internal;
	struct device_node *mdio_mux;
	int ret;

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

	/* Seek for internal PHY */
	for_each_child_of_node(mdio_internal, iphynode) {
	for_each_child_of_node_scoped(mdio_internal, iphynode) {
		gmac->ephy_clk = of_clk_get(iphynode, 0);
		if (IS_ERR(gmac->ephy_clk))
			continue;
@@ -801,14 +801,12 @@ static int get_ephy_nodes(struct stmmac_priv *priv)
		if (IS_ERR(gmac->rst_ephy)) {
			ret = PTR_ERR(gmac->rst_ephy);
			if (ret == -EPROBE_DEFER) {
				of_node_put(iphynode);
				of_node_put(mdio_internal);
				return ret;
			}
			continue;
		}
		dev_info(priv->device, "Found internal PHY node\n");
		of_node_put(iphynode);
		of_node_put(mdio_internal);
		return 0;
	}