@@ -380,7 +380,6 @@ struct ag71xx {
int mac_idx;
struct reset_control *mdio_reset;
- struct mii_bus *mii_bus;
struct clk *clk_mdio;
struct clk *clk_eth;
};
@@ -689,7 +688,6 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
int err;
np = dev->of_node;
- ag->mii_bus = NULL;
ag->clk_mdio = devm_clk_get_enabled(dev, "mdio");
if (IS_ERR(ag->clk_mdio)) {
@@ -723,22 +721,14 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
}
mnp = of_get_child_by_name(np, "mdio");
- err = of_mdiobus_register(mii_bus, mnp);
+ err = devm_of_mdiobus_register(dev, mii_bus, mnp);
of_node_put(mnp);
if (err)
return err;
- ag->mii_bus = mii_bus;
-
return 0;
}
-static void ag71xx_mdio_remove(struct ag71xx *ag)
-{
- if (ag->mii_bus)
- mdiobus_unregister(ag->mii_bus);
-}
-
static void ag71xx_hw_stop(struct ag71xx *ag)
{
/* disable all interrupts and stop the rx/tx engine */
@@ -1924,14 +1914,14 @@ static int ag71xx_probe(struct platform_device *pdev)
err = ag71xx_phylink_setup(ag);
if (err) {
netif_err(ag, probe, ndev, "failed to setup phylink (%d)\n", err);
- goto err_mdio_remove;
+ return err;
}
err = register_netdev(ndev);
if (err) {
netif_err(ag, probe, ndev, "unable to register net device\n");
platform_set_drvdata(pdev, NULL);
- goto err_mdio_remove;
+ return err;
}
netif_info(ag, probe, ndev, "Atheros AG71xx at 0x%08lx, irq %d, mode:%s\n",
@@ -1939,23 +1929,16 @@ static int ag71xx_probe(struct platform_device *pdev)
phy_modes(ag->phy_if_mode));
return 0;
-
-err_mdio_remove:
- ag71xx_mdio_remove(ag);
- return err;
}
static void ag71xx_remove(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);
- struct ag71xx *ag;
if (!ndev)
return;
- ag = netdev_priv(ndev);
unregister_netdev(ndev);
- ag71xx_mdio_remove(ag);
platform_set_drvdata(pdev, NULL);
}
Allows removing ag71xx_mdio_remove. Removed ag.mii_bus variable. Local one can be used with devm. Easier to reason about as mii_bus is only used here now. Also shrinks the struct slightly. Signed-off-by: Rosen Penev <rosenp@gmail.com> --- drivers/net/ethernet/atheros/ag71xx.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-)