net: phy: exported the genphy_read_master_slave function
authorArun Ramadoss <arun.ramadoss@microchip.com>
Mon, 7 Mar 2022 16:15:14 +0000 (21:45 +0530)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 8 Mar 2022 12:34:33 +0000 (13:34 +0100)
genphy_read_master_slave function allows to configure the master/slave
for gigabit phys only. In order to use this function irrespective of
speed, moved the speed check to the genphy_read_status call.

Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/phy/phy_device.c
include/linux/phy.h

index ce0bb5951b81e356aba0322ac2fb752e48eaf3bd..8406ac739def833b43544338b9843c87260a70e8 100644 (file)
@@ -2051,17 +2051,11 @@ static int genphy_setup_master_slave(struct phy_device *phydev)
                                   CTL1000_PREFER_MASTER), ctl);
 }
 
-static int genphy_read_master_slave(struct phy_device *phydev)
+int genphy_read_master_slave(struct phy_device *phydev)
 {
        int cfg, state;
        int val;
 
-       if (!phydev->is_gigabit_capable) {
-               phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED;
-               phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED;
-               return 0;
-       }
-
        phydev->master_slave_get = MASTER_SLAVE_CFG_UNKNOWN;
        phydev->master_slave_state = MASTER_SLAVE_STATE_UNKNOWN;
 
@@ -2102,6 +2096,7 @@ static int genphy_read_master_slave(struct phy_device *phydev)
 
        return 0;
 }
+EXPORT_SYMBOL(genphy_read_master_slave);
 
 /**
  * genphy_restart_aneg - Enable and Restart Autonegotiation
@@ -2396,14 +2391,18 @@ int genphy_read_status(struct phy_device *phydev)
        if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link)
                return 0;
 
+       phydev->master_slave_get = MASTER_SLAVE_CFG_UNSUPPORTED;
+       phydev->master_slave_state = MASTER_SLAVE_STATE_UNSUPPORTED;
        phydev->speed = SPEED_UNKNOWN;
        phydev->duplex = DUPLEX_UNKNOWN;
        phydev->pause = 0;
        phydev->asym_pause = 0;
 
-       err = genphy_read_master_slave(phydev);
-       if (err < 0)
-               return err;
+       if (phydev->is_gigabit_capable) {
+               err = genphy_read_master_slave(phydev);
+               if (err < 0)
+                       return err;
+       }
 
        err = genphy_read_lpa(phydev);
        if (err < 0)
index cd08cf1a8b0de41755a6a813decb6d2f28670498..20beeaa7443b8b879a1c9d736b3d6b321eca7318 100644 (file)
@@ -1578,6 +1578,7 @@ int genphy_update_link(struct phy_device *phydev);
 int genphy_read_lpa(struct phy_device *phydev);
 int genphy_read_status_fixed(struct phy_device *phydev);
 int genphy_read_status(struct phy_device *phydev);
+int genphy_read_master_slave(struct phy_device *phydev);
 int genphy_suspend(struct phy_device *phydev);
 int genphy_resume(struct phy_device *phydev);
 int genphy_loopback(struct phy_device *phydev, bool enable);