Commit 707293a5 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

phy: phy_start_aneg: Add an unlocked version

Split phy_start_aneg into a wrapper which takes the PHY lock, and a
helper doing the real work. This will be needed when
phy_ethtook_ksettings_set takes the lock.

Fixes: 2d55173e ("phy: add generic function to support ksetting support")
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 64cd92d5
...@@ -700,7 +700,7 @@ static int phy_check_link_status(struct phy_device *phydev) ...@@ -700,7 +700,7 @@ static int phy_check_link_status(struct phy_device *phydev)
} }
/** /**
* phy_start_aneg - start auto-negotiation for this PHY device * _phy_start_aneg - start auto-negotiation for this PHY device
* @phydev: the phy_device struct * @phydev: the phy_device struct
* *
* Description: Sanitizes the settings (if we're not autonegotiating * Description: Sanitizes the settings (if we're not autonegotiating
...@@ -708,25 +708,43 @@ static int phy_check_link_status(struct phy_device *phydev) ...@@ -708,25 +708,43 @@ static int phy_check_link_status(struct phy_device *phydev)
* If the PHYCONTROL Layer is operating, we change the state to * If the PHYCONTROL Layer is operating, we change the state to
* reflect the beginning of Auto-negotiation or forcing. * reflect the beginning of Auto-negotiation or forcing.
*/ */
int phy_start_aneg(struct phy_device *phydev) static int _phy_start_aneg(struct phy_device *phydev)
{ {
int err; int err;
lockdep_assert_held(&phydev->lock);
if (!phydev->drv) if (!phydev->drv)
return -EIO; return -EIO;
mutex_lock(&phydev->lock);
if (AUTONEG_DISABLE == phydev->autoneg) if (AUTONEG_DISABLE == phydev->autoneg)
phy_sanitize_settings(phydev); phy_sanitize_settings(phydev);
err = phy_config_aneg(phydev); err = phy_config_aneg(phydev);
if (err < 0) if (err < 0)
goto out_unlock; return err;
if (phy_is_started(phydev)) if (phy_is_started(phydev))
err = phy_check_link_status(phydev); err = phy_check_link_status(phydev);
out_unlock:
return err;
}
/**
* phy_start_aneg - start auto-negotiation for this PHY device
* @phydev: the phy_device struct
*
* Description: Sanitizes the settings (if we're not autonegotiating
* them), and then calls the driver's config_aneg function.
* If the PHYCONTROL Layer is operating, we change the state to
* reflect the beginning of Auto-negotiation or forcing.
*/
int phy_start_aneg(struct phy_device *phydev)
{
int err;
mutex_lock(&phydev->lock);
err = _phy_start_aneg(phydev);
mutex_unlock(&phydev->lock); mutex_unlock(&phydev->lock);
return err; return err;
......
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