summaryrefslogtreecommitdiff
path: root/drivers/net/phy/mdio_bus.c
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2016-01-06 20:11:27 +0100
committerDavid S. Miller <davem@davemloft.net>2016-01-07 14:31:27 -0500
commit711fdba37a3dd7ee487e28767f9f0e67144cbf80 (patch)
treee152e8b038e05908c7fb1271f751dfa8462d6034 /drivers/net/phy/mdio_bus.c
parenta9049e0c513c4521dbfaa302af8ed08b3366b41f (diff)
mdio: Abstract device_remove() and device_free()
Make device_free and device_remove operations in the mdio device structure, so the core code does not need to differentiate between phy devices and generic mdio devices. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/mdio_bus.c')
-rw-r--r--drivers/net/phy/mdio_bus.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 0573cfd2116f..0be7b3d65f0f 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -299,6 +299,7 @@ static inline void of_mdiobus_link_mdiodev(struct mii_bus *mdio,
*/
int __mdiobus_register(struct mii_bus *bus, struct module *owner)
{
+ struct mdio_device *mdiodev;
int i, err;
if (NULL == bus || NULL == bus->name ||
@@ -344,11 +345,12 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner)
error:
while (--i >= 0) {
- struct phy_device *phydev = mdiobus_get_phy(bus, i);
- if (phydev) {
- phy_device_remove(phydev);
- phy_device_free(phydev);
- }
+ mdiodev = bus->mdio_map[i];
+ if (!mdiodev)
+ continue;
+
+ mdiodev->device_remove(mdiodev);
+ mdiodev->device_free(mdiodev);
}
device_del(&bus->dev);
return err;
@@ -358,7 +360,6 @@ EXPORT_SYMBOL(__mdiobus_register);
void mdiobus_unregister(struct mii_bus *bus)
{
struct mdio_device *mdiodev;
- struct phy_device *phydev;
int i;
BUG_ON(bus->state != MDIOBUS_REGISTERED);
@@ -369,14 +370,8 @@ void mdiobus_unregister(struct mii_bus *bus)
if (!mdiodev)
continue;
- if (!(mdiodev->flags & MDIO_DEVICE_FLAG_PHY)) {
- phydev = container_of(mdiodev, struct phy_device, mdio);
- phy_device_remove(phydev);
- phy_device_free(phydev);
- } else {
- mdio_device_remove(mdiodev);
- mdio_device_free(mdiodev);
- }
+ mdiodev->device_remove(mdiodev);
+ mdiodev->device_free(mdiodev);
}
device_del(&bus->dev);
}