Skip to content

Commit 93a6d4e

Browse files
nehebkuba-moo
authored andcommitted
net: ibm: emac: remove mii_bus with devm
Switching to devm management of mii_bus allows to remove mdiobus_unregister calls and thus avoids needing a mii_bus global struct member. Signed-off-by: Rosen Penev <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 969b002 commit 93a6d4e

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

drivers/net/ethernet/ibm/emac/core.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,6 +2581,7 @@ static const struct mii_phy_ops emac_dt_mdio_phy_ops = {
25812581
static int emac_dt_mdio_probe(struct emac_instance *dev)
25822582
{
25832583
struct device_node *mii_np;
2584+
struct mii_bus *bus;
25842585
int res;
25852586

25862587
mii_np = of_get_child_by_name(dev->ofdev->dev.of_node, "mdio");
@@ -2594,23 +2595,23 @@ static int emac_dt_mdio_probe(struct emac_instance *dev)
25942595
goto put_node;
25952596
}
25962597

2597-
dev->mii_bus = devm_mdiobus_alloc(&dev->ofdev->dev);
2598-
if (!dev->mii_bus) {
2598+
bus = devm_mdiobus_alloc(&dev->ofdev->dev);
2599+
if (!bus) {
25992600
res = -ENOMEM;
26002601
goto put_node;
26012602
}
26022603

2603-
dev->mii_bus->priv = dev->ndev;
2604-
dev->mii_bus->parent = dev->ndev->dev.parent;
2605-
dev->mii_bus->name = "emac_mdio";
2606-
dev->mii_bus->read = &emac_mii_bus_read;
2607-
dev->mii_bus->write = &emac_mii_bus_write;
2608-
dev->mii_bus->reset = &emac_mii_bus_reset;
2609-
snprintf(dev->mii_bus->id, MII_BUS_ID_SIZE, "%s", dev->ofdev->name);
2610-
res = of_mdiobus_register(dev->mii_bus, mii_np);
2604+
bus->priv = dev->ndev;
2605+
bus->parent = dev->ndev->dev.parent;
2606+
bus->name = "emac_mdio";
2607+
bus->read = &emac_mii_bus_read;
2608+
bus->write = &emac_mii_bus_write;
2609+
bus->reset = &emac_mii_bus_reset;
2610+
snprintf(bus->id, MII_BUS_ID_SIZE, "%s", dev->ofdev->name);
2611+
res = devm_of_mdiobus_register(&dev->ofdev->dev, bus, mii_np);
26112612
if (res) {
26122613
dev_err(&dev->ofdev->dev, "cannot register MDIO bus %s (%d)",
2613-
dev->mii_bus->name, res);
2614+
bus->name, res);
26142615
}
26152616

26162617
put_node:
@@ -2656,8 +2657,6 @@ static int emac_dt_phy_probe(struct emac_instance *dev)
26562657
res = emac_dt_mdio_probe(dev);
26572658
if (!res) {
26582659
res = emac_dt_phy_connect(dev, phy_handle);
2659-
if (res)
2660-
mdiobus_unregister(dev->mii_bus);
26612660
}
26622661
}
26632662

@@ -2697,10 +2696,8 @@ static int emac_init_phy(struct emac_instance *dev)
26972696

26982697
res = of_phy_register_fixed_link(np);
26992698
dev->phy_dev = of_phy_find_device(np);
2700-
if (res || !dev->phy_dev) {
2701-
mdiobus_unregister(dev->mii_bus);
2699+
if (res || !dev->phy_dev)
27022700
return res ? res : -EINVAL;
2703-
}
27042701
emac_adjust_link(dev->ndev);
27052702
put_device(&dev->phy_dev->mdio.dev);
27062703
}
@@ -3265,9 +3262,6 @@ static void emac_remove(struct platform_device *ofdev)
32653262
if (dev->phy_dev)
32663263
phy_disconnect(dev->phy_dev);
32673264

3268-
if (dev->mii_bus)
3269-
mdiobus_unregister(dev->mii_bus);
3270-
32713265
busy_phy_map &= ~(1 << dev->phy.address);
32723266
DBG(dev, "busy_phy_map now %#x" NL, busy_phy_map);
32733267

drivers/net/ethernet/ibm/emac/core.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ struct emac_instance {
189189
struct mutex mdio_lock;
190190

191191
/* Device-tree based phy configuration */
192-
struct mii_bus *mii_bus;
193192
struct phy_device *phy_dev;
194193

195194
/* ZMII infos if any */

0 commit comments

Comments
 (0)