Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-stmmac-remove-unnecessary-of_get_phy_mode-calls'

Russell King says:

====================
net: stmmac: remove unnecessary of_get_phy_mode() calls

This series removes unnecessary of_get_phy_mode() calls from the stmmac
glue drivers. stmmac_probe_config_dt() / devm_stmmac_probe_config_dt()
already gets the interface mode using device_get_phy_mode() and stores
it in plat_dat->phy_interface.

Therefore, glue drivers using of_get_phy_mode() are just duplicating
the work that has already been done.

This series adjusts the glue drivers to remove their usage of
of_get_phy_mode().
====================

Link: https://patch.msgid.link/Z9FQjQZb0IMaQJ9H@shell.armlinux.org.uk
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

+23 -56
+9 -12
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
··· 59 59 gmac_write_reg(gmac, GMAC_RESET_CONTROL_REG, 1); 60 60 } 61 61 62 - static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev) 62 + static struct anarion_gmac * 63 + anarion_config_dt(struct platform_device *pdev, 64 + struct plat_stmmacenet_data *plat_dat) 63 65 { 64 66 struct anarion_gmac *gmac; 65 - phy_interface_t phy_mode; 66 67 void __iomem *ctl_block; 67 68 int err; 68 69 ··· 80 79 81 80 gmac->ctl_block = ctl_block; 82 81 83 - err = of_get_phy_mode(pdev->dev.of_node, &phy_mode); 84 - if (err) 85 - return ERR_PTR(err); 86 - 87 - switch (phy_mode) { 82 + switch (plat_dat->phy_interface) { 88 83 case PHY_INTERFACE_MODE_RGMII: 89 84 fallthrough; 90 85 case PHY_INTERFACE_MODE_RGMII_ID: ··· 90 93 break; 91 94 default: 92 95 dev_err(&pdev->dev, "Unsupported phy-mode (%d)\n", 93 - phy_mode); 96 + plat_dat->phy_interface); 94 97 return ERR_PTR(-ENOTSUPP); 95 98 } 96 99 ··· 108 111 if (ret) 109 112 return ret; 110 113 111 - gmac = anarion_config_dt(pdev); 112 - if (IS_ERR(gmac)) 113 - return PTR_ERR(gmac); 114 - 115 114 plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac); 116 115 if (IS_ERR(plat_dat)) 117 116 return PTR_ERR(plat_dat); 117 + 118 + gmac = anarion_config_dt(pdev, plat_dat); 119 + if (IS_ERR(gmac)) 120 + return PTR_ERR(gmac); 118 121 119 122 plat_dat->init = anarion_gmac_init; 120 123 plat_dat->exit = anarion_gmac_exit;
+4 -8
drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
··· 211 211 return 0; 212 212 } 213 213 214 - static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac) 214 + static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac, 215 + struct plat_stmmacenet_data *plat_dat) 215 216 { 216 217 struct device *dev = &gmac->pdev->dev; 217 - int ret; 218 218 219 - ret = of_get_phy_mode(dev->of_node, &gmac->phy_mode); 220 - if (ret) { 221 - dev_err(dev, "missing phy mode property\n"); 222 - return -EINVAL; 223 - } 219 + gmac->phy_mode = plat_dat->phy_interface; 224 220 225 221 if (of_property_read_u32(dev->of_node, "qcom,id", &gmac->id) < 0) { 226 222 dev_err(dev, "missing qcom id property\n"); ··· 394 398 395 399 gmac->pdev = pdev; 396 400 397 - err = ipq806x_gmac_of_parse(gmac); 401 + err = ipq806x_gmac_of_parse(gmac, plat_dat); 398 402 if (err) { 399 403 dev_err(dev, "device tree parsing error\n"); 400 404 return err;
+1 -7
drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
··· 456 456 { 457 457 struct mac_delay_struct *mac_delay = &plat->mac_delay; 458 458 u32 tx_delay_ps, rx_delay_ps; 459 - int err; 460 459 461 460 plat->peri_regmap = syscon_regmap_lookup_by_phandle(plat->np, "mediatek,pericfg"); 462 461 if (IS_ERR(plat->peri_regmap)) { 463 462 dev_err(plat->dev, "Failed to get pericfg syscon\n"); 464 463 return PTR_ERR(plat->peri_regmap); 465 - } 466 - 467 - err = of_get_phy_mode(plat->np, &plat->phy_mode); 468 - if (err) { 469 - dev_err(plat->dev, "not find phy-mode\n"); 470 - return err; 471 464 } 472 465 473 466 if (!of_property_read_u32(plat->np, "mediatek,tx-delay-ps", &tx_delay_ps)) { ··· 580 587 { 581 588 int i; 582 589 590 + priv_plat->phy_mode = plat->phy_interface; 583 591 plat->mac_interface = priv_plat->phy_mode; 584 592 if (priv_plat->mac_wol) 585 593 plat->flags &= ~STMMAC_FLAG_USE_PHY_WOL;
+1 -5
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
··· 417 417 return PTR_ERR(dwmac->regs); 418 418 419 419 dwmac->dev = &pdev->dev; 420 - ret = of_get_phy_mode(pdev->dev.of_node, &dwmac->phy_mode); 421 - if (ret) { 422 - dev_err(&pdev->dev, "missing phy-mode property\n"); 423 - return ret; 424 - } 420 + dwmac->phy_mode = plat_dat->phy_interface; 425 421 426 422 /* use 2ns as fallback since this value was previously hardcoded */ 427 423 if (of_property_read_u32(pdev->dev.of_node, "amlogic,tx-delay-ns",
+1 -3
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
··· 794 794 if (!ethqos) 795 795 return -ENOMEM; 796 796 797 - ret = of_get_phy_mode(np, &ethqos->phy_mode); 798 - if (ret) 799 - return dev_err_probe(dev, ret, "Failed to get phy mode\n"); 797 + ethqos->phy_mode = plat_dat->phy_interface; 800 798 switch (ethqos->phy_mode) { 801 799 case PHY_INTERFACE_MODE_RGMII: 802 800 case PHY_INTERFACE_MODE_RGMII_ID:
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
··· 1503 1503 if (!bsp_priv) 1504 1504 return ERR_PTR(-ENOMEM); 1505 1505 1506 - of_get_phy_mode(dev->of_node, &bsp_priv->phy_iface); 1506 + bsp_priv->phy_iface = plat->phy_interface; 1507 1507 bsp_priv->ops = ops; 1508 1508 1509 1509 /* Some SoCs have multiple MAC controllers, which need
+4 -8
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
··· 185 185 } 186 186 187 187 static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, 188 - struct platform_device *pdev) 188 + struct platform_device *pdev, 189 + struct plat_stmmacenet_data *plat_dat) 189 190 { 190 191 struct resource *res; 191 192 struct device *dev = &pdev->dev; ··· 205 204 if (IS_ERR(regmap)) 206 205 return PTR_ERR(regmap); 207 206 208 - err = of_get_phy_mode(np, &dwmac->interface); 209 - if (err && err != -ENODEV) { 210 - dev_err(dev, "Can't get phy-mode\n"); 211 - return err; 212 - } 213 - 207 + dwmac->interface = plat_dat->phy_interface; 214 208 dwmac->regmap = regmap; 215 209 dwmac->gmac_en = of_property_read_bool(np, "st,gmac_en"); 216 210 dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk"); ··· 264 268 if (!dwmac) 265 269 return -ENOMEM; 266 270 267 - ret = sti_dwmac_parse_data(dwmac, pdev); 271 + ret = sti_dwmac_parse_data(dwmac, pdev, plat_dat); 268 272 if (ret) { 269 273 dev_err(&pdev->dev, "Unable to parse OF data\n"); 270 274 return ret;
+1 -7
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
··· 1155 1155 struct stmmac_resources stmmac_res; 1156 1156 struct sunxi_priv_data *gmac; 1157 1157 struct device *dev = &pdev->dev; 1158 - phy_interface_t interface; 1159 - int ret; 1160 1158 struct stmmac_priv *priv; 1161 1159 struct net_device *ndev; 1162 1160 struct regmap *regmap; 1161 + int ret; 1163 1162 1164 1163 ret = stmmac_get_platform_resources(pdev, &stmmac_res); 1165 1164 if (ret) ··· 1218 1219 return ret; 1219 1220 } 1220 1221 1221 - ret = of_get_phy_mode(dev->of_node, &interface); 1222 - if (ret) 1223 - return -EINVAL; 1224 - 1225 1222 plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac); 1226 1223 if (IS_ERR(plat_dat)) 1227 1224 return PTR_ERR(plat_dat); ··· 1225 1230 /* platform data specifying hardware features and callbacks. 1226 1231 * hardware features were copied from Allwinner drivers. 1227 1232 */ 1228 - plat_dat->mac_interface = interface; 1229 1233 plat_dat->rx_coe = STMMAC_RX_COE_TYPE2; 1230 1234 plat_dat->tx_coe = 1; 1231 1235 plat_dat->flags |= STMMAC_FLAG_HAS_SUN8I;
+1 -5
drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
··· 116 116 if (!gmac) 117 117 return -ENOMEM; 118 118 119 - ret = of_get_phy_mode(dev->of_node, &gmac->interface); 120 - if (ret && ret != -ENODEV) { 121 - dev_err(dev, "Can't get phy-mode\n"); 122 - return ret; 123 - } 119 + gmac->interface = plat_dat->phy_interface; 124 120 125 121 gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx"); 126 122 if (IS_ERR(gmac->tx_clk)) {