]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
net: stmmac: dwmac-sun8i: fix OF child-node lookup
[mirror_ubuntu-bionic-kernel.git] / drivers / net / ethernet / stmicro / stmmac / dwmac-sun8i.c
index 9eb7f65d8000d28190da780587dba562aed72152..0471e230163b994e739dec3fe02630c1fd3436c8 100644 (file)
@@ -654,8 +654,9 @@ static int get_ephy_nodes(struct stmmac_priv *priv)
                return -ENODEV;
        }
 
-       mdio_internal = of_find_compatible_node(mdio_mux, NULL,
+       mdio_internal = of_get_compatible_child(mdio_mux,
                                                "allwinner,sun8i-h3-mdio-internal");
+       of_node_put(mdio_mux);
        if (!mdio_internal) {
                dev_err(priv->device, "Cannot get internal_mdio node\n");
                return -ENODEV;
@@ -669,13 +670,20 @@ 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)
+                       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;
        }
+
+       of_node_put(mdio_internal);
        return -ENODEV;
 }