struct stmmac_priv *priv = netdev_priv(dev);
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
priv->tm = kzalloc(sizeof(struct stmmac_timer *), GFP_KERNEL);
- if (unlikely(priv->tm == NULL)) {
- ret = -ENOMEM;
- goto open_clk_dis;
- }
+ if (unlikely(priv->tm == NULL))
+ return -ENOMEM;
priv->tm->freq = tmrate;
} else
priv->tm->enable = 1;
#endif
+ stmmac_clk_enable(priv);
+
+ stmmac_check_ether_addr(priv);
+
ret = stmmac_init_phy(dev);
if (unlikely(ret)) {
pr_err("%s: Cannot attach to PHY (error: %d)\n", __func__, ret);
if (priv->phydev)
phy_disconnect(priv->phydev);
-open_clk_dis:
stmmac_clk_disable(priv);
+
return ret;
}
#ifdef CONFIG_STMMAC_DEBUG_FS
stmmac_exit_fs();
#endif
- stmmac_mdio_unregister(dev);
stmmac_clk_disable(priv);
return 0;
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:
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);