mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-04 04:04:19 +00:00
net: macb: Probe MDIO bus before registering netdev
The current sequence makes us register for a network device prior to registering and probing the MDIO bus which could lead to some unwanted consequences, like a thread of execution calling into ndo_open before register_netdev() returns, while the MDIO bus is not ready yet. Rework the sequence to register for the MDIO bus, and therefore attach to a PHY prior to calling register_netdev(), which implies reworking the error path a bit. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b365d955f3
commit
cf6696608a
@ -441,7 +441,7 @@ static int macb_mii_init(struct macb *bp)
|
||||
snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
|
||||
bp->pdev->name, bp->pdev->id);
|
||||
bp->mii_bus->priv = bp;
|
||||
bp->mii_bus->parent = &bp->dev->dev;
|
||||
bp->mii_bus->parent = &bp->pdev->dev;
|
||||
pdata = dev_get_platdata(&bp->pdev->dev);
|
||||
|
||||
dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
|
||||
@ -3020,29 +3020,36 @@ static int macb_probe(struct platform_device *pdev)
|
||||
if (err)
|
||||
goto err_out_free_netdev;
|
||||
|
||||
err = macb_mii_init(bp);
|
||||
if (err)
|
||||
goto err_out_free_netdev;
|
||||
|
||||
phydev = bp->phy_dev;
|
||||
|
||||
netif_carrier_off(dev);
|
||||
|
||||
err = register_netdev(dev);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
|
||||
goto err_out_unregister_netdev;
|
||||
goto err_out_unregister_mdio;
|
||||
}
|
||||
|
||||
err = macb_mii_init(bp);
|
||||
if (err)
|
||||
goto err_out_unregister_netdev;
|
||||
|
||||
netif_carrier_off(dev);
|
||||
phy_attached_info(phydev);
|
||||
|
||||
netdev_info(dev, "Cadence %s rev 0x%08x at 0x%08lx irq %d (%pM)\n",
|
||||
macb_is_gem(bp) ? "GEM" : "MACB", macb_readl(bp, MID),
|
||||
dev->base_addr, dev->irq, dev->dev_addr);
|
||||
|
||||
phydev = bp->phy_dev;
|
||||
phy_attached_info(phydev);
|
||||
|
||||
return 0;
|
||||
|
||||
err_out_unregister_netdev:
|
||||
unregister_netdev(dev);
|
||||
err_out_unregister_mdio:
|
||||
phy_disconnect(bp->phy_dev);
|
||||
mdiobus_unregister(bp->mii_bus);
|
||||
mdiobus_free(bp->mii_bus);
|
||||
|
||||
/* Shutdown the PHY if there is a GPIO reset */
|
||||
if (bp->reset_gpio)
|
||||
gpiod_set_value(bp->reset_gpio, 0);
|
||||
|
||||
err_out_free_netdev:
|
||||
free_netdev(dev);
|
||||
|
Loading…
Reference in New Issue
Block a user