]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: stmmac: qcom-ethqos: move ethqos_set_serdes_speed()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tue, 3 Mar 2026 15:53:35 +0000 (15:53 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 6 Mar 2026 02:43:06 +0000 (18:43 -0800)
Combine ethqos_set_serdes_speed() with ethqos_mac_finish_serdes() to
simplify the code.

Reviewed-by: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
Tested-by: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vxS3z-0000000BQXO-2WpU@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c

index ad5b5d950fffc14b33bd83274d3589410ad29618..57cbe800f6521ce5ed7a3947842af0fe715e81c2 100644 (file)
@@ -591,14 +591,6 @@ static void ethqos_configure_rgmii(struct qcom_ethqos *ethqos,
        ethqos_rgmii_macro_init(ethqos, speed);
 }
 
-static void ethqos_set_serdes_speed(struct qcom_ethqos *ethqos, int speed)
-{
-       if (ethqos->serdes_speed != speed) {
-               phy_set_speed(ethqos->serdes_phy, speed);
-               ethqos->serdes_speed = speed;
-       }
-}
-
 static void ethqos_pcs_set_inband(struct stmmac_priv *priv, bool enable)
 {
        stmmac_pcs_ctrl_ane(priv, enable, 0);
@@ -683,15 +675,23 @@ static int ethqos_mac_finish_serdes(struct net_device *ndev, void *priv,
                                    phy_interface_t interface)
 {
        struct qcom_ethqos *ethqos = priv;
+       int speed, ret = 0;
 
        qcom_ethqos_set_sgmii_loopback(ethqos, false);
 
+       speed = SPEED_UNKNOWN;
        if (interface == PHY_INTERFACE_MODE_SGMII)
-               ethqos_set_serdes_speed(ethqos, SPEED_1000);
+               speed = SPEED_1000;
        else if (interface == PHY_INTERFACE_MODE_2500BASEX)
-               ethqos_set_serdes_speed(ethqos, SPEED_2500);
+               speed = SPEED_2500;
 
-       return 0;
+       if (speed != SPEED_UNKNOWN && speed != ethqos->serdes_speed) {
+               ret = phy_set_speed(ethqos->serdes_phy, speed);
+               if (ret == 0)
+                       ethqos->serdes_speed = speed;
+       }
+
+       return ret;
 }
 
 static int ethqos_clks_config(void *priv, bool enabled)