diff mbox series

[3/3] net: phy: sanitize autoneg in phy_start_aneg_priv

Message ID 20171213173751.12722-3-l.stach@pengutronix.de
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series [1/3] net: phy: add support to detect 100BASE-T1 capability | expand

Commit Message

Lucas Stach Dec. 13, 2017, 5:37 p.m. UTC
phy_sanitize_settings() is only called when autonegotiation has been
explicitly disabled. This breaks PHYs without any autonegotiation
capability, as the check for the capability happens inside this function.

Move the check out to the caller, so it is properly applied for those
PHYs.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/net/phy/phy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 2b1e67bc1e73..433d859b6955 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -226,10 +226,6 @@  static void phy_sanitize_settings(struct phy_device *phydev)
 	const struct phy_setting *setting;
 	u32 features = phydev->supported;
 
-	/* Sanitize settings based on PHY capabilities */
-	if ((features & SUPPORTED_Autoneg) == 0)
-		phydev->autoneg = AUTONEG_DISABLE;
-
 	setting = phy_find_valid(phydev->speed, phydev->duplex, features);
 	if (setting) {
 		phydev->speed = setting->speed;
@@ -487,6 +483,10 @@  static int phy_start_aneg_priv(struct phy_device *phydev, bool sync)
 
 	mutex_lock(&phydev->lock);
 
+	/* Sanitize settings based on PHY capabilities */
+	if ((phydev->supported & SUPPORTED_Autoneg) == 0)
+		phydev->autoneg = AUTONEG_DISABLE;
+
 	if (AUTONEG_DISABLE == phydev->autoneg)
 		phy_sanitize_settings(phydev);