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.st...@pengutronix.de>
---
 drivers/net/phy/phy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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);
 
-- 
2.11.0

Reply via email to