]> git.baikalelectronics.ru Git - kernel.git/commitdiff
phy: phy_start_aneg: Add an unlocked version
authorAndrew Lunn <andrew@lunn.ch>
Sun, 24 Oct 2021 19:48:04 +0000 (21:48 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 2 Nov 2021 18:46:14 +0000 (19:46 +0100)
commit 707293a56f95f8e7e0cfae008010c7933fb68973 upstream.

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: b8d3899eefb1 ("phy: add generic function to support ksetting support")
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/phy/phy.c

index 168a36857036de869e0176b9dc809a546567f121..6c52ff8c0d2ebb5a34626484cf9a2fd7008adaa9 100644 (file)
@@ -555,7 +555,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
  *
  * Description: Sanitizes the settings (if we're not autonegotiating
@@ -563,25 +563,43 @@ static int phy_check_link_status(struct phy_device *phydev)
  *   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)
+static int _phy_start_aneg(struct phy_device *phydev)
 {
        int err;
 
+       lockdep_assert_held(&phydev->lock);
+
        if (!phydev->drv)
                return -EIO;
 
-       mutex_lock(&phydev->lock);
-
        if (AUTONEG_DISABLE == phydev->autoneg)
                phy_sanitize_settings(phydev);
 
        err = phy_config_aneg(phydev);
        if (err < 0)
-               goto out_unlock;
+               return err;
 
        if (phy_is_started(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);
 
        return err;