Patchwork [net-next,2/2] stmmac: Move the mdio_register/_unregister in probe/remove

login
register
mail settings
Submitter Giuseppe CAVALLARO
Date April 18, 2012, 8:28 a.m.
Message ID <1334737705-4508-2-git-send-email-peppe.cavallaro@st.com>
Download mbox | patch
Permalink /patch/153437/
State Superseded
Delegated to: David Miller
Headers show

Comments

Giuseppe CAVALLARO - April 18, 2012, 8:28 a.m.
From: Francesco Virlinzi <francesco.virlinzi@st.com>

This patch moves the mdio_register/_unregister in probe/remove
functions and this also is required when hibernation on disk
is done.

Signed-off-by: Francesco Virlinzi <francesco.virlinzi@st,com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st,com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a64f0d4..b6dce8f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -937,14 +937,6 @@  static int stmmac_open(struct net_device *dev)
 
 	stmmac_check_ether_addr(priv);
 
-	/* MDIO bus Registration */
-	ret = stmmac_mdio_register(dev);
-	if (ret < 0) {
-		pr_debug("%s: MDIO bus (id: %d) registration failed",
-			 __func__, priv->plat->bus_id);
-		goto open_clk_dis;
-	}
-
 #ifdef CONFIG_STMMAC_TIMER
 	priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL);
 	if (unlikely(priv->tm == NULL)) {
@@ -1067,7 +1059,9 @@  open_error:
 	if (priv->phydev)
 		phy_disconnect(priv->phydev);
 
+#ifdef CONFIG_STMMAC_TIMER
 open_clk_dis:
+#endif
 	stmmac_clk_disable(priv);
 	return ret;
 }
@@ -1120,7 +1114,6 @@  static int stmmac_release(struct net_device *dev)
 #ifdef CONFIG_STMMAC_DEBUG_FS
 	stmmac_exit_fs();
 #endif
-	stmmac_mdio_unregister(dev);
 	stmmac_clk_disable(priv);
 
 	return 0;
@@ -1932,6 +1925,14 @@  struct stmmac_priv *stmmac_dvr_probe(struct device *device,
 	else
 		priv->clk_csr = priv->plat->clk_csr;
 
+	/* MDIO bus Registration */
+	ret = stmmac_mdio_register(ndev);
+	if (ret < 0) {
+		pr_debug("%s: MDIO bus (id: %d) registration failed",
+			 __func__, priv->plat->bus_id);
+		goto error;
+	}
+
 	return priv;
 
 error:
@@ -1959,6 +1960,7 @@  int stmmac_dvr_remove(struct net_device *ndev)
 	priv->hw->dma->stop_tx(priv->ioaddr);
 
 	stmmac_set_mac(priv->ioaddr, false);
+	stmmac_mdio_unregister(ndev);
 	netif_carrier_off(ndev);
 	unregister_netdev(ndev);
 	free_netdev(ndev);