diff mbox series

[net-next,1/2] net: phy: set 1Gbps as default for driver features

Message ID 6f01dade-a6e1-6de8-cd51-5b7825eb189b@gmail.com
State Deferred, archived
Delegated to: David Miller
Headers show
Series net: phy: set 1Gbps as default for driver features | expand

Commit Message

Heiner Kallweit Dec. 18, 2018, 6:36 a.m. UTC
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 <hkallweit1@gmail.com>
---
 drivers/net/phy/phy_device.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
diff mbox series

Patch

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 {