@@ -774,19 +774,17 @@ 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_internal;
- struct device_node *mdio_mux;
int ret;
- mdio_mux = of_get_child_by_name(priv->device->of_node, "mdio-mux");
+ struct device_node *mdio_mux __free(device_node) =
+ of_get_child_by_name(priv->device->of_node, "mdio-mux");
if (!mdio_mux) {
dev_err(priv->device, "Cannot get mdio-mux node\n");
return -ENODEV;
}
- mdio_internal = of_get_compatible_child(mdio_mux,
- "allwinner,sun8i-h3-mdio-internal");
- of_node_put(mdio_mux);
+ struct device_node *mdio_internal __free(device_node) =
+ of_get_compatible_child(mdio_mux, "allwinner,sun8i-h3-mdio-internal");
if (!mdio_internal) {
dev_err(priv->device, "Cannot get internal_mdio node\n");
return -ENODEV;
@@ -800,18 +798,14 @@ static int get_ephy_nodes(struct stmmac_priv *priv)
gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL);
if (IS_ERR(gmac->rst_ephy)) {
ret = PTR_ERR(gmac->rst_ephy);
- if (ret == -EPROBE_DEFER) {
- of_node_put(mdio_internal);
+ if (ret == -EPROBE_DEFER)
return ret;
- }
continue;
}
dev_info(priv->device, "Found internal PHY node\n");
- of_node_put(mdio_internal);
return 0;
}
- of_node_put(mdio_internal);
return -ENODEV;
}