summaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/mdio_bus.c
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2016-01-06 20:11:26 +0100
committerDavid S. Miller <davem@davemloft.net>2016-01-07 20:31:27 +0100
commita9049e0c513c4521dbfaa302af8ed08b3366b41f (patch)
treec7791b09aee213f8241f366aa9b88c270803ebf9 /drivers/net/phy/mdio_bus.c
parentmdio_bus: Add comment to mdiobus_scan() and __mdiobus_register() (diff)
downloadlinux-a9049e0c513c4521dbfaa302af8ed08b3366b41f.tar.xz
linux-a9049e0c513c4521dbfaa302af8ed08b3366b41f.zip
mdio: Add support for mdio drivers.
Not all devices on an MDIO bus are PHYs. Meaning not all MDIO drivers are PHY drivers. Add support for generic MDIO drivers. 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.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 6f9ca51446db..0573cfd2116f 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -357,16 +357,25 @@ 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);
bus->state = MDIOBUS_UNREGISTERED;
for (i = 0; i < PHY_MAX_ADDR; i++) {
- struct phy_device *phydev = mdiobus_get_phy(bus, i);
- if (phydev) {
+ mdiodev = bus->mdio_map[i];
+ 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);
}
}
device_del(&bus->dev);