]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: stmmac: socfpga: provide init function
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thu, 17 Apr 2025 17:13:17 +0000 (18:13 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 22 Apr 2025 01:47:57 +0000 (18:47 -0700)
Both the resume and probe path needs to configure the phy mode, so
provide a common function to do this which can later be hooked into
plat_dat->init.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/E1u5Snd-001IJe-Cx@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c

index bcdb25ee2a3332b0f1938f4619761da16a7b3e21..c333ec07d15fad8e6ef41f65fb1bd6b9490b7040 100644 (file)
@@ -435,6 +435,13 @@ static struct phylink_pcs *socfpga_dwmac_select_pcs(struct stmmac_priv *priv,
        return priv->hw->phylink_pcs;
 }
 
+static int socfpga_dwmac_init(struct platform_device *pdev, void *bsp_priv)
+{
+       struct socfpga_dwmac *dwmac = bsp_priv;
+
+       return dwmac->ops->set_phy_mode(dwmac);
+}
+
 static int socfpga_dwmac_probe(struct platform_device *pdev)
 {
        struct plat_stmmacenet_data *plat_dat;
@@ -497,7 +504,7 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       ret = ops->set_phy_mode(dwmac);
+       ret = socfpga_dwmac_init(pdev, dwmac);
        if (ret)
                goto err_dvr_remove;
 
@@ -512,11 +519,9 @@ err_dvr_remove:
 #ifdef CONFIG_PM_SLEEP
 static int socfpga_dwmac_resume(struct device *dev)
 {
-       struct net_device *ndev = dev_get_drvdata(dev);
-       struct stmmac_priv *priv = netdev_priv(ndev);
        struct socfpga_dwmac *dwmac_priv = get_stmmac_bsp_priv(dev);
 
-       dwmac_priv->ops->set_phy_mode(priv->plat->bsp_priv);
+       socfpga_dwmac_init(to_platform_device(dev), dwmac_priv);
 
        return stmmac_resume(dev);
 }