]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: stmmac: add suspend()/resume() platform ops
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 11 Aug 2025 18:50:43 +0000 (19:50 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 13 Aug 2025 01:04:53 +0000 (18:04 -0700)
Add suspend/resume platform operations, which, when populated, override
the init/exit platform operations when we suspend and resume. These
suspend()/resume() methods are called by core code, and thus are
designed to support any struct device, not just platform devices. This
allows them to be used by the PCI drivers we have.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/E1ulXbX-008gqZ-Bb@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_platform.c
include/linux/stmmac.h

index f1abf4242cd2fb34d1c0d5e969d26de3a7ebdadc..2da4f7bb2899534fba74a26f3a12e0fe960bed9f 100644 (file)
@@ -7879,6 +7879,9 @@ int stmmac_suspend(struct device *dev)
        if (stmmac_fpe_supported(priv))
                ethtool_mmsv_stop(&priv->fpe_cfg.mmsv);
 
+       if (priv->plat->suspend)
+               return priv->plat->suspend(dev, priv->plat->bsp_priv);
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(stmmac_suspend);
@@ -7931,6 +7934,12 @@ int stmmac_resume(struct device *dev)
        struct stmmac_priv *priv = netdev_priv(ndev);
        int ret;
 
+       if (priv->plat->resume) {
+               ret = priv->plat->resume(dev, priv->plat->bsp_priv);
+               if (ret)
+                       return ret;
+       }
+
        if (!netif_running(ndev))
                return 0;
 
index 030fcf1b5993a45ae9f693825a0f6856cd248c54..21df052eeed04c0ba35e848900bad4e2b4d4715e 100644 (file)
@@ -901,7 +901,9 @@ static int __maybe_unused stmmac_pltfr_suspend(struct device *dev)
        struct platform_device *pdev = to_platform_device(dev);
 
        ret = stmmac_suspend(dev);
-       stmmac_pltfr_exit(pdev, priv->plat);
+
+       if (!priv->plat->suspend)
+               stmmac_pltfr_exit(pdev, priv->plat);
 
        return ret;
 }
@@ -920,9 +922,11 @@ static int __maybe_unused stmmac_pltfr_resume(struct device *dev)
        struct platform_device *pdev = to_platform_device(dev);
        int ret;
 
-       ret = stmmac_pltfr_init(pdev, priv->plat);
-       if (ret)
-               return ret;
+       if (!priv->plat->resume) {
+               ret = stmmac_pltfr_init(pdev, priv->plat);
+               if (ret)
+                       return ret;
+       }
 
        return stmmac_resume(dev);
 }
index 26ddf95d23f95490327d3edefb307d243d4b5e7e..22c24dacbc6519bc82c009f3adeb54cf3739394d 100644 (file)
@@ -248,6 +248,8 @@ struct plat_stmmacenet_data {
        void (*ptp_clk_freq_config)(struct stmmac_priv *priv);
        int (*init)(struct platform_device *pdev, void *priv);
        void (*exit)(struct platform_device *pdev, void *priv);
+       int (*suspend)(struct device *dev, void *priv);
+       int (*resume)(struct device *dev, void *priv);
        struct mac_device_info *(*setup)(void *priv);
        int (*clks_config)(void *priv, bool enabled);
        int (*crosststamp)(ktime_t *device, struct system_counterval_t *system,