net: stmmac: anarion: remove of_get_phy_mode()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 12 Mar 2025 09:20:36 +0000 (09:20 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 18 Mar 2025 14:53:15 +0000 (15:53 +0100)
devm_stmmac_probe_config_dt() already gets the PHY mode from firmware,
which is stored in plat_dat->phy_interface. Therefore, we don't need to
get it in platform code.

Rearrange the initialisation order so we can pass plat_dat into
anarion_config_dt(), thereby providing plat_dat->phy_interface as
necessary there.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1tsIGS-005uzf-QE@rmk-PC.armlinux.org.uk
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c

index ef99ef3f1ab47961d27c7934841b201d8a972a88..37fe7c2888784b825cba987741d9b940230988b7 100644 (file)
@@ -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;
 
@@ -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:
@@ -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);
        }
 
@@ -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);