diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2017-05-09 17:16:15 +0100 |
---|---|---|
committer | Russell King <rmk+kernel@armlinux.org.uk> | 2017-05-09 18:08:27 +0100 |
commit | 309078107c415afca95e0b6937de2c1494e0fa4a (patch) | |
tree | b6269916e47e53ad3bbe96d445e8c8e83bc0c8e7 | |
parent | 5be9a27de30e6ee5b108f9c4b02def0ecda9f9dc (diff) |
phylink: attach phy to netdev
Attach the phy to the net device so that the generic phy calls can
access the attached phy without having to use phylink veneers.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r-- | drivers/net/phy/phylink.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index f180b947d090..b4c384cffdef 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -554,7 +554,9 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy) "PHY [%s] driver [%s]\n", dev_name(&phy->mdio.dev), phy->drv->name); + mutex_lock(&phy->lock); mutex_lock(&pl->state_mutex); + pl->netdev->phydev = phy; pl->phydev = phy; linkmode_copy(pl->supported, mask); @@ -564,6 +566,7 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy) ethtool_convert_legacy_u32_to_link_mode(pl->link_config.advertising, phy->advertising); mutex_unlock(&pl->state_mutex); + mutex_unlock(&phy->lock); netdev_dbg(pl->netdev, "phy: setting supported %*pb advertising 0x%08x\n", @@ -639,14 +642,17 @@ void phylink_disconnect_phy(struct phylink *pl) WARN_ON(!lockdep_rtnl_is_held()); phy = pl->phydev; + if (phy) { + mutex_lock(&phy->lock); + mutex_lock(&pl->state_mutex); + pl->netdev->phydev = NULL; + pl->phydev = NULL; + mutex_unlock(&pl->state_mutex); + mutex_unlock(&phy->lock); + flush_work(&pl->resolve); - mutex_lock(&pl->state_mutex); - pl->phydev = NULL; - mutex_unlock(&pl->state_mutex); - flush_work(&pl->resolve); - - if (phy) phy_disconnect(phy); + } } EXPORT_SYMBOL_GPL(phylink_disconnect_phy); |