From: Heiner Kallweit Subject: [PATCH net-next 1/2] net: phy: set 1Gbps as default for driver features Date: Tue, 18 Dec 2018 07:36:27 +0100 Message-ID: <6f01dade-a6e1-6de8-cd51-5b7825eb189b@gmail.com> References: <98eb58fb-9ba2-e18b-cd9f-7afd632a9f0b@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "netdev@vger.kernel.org" To: Andrew Lunn , Florian Fainelli , David Miller , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com Return-path: Received: from mail-wm1-f65.google.com ([209.85.128.65]:52132 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726322AbeLRGkF (ORCPT ); Tue, 18 Dec 2018 01:40:05 -0500 Received: by mail-wm1-f65.google.com with SMTP id b11so1402137wmj.1 for ; Mon, 17 Dec 2018 22:40:03 -0800 (PST) In-Reply-To: <98eb58fb-9ba2-e18b-cd9f-7afd632a9f0b@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: Whether a PHY is 100MBps or 1Gbps-capable can be autodetected, therefore it's not needed to define this manually in the driver. genphy_config_init() will remove 1Gbps from phydev->supported if not supported. Having said that PHY drivers for 100Mbps not calling genphy_config_init() still have to set the features field. As most PHY's are 1Gbps-capable let's use this as default. Signed-off-by: Heiner Kallweit --- drivers/net/phy/phy_device.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 54af2bde6..753451341 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2138,6 +2138,7 @@ static int phy_probe(struct device *dev) struct phy_device *phydev = to_phy_device(dev); struct device_driver *drv = phydev->mdio.dev.driver; struct phy_driver *phydrv = to_phy_driver(drv); + const long unsigned int *features; int err = 0; phydev->drv = phydrv; @@ -2153,11 +2154,14 @@ static int phy_probe(struct device *dev) mutex_lock(&phydev->lock); + /* Use 1Gbps as default if driver defines no features */ + features = phydrv->features ?: phy_gbit_features; + /* Start out supporting everything. Eventually, * a controller will attach, and may modify one * or both of these values */ - linkmode_copy(phydev->supported, phydrv->features); + linkmode_copy(phydev->supported, features); of_set_phy_supported(phydev); linkmode_copy(phydev->advertising, phydev->supported); @@ -2177,17 +2181,16 @@ static int phy_probe(struct device *dev) * (e.g. hardware erratum) where the driver wants to set only one * of these bits. */ - if (test_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydrv->features) || - test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydrv->features)) { + if (test_bit(ETHTOOL_LINK_MODE_Pause_BIT, features) || + test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, features)) { linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported); linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported); - if (test_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydrv->features)) + if (test_bit(ETHTOOL_LINK_MODE_Pause_BIT, features)) linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, phydev->supported); - if (test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, - phydrv->features)) + if (test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, features)) linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, phydev->supported); } else { -- 2.20.0