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