Skip to content

Commit

Permalink
Merge branch 'net-stmmac-remove-unnecessary-of_get_phy_mode-calls'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paolo Abeni committed Mar 18, 2025
2 parents 1549270 + 00d2c3c commit 23c9ff6
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 56 deletions.
21 changes: 9 additions & 12 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ static void anarion_gmac_exit(struct platform_device *pdev, void *priv)
gmac_write_reg(gmac, GMAC_RESET_CONTROL_REG, 1);
}

static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev)
static struct anarion_gmac *
anarion_config_dt(struct platform_device *pdev,
struct plat_stmmacenet_data *plat_dat)
{
struct anarion_gmac *gmac;
phy_interface_t phy_mode;
void __iomem *ctl_block;
int err;

Expand All @@ -79,11 +80,7 @@ static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev)

gmac->ctl_block = ctl_block;

err = of_get_phy_mode(pdev->dev.of_node, &phy_mode);
if (err)
return ERR_PTR(err);

switch (phy_mode) {
switch (plat_dat->phy_interface) {
case PHY_INTERFACE_MODE_RGMII:
fallthrough;
case PHY_INTERFACE_MODE_RGMII_ID:
Expand All @@ -93,7 +90,7 @@ static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev)
break;
default:
dev_err(&pdev->dev, "Unsupported phy-mode (%d)\n",
phy_mode);
plat_dat->phy_interface);
return ERR_PTR(-ENOTSUPP);
}

Expand All @@ -111,14 +108,14 @@ static int anarion_dwmac_probe(struct platform_device *pdev)
if (ret)
return ret;

gmac = anarion_config_dt(pdev);
if (IS_ERR(gmac))
return PTR_ERR(gmac);

plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat))
return PTR_ERR(plat_dat);

gmac = anarion_config_dt(pdev, plat_dat);
if (IS_ERR(gmac))
return PTR_ERR(gmac);

plat_dat->init = anarion_gmac_init;
plat_dat->exit = anarion_gmac_exit;
anarion_gmac_init(pdev, gmac);
Expand Down
12 changes: 4 additions & 8 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,12 @@ static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, int speed)
return 0;
}

