From patchwork Wed Dec 13 17:37:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 848065 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxkRn2Tmhz9ryr for ; Thu, 14 Dec 2017 04:37:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753448AbdLMRhz (ORCPT ); Wed, 13 Dec 2017 12:37:55 -0500 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:52161 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753332AbdLMRhx (ORCPT ); Wed, 13 Dec 2017 12:37:53 -0500 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.84_2) (envelope-from ) id 1ePAyd-0004wv-VZ; Wed, 13 Dec 2017 18:37:52 +0100 From: Lucas Stach To: Andrew Lunn , Florian Fainelli Cc: netdev@vger.kernel.org, kernel@pengutronix.de, patchwork-lst@pengutronix.de Subject: [PATCH 3/3] net: phy: sanitize autoneg in phy_start_aneg_priv Date: Wed, 13 Dec 2017 18:37:51 +0100 Message-Id: <20171213173751.12722-3-l.stach@pengutronix.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171213173751.12722-1-l.stach@pengutronix.de> References: <20171213173751.12722-1-l.stach@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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);