]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: ingenic: use ->set_phy_intf_sel()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Fri, 7 Nov 2025 08:29:26 +0000 (08:29 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 11 Nov 2025 01:30:40 +0000 (17:30 -0800)
Rather than placing the phy_intf_sel() setup in the ->init() method,
move it to the new ->set_phy_intf_sel() method.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vHHqY-0000000Djrn-1D6H@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c

index 41a2071262bc7492ef4b3c02db0b5b314a14145f..8e4a30c11db06aa44d102542424df0ff874142a0 100644 (file)
@@ -134,32 +134,21 @@ static int x2000_mac_set_mode(struct ingenic_mac *mac, u8 phy_intf_sel)
        return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val);
 }
 
-static int ingenic_mac_init(struct platform_device *pdev, void *bsp_priv)
+static int ingenic_set_phy_intf_sel(void *bsp_priv, u8 phy_intf_sel)
 {
        struct ingenic_mac *mac = bsp_priv;
-       phy_interface_t interface;
-       int phy_intf_sel, ret;
-
-       if (mac->soc_info->set_mode) {
-               interface = mac->plat_dat->phy_interface;
-
-               phy_intf_sel = stmmac_get_phy_intf_sel(interface);
-               if (phy_intf_sel < 0 || phy_intf_sel >= BITS_PER_BYTE ||
-                   ~mac->soc_info->valid_phy_intf_sel & BIT(phy_intf_sel)) {
-                       dev_err(mac->dev, "unsupported interface %s\n",
-                               phy_modes(interface));
-                       return phy_intf_sel < 0 ? phy_intf_sel : -EINVAL;
-               }
 
-               dev_dbg(mac->dev, "MAC PHY control register: interface %s\n",
-                       phy_modes(interface));
+       if (!mac->soc_info->set_mode)
+               return 0;
 
-               ret = mac->soc_info->set_mode(mac, phy_intf_sel);
-               if (ret)
-                       return ret;
-       }
+       if (phy_intf_sel >= BITS_PER_BYTE ||
+           ~mac->soc_info->valid_phy_intf_sel & BIT(phy_intf_sel))
+               return -EINVAL;
+
+       dev_dbg(mac->dev, "MAC PHY control register: interface %s\n",
+               phy_modes(mac->plat_dat->phy_interface));
 
-       return 0;
+       return mac->soc_info->set_mode(mac, phy_intf_sel);
 }
 
 static int ingenic_mac_probe(struct platform_device *pdev)
@@ -221,7 +210,7 @@ static int ingenic_mac_probe(struct platform_device *pdev)
        mac->plat_dat = plat_dat;
 
        plat_dat->bsp_priv = mac;
-       plat_dat->init = ingenic_mac_init;
+       plat_dat->set_phy_intf_sel = ingenic_set_phy_intf_sel;
 
        return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
 }