提交 daacf03f 编写于 作者: L Laurent Pinchart 提交者: David S. Miller

sh_eth: Register MDIO bus before registering the network device

Network API functions that rely on the MDIO bus can be called as soon as
the driver calls register_netdev(). Register the MDIO bus before the
network device to avoid race conditions.
Signed-off-by: NLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: NGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 bd920ff5
...@@ -2891,6 +2891,13 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ...@@ -2891,6 +2891,13 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
} }
} }
/* MDIO bus init */
ret = sh_mdio_init(mdp, pd);
if (ret) {
dev_err(&ndev->dev, "failed to initialise MDIO\n");
goto out_release;
}
netif_napi_add(ndev, &mdp->napi, sh_eth_poll, 64); netif_napi_add(ndev, &mdp->napi, sh_eth_poll, 64);
/* network device register */ /* network device register */
...@@ -2898,13 +2905,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ...@@ -2898,13 +2905,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
if (ret) if (ret)
goto out_napi_del; goto out_napi_del;
/* mdio bus init */
ret = sh_mdio_init(mdp, pd);
if (ret) {
dev_err(&ndev->dev, "failed to initialise MDIO\n");
goto out_unregister;
}
/* print device information */ /* print device information */
netdev_info(ndev, "Base address at 0x%x, %pM, IRQ %d.\n", netdev_info(ndev, "Base address at 0x%x, %pM, IRQ %d.\n",
(u32)ndev->base_addr, ndev->dev_addr, ndev->irq); (u32)ndev->base_addr, ndev->dev_addr, ndev->irq);
...@@ -2913,11 +2913,9 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ...@@ -2913,11 +2913,9 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
return ret; return ret;
out_unregister:
unregister_netdev(ndev);
out_napi_del: out_napi_del:
netif_napi_del(&mdp->napi); netif_napi_del(&mdp->napi);
sh_mdio_release(mdp);
out_release: out_release:
/* net_dev free */ /* net_dev free */
...@@ -2933,9 +2931,9 @@ static int sh_eth_drv_remove(struct platform_device *pdev) ...@@ -2933,9 +2931,9 @@ static int sh_eth_drv_remove(struct platform_device *pdev)
struct net_device *ndev = platform_get_drvdata(pdev); struct net_device *ndev = platform_get_drvdata(pdev);
struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_private *mdp = netdev_priv(ndev);
sh_mdio_release(mdp);
unregister_netdev(ndev); unregister_netdev(ndev);
netif_napi_del(&mdp->napi); netif_napi_del(&mdp->napi);
sh_mdio_release(mdp);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
free_netdev(ndev); free_netdev(ndev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册