Skip to content

Commit 7ac5ddd

Browse files
aspeedJackyPaolo Abeni
authored andcommitted
net: ftgmac100: Use devm_mdiobus_alloc/devm_of_mdiobus_register
Make use of devm_ methods to allocate and register mdiobus to simplify cleanup. Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com> Link: https://patch.msgid.link/20260206-ftgmac-cleanup-v5-15-ad28a9067ea7@aspeedtech.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 201dddf commit 7ac5ddd

1 file changed

Lines changed: 4 additions & 22 deletions

File tree

drivers/net/ethernet/faraday/ftgmac100.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,7 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
17211721
u32 reg;
17221722

17231723
/* initialize mdio bus */
1724-
priv->mii_bus = mdiobus_alloc();
1724+
priv->mii_bus = devm_mdiobus_alloc(priv->dev);
17251725
if (!priv->mii_bus)
17261726
return -EIO;
17271727

@@ -1747,19 +1747,14 @@ static int ftgmac100_setup_mdio(struct net_device *netdev)
17471747

17481748
mdio_np = of_get_child_by_name(np, "mdio");
17491749

1750-
err = of_mdiobus_register(priv->mii_bus, mdio_np);
1750+
err = devm_of_mdiobus_register(priv->dev, priv->mii_bus, mdio_np);
1751+
of_node_put(mdio_np);
17511752
if (err) {
17521753
dev_err(priv->dev, "Cannot register MDIO bus!\n");
1753-
goto err_register_mdiobus;
1754+
return err;
17541755
}
17551756

1756-
of_node_put(mdio_np);
1757-
17581757
return 0;
1759-
1760-
err_register_mdiobus:
1761-
mdiobus_free(priv->mii_bus);
1762-
return err;
17631758
}
17641759

17651760
static void ftgmac100_phy_disconnect(struct net_device *netdev)
@@ -1778,17 +1773,6 @@ static void ftgmac100_phy_disconnect(struct net_device *netdev)
17781773
fixed_phy_unregister(phydev);
17791774
}
17801775

1781-
static void ftgmac100_destroy_mdio(struct net_device *netdev)
1782-
{
1783-
struct ftgmac100 *priv = netdev_priv(netdev);
1784-
1785-
if (!priv->mii_bus)
1786-
return;
1787-
1788-
mdiobus_unregister(priv->mii_bus);
1789-
mdiobus_free(priv->mii_bus);
1790-
}
1791-
17921776
static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
17931777
{
17941778
if (unlikely(nd->state != ncsi_dev_state_functional))
@@ -2092,7 +2076,6 @@ static int ftgmac100_probe(struct platform_device *pdev)
20922076
ftgmac100_phy_disconnect(netdev);
20932077
if (priv->ndev)
20942078
ncsi_unregister_dev(priv->ndev);
2095-
ftgmac100_destroy_mdio(netdev);
20962079
return err;
20972080
}
20982081

@@ -2114,7 +2097,6 @@ static void ftgmac100_remove(struct platform_device *pdev)
21142097
cancel_work_sync(&priv->reset_task);
21152098

21162099
ftgmac100_phy_disconnect(netdev);
2117-
ftgmac100_destroy_mdio(netdev);
21182100
}
21192101

21202102
static const struct ftgmac100_match_data ftgmac100_match_data_ast2400 = {

0 commit comments

Comments
 (0)