bf70cee
From 44f947bb8ef5f4add9f2d84e1ff53afd8f2f5537 Mon Sep 17 00:00:00 2001
bf70cee
From: Peter Robinson <pbrobinson@gmail.com>
bf70cee
Date: Wed, 16 Mar 2016 15:21:44 +0000
bf70cee
Subject: [PATCH 1/2] Revert "stmmac: Fix 'eth0: No PHY found' regression"
bf70cee
bf70cee
This reverts commit 88f8b1bb41c6208f81b6a480244533ded7b59493.
bf70cee
---
bf70cee
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c     | 11 ++++++++++-
bf70cee
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c |  9 +--------
bf70cee
 include/linux/stmmac.h                                |  1 -
bf70cee
 3 files changed, 11 insertions(+), 10 deletions(-)
bf70cee
bf70cee
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
bf70cee
index efb54f3..0faf163 100644
bf70cee
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
bf70cee
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
bf70cee
@@ -199,12 +199,21 @@ int stmmac_mdio_register(struct net_device *ndev)
bf70cee
 	struct stmmac_priv *priv = netdev_priv(ndev);
bf70cee
 	struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
bf70cee
 	int addr, found;
bf70cee
-	struct device_node *mdio_node = priv->plat->mdio_node;
bf70cee
+	struct device_node *mdio_node = NULL;
bf70cee
+	struct device_node *child_node = NULL;
bf70cee
 
bf70cee
 	if (!mdio_bus_data)
bf70cee
 		return 0;
bf70cee
 
bf70cee
 	if (IS_ENABLED(CONFIG_OF)) {
bf70cee
+		for_each_child_of_node(priv->device->of_node, child_node) {
bf70cee
+			if (of_device_is_compatible(child_node,
bf70cee
+						    "snps,dwmac-mdio")) {
bf70cee
+				mdio_node = child_node;
bf70cee
+				break;
bf70cee
+			}
bf70cee
+		}
bf70cee
+
bf70cee
 		if (mdio_node) {
bf70cee
 			netdev_dbg(ndev, "FOUND MDIO subnode\n");
bf70cee
 		} else {
bf70cee
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
bf70cee
index 4514ba7..6a52fa1 100644
bf70cee
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
bf70cee
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
bf70cee
@@ -110,7 +110,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
bf70cee
 	struct device_node *np = pdev->dev.of_node;
bf70cee
 	struct plat_stmmacenet_data *plat;
bf70cee
 	struct stmmac_dma_cfg *dma_cfg;
bf70cee
-	struct device_node *child_node = NULL;
bf70cee
 
bf70cee
 	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
bf70cee
 	if (!plat)
bf70cee
@@ -141,19 +140,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
bf70cee
 		plat->phy_node = of_node_get(np);
bf70cee
 	}
bf70cee
 
bf70cee
-	for_each_child_of_node(np, child_node)
bf70cee
-		if (of_device_is_compatible(child_node,	"snps,dwmac-mdio")) {
bf70cee
-			plat->mdio_node = child_node;
bf70cee
-			break;
bf70cee
-		}
bf70cee
-
bf70cee
 	/* "snps,phy-addr" is not a standard property. Mark it as deprecated
bf70cee
 	 * and warn of its use. Remove this when phy node support is added.
bf70cee
 	 */
bf70cee
 	if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0)
bf70cee
 		dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n");
bf70cee
 
bf70cee
-	if ((plat->phy_node && !of_phy_is_fixed_link(np)) || !plat->mdio_node)
bf70cee
+	if ((plat->phy_node && !of_phy_is_fixed_link(np)) || plat->phy_bus_name)
bf70cee
 		plat->mdio_bus_data = NULL;
bf70cee
 	else
bf70cee
 		plat->mdio_bus_data =
bf70cee
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
bf70cee
index 881a79d..eead8ab 100644
bf70cee
--- a/include/linux/stmmac.h
bf70cee
+++ b/include/linux/stmmac.h
bf70cee
@@ -100,7 +100,6 @@ struct plat_stmmacenet_data {
bf70cee
 	int interface;
bf70cee
 	struct stmmac_mdio_bus_data *mdio_bus_data;
bf70cee
 	struct device_node *phy_node;
bf70cee
-	struct device_node *mdio_node;
bf70cee
 	struct stmmac_dma_cfg *dma_cfg;
bf70cee
 	int clk_csr;
bf70cee
 	int has_gmac;
bf70cee
-- 
bf70cee
2.5.0
bf70cee