diff options
author | David S. Miller <davem@davemloft.net> | 2016-12-10 16:21:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-12-10 16:21:55 -0500 |
commit | 821781a9f40673c2aa0f29d9d8226ec320dff20c (patch) | |
tree | c9d5cb8a184fff84a9d841d8cb5da4b26be5c551 /drivers/net/phy/phy_device.c | |
parent | 3174fed9820edc95cff74ad0934c3240c7fb5115 (diff) | |
parent | 045169816b31b10faed984b01c390db1b32ee4c1 (diff) | |
download | blackbird-op-linux-821781a9f40673c2aa0f29d9d8226ec320dff20c.tar.gz blackbird-op-linux-821781a9f40673c2aa0f29d9d8226ec320dff20c.zip |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'drivers/net/phy/phy_device.c')
-rw-r--r-- | drivers/net/phy/phy_device.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 32fa7c76f29c..0aadef9fc7dd 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -905,11 +905,17 @@ EXPORT_SYMBOL(phy_attached_print); int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, u32 flags, phy_interface_t interface) { + struct module *ndev_owner = dev->dev.parent->driver->owner; struct mii_bus *bus = phydev->mdio.bus; struct device *d = &phydev->mdio.dev; int err; - if (!try_module_get(bus->owner)) { + /* For Ethernet device drivers that register their own MDIO bus, we + * will have bus->owner match ndev_mod, so we do not want to increment + * our own module->refcnt here, otherwise we would not be able to + * unload later on. + */ + if (ndev_owner != bus->owner && !try_module_get(bus->owner)) { dev_err(&dev->dev, "failed to get the bus module\n"); return -EIO; } @@ -971,7 +977,8 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, error: phy_detach(phydev); put_device(d); - module_put(bus->owner); + if (ndev_owner != bus->owner) + module_put(bus->owner); return err; } EXPORT_SYMBOL(phy_attach_direct); @@ -1021,6 +1028,8 @@ EXPORT_SYMBOL(phy_attach); */ void phy_detach(struct phy_device *phydev) { + struct net_device *dev = phydev->attached_dev; + struct module *ndev_owner = dev->dev.parent->driver->owner; struct mii_bus *bus; int i; @@ -1050,7 +1059,8 @@ void phy_detach(struct phy_device *phydev) bus = phydev->mdio.bus; put_device(&phydev->mdio.dev); - module_put(bus->owner); + if (ndev_owner != bus->owner) + module_put(bus->owner); } EXPORT_SYMBOL(phy_detach); |