mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
net: ag71xx: use devm for of_mdiobus_register
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> Link: https://patch.msgid.link/20240813170516.7301-3-rosenp@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
df37fcf58f
commit
8ef34bea8c
@ -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;
|
||||
};
|
||||
@ -697,7 +696,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)) {
|
||||
@ -731,22 +729,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 */
|
||||
@ -1932,14 +1922,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",
|
||||
@ -1947,23 +1937,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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user