]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: stmmac: remove plat_dat->port_node
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Fri, 27 Feb 2026 09:53:13 +0000 (09:53 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 3 Mar 2026 02:35:05 +0000 (18:35 -0800)
There are repeated instances of:

fwnode = priv->plat->port_node;
if (!fwnode)
fwnode = dev_fwnode(priv->device);

However, the only place that ->port_node is set is
stmmac_probe_config_dt():

struct device_node *np = pdev->dev.of_node;
...
/* PHYLINK automatically parses the phy-handle property */
plat->port_node = of_fwnode_handle(np);

which is equivalent to dev_fwnode(&pdev->dev) and, as priv->device
will be &pdev->dev, is also equivalent to dev_fwnode(priv->device).

Thus, plat_dat->port_node doesn't provide any extra benefit over
using dev_fwnode(priv->device) directly.

There is one case where port_node is used directly, which can be
found in stmmac_pcs_setup(). This may cause a change of behaviour
as PCI drivers do not populate plat_dat->port_node, but
dev_fwnode(priv->device) may be valid. PCI-based stmmac should
be tested.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vvuX3-0000000Avme-3oej@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
include/linux/stmmac.h

index 5c144ac259af62f10b8834e4f88fb58a6a3505a1..4e788f54bbbc845f2dd872d64a0c8b390738e8d6 100644 (file)
@@ -1252,10 +1252,7 @@ static int stmmac_init_phy(struct net_device *dev)
            xpcs_get_an_mode(priv->hw->xpcs, mode) == DW_AN_C73)
                return 0;
 
-       fwnode = priv->plat->port_node;
-       if (!fwnode)
-               fwnode = dev_fwnode(priv->device);
-
+       fwnode = dev_fwnode(priv->device);
        if (fwnode)
                phy_fwnode = fwnode_get_phy_node(fwnode);
        else
@@ -1313,7 +1310,6 @@ static int stmmac_phylink_setup(struct stmmac_priv *priv)
 {
        struct stmmac_mdio_bus_data *mdio_bus_data;
        struct phylink_config *config;
-       struct fwnode_handle *fwnode;
        struct phylink_pcs *pcs;
        struct phylink *phylink;
 
@@ -1400,11 +1396,8 @@ static int stmmac_phylink_setup(struct stmmac_priv *priv)
                        config->wol_mac_support |= WAKE_MAGIC;
        }
 
-       fwnode = priv->plat->port_node;
-       if (!fwnode)
-               fwnode = dev_fwnode(priv->device);
-
-       phylink = phylink_create(config, fwnode, priv->plat->phy_interface,
+       phylink = phylink_create(config, dev_fwnode(priv->device),
+                                priv->plat->phy_interface,
                                 &stmmac_phylink_mac_ops);
        if (IS_ERR(phylink))
                return PTR_ERR(phylink);
index a7c2496b39f286699da5395ec7e468ca84feaa62..485a0d790baacde4c294148e8990c5fc5165b8ce 100644 (file)
@@ -430,7 +430,7 @@ int stmmac_pcs_setup(struct net_device *ndev)
        struct dw_xpcs *xpcs = NULL;
        int addr, ret;
 
-       devnode = priv->plat->port_node;
+       devnode = dev_fwnode(priv->device);
 
        if (priv->plat->pcs_init) {
                ret = priv->plat->pcs_init(priv);
@@ -649,10 +649,7 @@ int stmmac_mdio_register(struct net_device *ndev)
                stmmac_xgmac2_mdio_read_c45(new_bus, 0, 0, 0);
 
        /* If fixed-link is set, skip PHY scanning */
-       fwnode = priv->plat->port_node;
-       if (!fwnode)
-               fwnode = dev_fwnode(priv->device);
-
+       fwnode = dev_fwnode(priv->device);
        if (fwnode) {
                fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
                if (fixed_node) {
index 5c9fd91a1db9d6f85a18fd997ac4a970157ec59f..c34998486293693ea91da6e1d064b1fa653ad682 100644 (file)
@@ -446,9 +446,6 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac)
         * they are not converted to phylink. */
        plat->phy_node = of_parse_phandle(np, "phy-handle", 0);
 
-       /* PHYLINK automatically parses the phy-handle property */
-       plat->port_node = of_fwnode_handle(np);
-
        /* Get max speed of operation from device tree */
        of_property_read_u32(np, "max-speed", &plat->max_speed);
 
index b96ae9dadfaba6a5933f99d22c257b4917845542..77e51eaa5ec52b91dbd37999fb24458918d4bb82 100644 (file)
@@ -225,7 +225,6 @@ struct plat_stmmacenet_data {
        phy_interface_t phy_interface;
        struct stmmac_mdio_bus_data *mdio_bus_data;
        struct device_node *phy_node;
-       struct fwnode_handle *port_node;
        struct device_node *mdio_node;
        struct stmmac_dma_cfg *dma_cfg;
        struct stmmac_safety_feature_cfg *safety_feat_cfg;