Commit 93a6d4e0 authored by Rosen Penev's avatar Rosen Penev Committed by Jakub Kicinski

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: default avatarRosen Penev <rosenp@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20240912024903.6201-5-rosenp@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 969b002d
...@@ -2581,6 +2581,7 @@ static const struct mii_phy_ops emac_dt_mdio_phy_ops = { ...@@ -2581,6 +2581,7 @@ static const struct mii_phy_ops emac_dt_mdio_phy_ops = {
static int emac_dt_mdio_probe(struct emac_instance *dev) static int emac_dt_mdio_probe(struct emac_instance *dev)
{ {
struct device_node *mii_np; struct device_node *mii_np;
struct mii_bus *bus;
int res; int res;
mii_np = of_get_child_by_name(dev->ofdev->dev.of_node, "mdio"); 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) ...@@ -2594,23 +2595,23 @@ static int emac_dt_mdio_probe(struct emac_instance *dev)
goto put_node; goto put_node;
} }
dev->mii_bus = devm_mdiobus_alloc(&dev->ofdev->dev); bus = devm_mdiobus_alloc(&dev->ofdev->dev);
if (!dev->mii_bus) { if (!bus) {
res = -ENOMEM; res = -ENOMEM;
goto put_node; goto put_node;
} }
dev->mii_bus->priv = dev->ndev; bus->priv = dev->ndev;
dev->mii_bus->parent = dev->ndev->dev.parent; bus->parent = dev->ndev->dev.parent;
dev->mii_bus->name = "emac_mdio"; bus->name = "emac_mdio";
dev->mii_bus->read = &emac_mii_bus_read; bus->read = &emac_mii_bus_read;
dev->mii_bus->write = &emac_mii_bus_write; bus->write = &emac_mii_bus_write;
dev->mii_bus->reset = &emac_mii_bus_reset; bus->reset = &emac_mii_bus_reset;
snprintf(dev->mii_bus->id, MII_BUS_ID_SIZE, "%s", dev->ofdev->name); snprintf(bus->id, MII_BUS_ID_SIZE, "%s", dev->ofdev->name);
res = of_mdiobus_register(dev->mii_bus, mii_np); res = devm_of_mdiobus_register(&dev->ofdev->dev, bus, mii_np);
if (res) { if (res) {
dev_err(&dev->ofdev->dev, "cannot register MDIO bus %s (%d)", dev_err(&dev->ofdev->dev, "cannot register MDIO bus %s (%d)",
dev->mii_bus->name, res); bus->name, res);
} }
put_node: put_node:
...@@ -2656,8 +2657,6 @@ static int emac_dt_phy_probe(struct emac_instance *dev) ...@@ -2656,8 +2657,6 @@ static int emac_dt_phy_probe(struct emac_instance *dev)
res = emac_dt_mdio_probe(dev); res = emac_dt_mdio_probe(dev);
if (!res) { if (!res) {
res = emac_dt_phy_connect(dev, phy_handle); res = emac_dt_phy_connect(dev, phy_handle);
if (res)
mdiobus_unregister(dev->mii_bus);
} }
} }
...@@ -2697,10 +2696,8 @@ static int emac_init_phy(struct emac_instance *dev) ...@@ -2697,10 +2696,8 @@ static int emac_init_phy(struct emac_instance *dev)
res = of_phy_register_fixed_link(np); res = of_phy_register_fixed_link(np);
dev->phy_dev = of_phy_find_device(np); dev->phy_dev = of_phy_find_device(np);
if (res || !dev->phy_dev) { if (res || !dev->phy_dev)
mdiobus_unregister(dev->mii_bus);
return res ? res : -EINVAL; return res ? res : -EINVAL;
}
emac_adjust_link(dev->ndev); emac_adjust_link(dev->ndev);
put_device(&dev->phy_dev->mdio.dev); put_device(&dev->phy_dev->mdio.dev);
} }
...@@ -3265,9 +3262,6 @@ static void emac_remove(struct platform_device *ofdev) ...@@ -3265,9 +3262,6 @@ static void emac_remove(struct platform_device *ofdev)
if (dev->phy_dev) if (dev->phy_dev)
phy_disconnect(dev->phy_dev); phy_disconnect(dev->phy_dev);
if (dev->mii_bus)
mdiobus_unregister(dev->mii_bus);
busy_phy_map &= ~(1 << dev->phy.address); busy_phy_map &= ~(1 << dev->phy.address);
DBG(dev, "busy_phy_map now %#x" NL, busy_phy_map); DBG(dev, "busy_phy_map now %#x" NL, busy_phy_map);
......
...@@ -189,7 +189,6 @@ struct emac_instance { ...@@ -189,7 +189,6 @@ struct emac_instance {
struct mutex mdio_lock; struct mutex mdio_lock;
/* Device-tree based phy configuration */ /* Device-tree based phy configuration */
struct mii_bus *mii_bus;
struct phy_device *phy_dev; struct phy_device *phy_dev;
/* ZMII infos if any */ /* ZMII infos if any */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment