Commit 4bfcbd7a authored by Francesco Virlinzi's avatar Francesco Virlinzi Committed by David S. Miller

stmmac: Move the mdio_register/_unregister in probe/remove

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: default avatarFrancesco Virlinzi <francesco.virlinzi@st,com>
Signed-off-by: default avatarGiuseppe Cavallaro <peppe.cavallaro@st,com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3256251f
...@@ -933,24 +933,10 @@ static int stmmac_open(struct net_device *dev) ...@@ -933,24 +933,10 @@ static int stmmac_open(struct net_device *dev)
struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_priv *priv = netdev_priv(dev);
int ret; int ret;
stmmac_clk_enable(priv);
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 #ifdef CONFIG_STMMAC_TIMER
priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL); priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL);
if (unlikely(priv->tm == NULL)) { if (unlikely(priv->tm == NULL))
ret = -ENOMEM; return -ENOMEM;
goto open_clk_dis;
}
priv->tm->freq = tmrate; priv->tm->freq = tmrate;
...@@ -964,6 +950,10 @@ static int stmmac_open(struct net_device *dev) ...@@ -964,6 +950,10 @@ static int stmmac_open(struct net_device *dev)
} else } else
priv->tm->enable = 1; priv->tm->enable = 1;
#endif #endif
stmmac_clk_enable(priv);
stmmac_check_ether_addr(priv);
ret = stmmac_init_phy(dev); ret = stmmac_init_phy(dev);
if (unlikely(ret)) { if (unlikely(ret)) {
pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret); pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
...@@ -1067,8 +1057,8 @@ static int stmmac_open(struct net_device *dev) ...@@ -1067,8 +1057,8 @@ static int stmmac_open(struct net_device *dev)
if (priv->phydev) if (priv->phydev)
phy_disconnect(priv->phydev); phy_disconnect(priv->phydev);
open_clk_dis:
stmmac_clk_disable(priv); stmmac_clk_disable(priv);
return ret; return ret;
} }
...@@ -1120,7 +1110,6 @@ static int stmmac_release(struct net_device *dev) ...@@ -1120,7 +1110,6 @@ static int stmmac_release(struct net_device *dev)
#ifdef CONFIG_STMMAC_DEBUG_FS #ifdef CONFIG_STMMAC_DEBUG_FS
stmmac_exit_fs(); stmmac_exit_fs();
#endif #endif
stmmac_mdio_unregister(dev);
stmmac_clk_disable(priv); stmmac_clk_disable(priv);
return 0; return 0;
...@@ -1932,6 +1921,14 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, ...@@ -1932,6 +1921,14 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
else else
priv->clk_csr = priv->plat->clk_csr; 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; return priv;
error: error:
...@@ -1959,6 +1956,7 @@ int stmmac_dvr_remove(struct net_device *ndev) ...@@ -1959,6 +1956,7 @@ int stmmac_dvr_remove(struct net_device *ndev)
priv->hw->dma->stop_tx(priv->ioaddr); priv->hw->dma->stop_tx(priv->ioaddr);
stmmac_set_mac(priv->ioaddr, false); stmmac_set_mac(priv->ioaddr, false);
stmmac_mdio_unregister(ndev);
netif_carrier_off(ndev); netif_carrier_off(ndev);
unregister_netdev(ndev); unregister_netdev(ndev);
free_netdev(ndev); free_netdev(ndev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment