Skip to content

Commit f9cdff1

Browse files
fancerkuba-moo
authored andcommitted
net: stmmac: Make stmmac_xpcs_setup() generic to all PCS devices
A pcs_init() callback will be introduced to stmmac in a future patch. This new function will be called during the hardware initialization phase. Instead of separately initializing XPCS and PCS components, let's group all PCS-related hardware initialization logic in the current stmmac_xpcs_setup() function. Rename stmmac_xpcs_setup() to stmmac_pcs_setup() and move the conditional call to stmmac_xpcs_setup() inside the function itself. Signed-off-by: Serge Semin <[email protected]> Co-developed-by: Romain Gantois <[email protected]> Signed-off-by: Romain Gantois <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Reviewed-by: Hariprasad Kelam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d5c5093 commit f9cdff1

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ enum stmmac_state {
360360
int stmmac_mdio_unregister(struct net_device *ndev);
361361
int stmmac_mdio_register(struct net_device *ndev);
362362
int stmmac_mdio_reset(struct mii_bus *mii);
363-
int stmmac_xpcs_setup(struct mii_bus *mii);
363+
int stmmac_pcs_setup(struct net_device *ndev);
364364
void stmmac_pcs_clean(struct net_device *ndev);
365365
void stmmac_set_ethtool_ops(struct net_device *netdev);
366366

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7754,11 +7754,9 @@ int stmmac_dvr_probe(struct device *device,
77547754
if (priv->plat->speed_mode_2500)
77557755
priv->plat->speed_mode_2500(ndev, priv->plat->bsp_priv);
77567756

7757-
if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) {
7758-
ret = stmmac_xpcs_setup(priv->mii);
7759-
if (ret)
7760-
goto error_xpcs_setup;
7761-
}
7757+
ret = stmmac_pcs_setup(ndev);
7758+
if (ret)
7759+
goto error_pcs_setup;
77627760

77637761
ret = stmmac_phy_setup(priv);
77647762
if (ret) {
@@ -7791,7 +7789,7 @@ int stmmac_dvr_probe(struct device *device,
77917789
phylink_destroy(priv->phylink);
77927790
error_phy_setup:
77937791
stmmac_pcs_clean(ndev);
7794-
error_xpcs_setup:
7792+
error_pcs_setup:
77957793
if (priv->hw->pcs != STMMAC_PCS_TBI &&
77967794
priv->hw->pcs != STMMAC_PCS_RTBI)
77977795
stmmac_mdio_unregister(ndev);

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -495,31 +495,37 @@ int stmmac_mdio_reset(struct mii_bus *bus)
495495
return 0;
496496
}
497497

498-
int stmmac_xpcs_setup(struct mii_bus *bus)
498+
int stmmac_pcs_setup(struct net_device *ndev)
499499
{
500-
struct net_device *ndev = bus->priv;
500+
struct dw_xpcs *xpcs = NULL;
501501
struct stmmac_priv *priv;
502-
struct dw_xpcs *xpcs;
502+
int ret = -ENODEV;
503503
int mode, addr;
504504

505505
priv = netdev_priv(ndev);
506506
mode = priv->plat->phy_interface;
507507

508-
/* Try to probe the XPCS by scanning all addresses. */
509-
for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
510-
xpcs = xpcs_create_mdiodev(bus, addr, mode);
511-
if (IS_ERR(xpcs))
512-
continue;
508+
if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) {
509+
/* Try to probe the XPCS by scanning all addresses */
510+
for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
511+
xpcs = xpcs_create_mdiodev(priv->mii, addr, mode);
512+
if (IS_ERR(xpcs))
513+
continue;
513514

514-
priv->hw->xpcs = xpcs;
515-
break;
515+
ret = 0;
516+
break;
517+
}
518+
} else {
519+
return 0;
516520
}
517521

518-
if (!priv->hw->xpcs) {
522+
if (ret) {
519523
dev_warn(priv->device, "No xPCS found\n");
520-
return -ENODEV;
524+
return ret;
521525
}
522526

527+
priv->hw->xpcs = xpcs;
528+
523529
return 0;
524530
}
525531

0 commit comments

Comments
 (0)