Skip to content

Commit

Permalink
sh_eth: Register MDIO bus before registering the network device
Browse files Browse the repository at this point in the history
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: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Laurent Pinchart authored and David S. Miller committed Mar 20, 2014
1 parent bd920ff commit daacf03
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions drivers/net/ethernet/renesas/sh_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2891,20 +2891,20 @@ 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);

/* network device register */
ret = register_netdev(ndev);
if (ret)
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 */
netdev_info(ndev, "Base address at 0x%x, %pM, IRQ %d.\n",
(u32)ndev->base_addr, ndev->dev_addr, ndev->irq);
Expand All @@ -2913,11 +2913,9 @@ static int sh_eth_drv_probe(struct platform_device *pdev)

return ret;

out_unregister:
unregister_netdev(ndev);

out_napi_del:
netif_napi_del(&mdp->napi);
sh_mdio_release(mdp);

out_release:
/* net_dev free */
Expand All @@ -2933,9 +2931,9 @@ static int sh_eth_drv_remove(struct platform_device *pdev)
struct net_device *ndev = platform_get_drvdata(pdev);
struct sh_eth_private *mdp = netdev_priv(ndev);

sh_mdio_release(mdp);
unregister_netdev(ndev);
netif_napi_del(&mdp->napi);
sh_mdio_release(mdp);
pm_runtime_disable(&pdev->dev);
free_netdev(ndev);

Expand Down

0 comments on commit daacf03

Please sign in to comment.