static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac)
static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac,
struct plat_stmmacenet_data *plat_dat)
{
struct device *dev = &gmac->pdev->dev;
int ret;

ret = of_get_phy_mode(dev->of_node, &gmac->phy_mode);
if (ret) {
dev_err(dev, "missing phy mode property\n");
return -EINVAL;
}
gmac->phy_mode = plat_dat->phy_interface;

if (of_property_read_u32(dev->of_node, "qcom,id", &gmac->id) < 0) {
dev_err(dev, "missing qcom id property\n");
Expand Down Expand Up @@ -398,7 +394,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)

gmac->pdev = pdev;

err = ipq806x_gmac_of_parse(gmac);
err = ipq806x_gmac_of_parse(gmac, plat_dat);
if (err) {
dev_err(dev, "device tree parsing error\n");
return err;
Expand Down
8 changes: 1 addition & 7 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,20 +456,13 @@ static int mediatek_dwmac_config_dt(struct mediatek_dwmac_plat_data *plat)
{
struct mac_delay_struct *mac_delay = &plat->mac_delay;
u32 tx_delay_ps, rx_delay_ps;
int err;

plat->peri_regmap = syscon_regmap_lookup_by_phandle(plat->np, "mediatek,pericfg");
if (IS_ERR(plat->peri_regmap)) {
dev_err(plat->dev, "Failed to get pericfg syscon\n");
return PTR_ERR(plat->peri_regmap);
}

err = of_get_phy_mode(plat->np, &plat->phy_mode);
if (err) {
dev_err(plat->dev, "not find phy-mode\n");
return err;
}

if (!of_property_read_u32(plat->np, "mediatek,tx-delay-ps", &tx_delay_ps)) {
if (tx_delay_ps < plat->variant->tx_delay_max) {
mac_delay->tx_delay = tx_delay_ps;
Expand Down Expand Up @@ -587,6 +580,7 @@ static int mediatek_dwmac_common_data(struct platform_device *pdev,
{
int i;

priv_plat->phy_mode = plat->phy_interface;
plat->mac_interface = priv_plat->phy_mode;
if (priv_plat->mac_wol)
plat->flags &= ~STMMAC_FLAG_USE_PHY_WOL;
Expand Down
6 changes: 1 addition & 5 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,7 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
return PTR_ERR(dwmac->regs);

dwmac->dev = &pdev->dev;
ret = of_get_phy_mode(pdev->dev.of_node, &dwmac->phy_mode);
if (ret) {
dev_err(&pdev->dev, "missing phy-mode property\n");
return ret;
}
dwmac->phy_mode = plat_dat->phy_interface;

/* use 2ns as fallback since this value was previously hardcoded */
if (of_property_read_u32(pdev->dev.of_node, "amlogic,tx-delay-ns",
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,9 +794,7 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
if (!ethqos)
return -ENOMEM;

ret = of_get_phy_mode(np, &ethqos->phy_mode);
if (ret)
return dev_err_probe(dev, ret, "Failed to get phy mode\n");
ethqos->phy_mode = plat_dat->phy_interface;
switch (ethqos->phy_mode) {
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,
if (!bsp_priv)
return ERR_PTR(-ENOMEM);

of_get_phy_mode(dev->of_node, &bsp_priv->phy_iface);
bsp_priv->phy_iface = plat->phy_interface;
bsp_priv->ops = ops;

/* Some SoCs have multiple MAC controllers, which need
Expand Down
12 changes: 4 additions & 8 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ static int sti_dwmac_set_mode(struct sti_dwmac *dwmac)
}

static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
struct platform_device *pdev)
struct platform_device *pdev,
struct plat_stmmacenet_data *plat_dat)
{
struct resource *res;
struct device *dev = &pdev->dev;
Expand All @@ -204,12 +205,7 @@ static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
if (IS_ERR(regmap))
return PTR_ERR(regmap);

err = of_get_phy_mode(np, &dwmac->interface);
if (err && err != -ENODEV) {
dev_err(dev, "Can't get phy-mode\n");
return err;
}

dwmac->interface = plat_dat->phy_interface;
dwmac->regmap = regmap;
dwmac->gmac_en = of_property_read_bool(np, "st,gmac_en");
dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk");
Expand Down Expand Up @@ -268,7 +264,7 @@ static int sti_dwmac_probe(struct platform_device *pdev)
if (!dwmac)
return -ENOMEM;

ret = sti_dwmac_parse_data(dwmac, pdev);
ret = sti_dwmac_parse_data(dwmac, pdev, plat_dat);
if (ret) {
dev_err(&pdev->dev, "Unable to parse OF data\n");
return ret;
Expand Down
8 changes: 1 addition & 7 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,11 +1155,10 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
struct stmmac_resources stmmac_res;
struct sunxi_priv_data *gmac;
struct device *dev = &pdev->dev;
phy_interface_t interface;
int ret;
struct stmmac_priv *priv;
struct net_device *ndev;
struct regmap *regmap;
int ret;

ret = stmmac_get_platform_resources(pdev, &stmmac_res);
if (ret)
Expand Down Expand Up @@ -1219,18 +1218,13 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
return ret;
}

ret = of_get_phy_mode(dev->of_node, &interface);
if (ret)
return -EINVAL;

plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
if (IS_ERR(plat_dat))
return PTR_ERR(plat_dat);

/* platform data specifying hardware features and callbacks.
* hardware features were copied from Allwinner drivers.
*/
plat_dat->mac_interface = interface;
plat_dat->rx_coe = STMMAC_RX_COE_TYPE2;
plat_dat->tx_coe = 1;
plat_dat->flags |= STMMAC_FLAG_HAS_SUN8I;
Expand Down
6 changes: 1 addition & 5 deletions drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,7 @@ static int sun7i_gmac_probe(struct platform_device *pdev)
if (!gmac)
return -ENOMEM;

ret = of_get_phy_mode(dev->of_node, &gmac->interface);
if (ret && ret != -ENODEV) {
dev_err(dev, "Can't get phy-mode\n");
return ret;
}
gmac->interface = plat_dat->phy_interface;

gmac->tx_clk = devm_clk_get(dev, "allwinner_gmac_tx");
if (IS_ERR(gmac->tx_clk)) {
Expand Down

0 comments on commit 23c9ff6

Please sign in to comment.