]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: stmmac: add helpers to indicate WoL enable status
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Fri, 15 Aug 2025 11:32:15 +0000 (12:32 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 19 Aug 2025 01:10:12 +0000 (18:10 -0700)
Add two helpers to abstract the WoL enable status at the PHY and MAC to
make the code easier to read.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/E1umsfP-008vKp-U1@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c

index b16b8aeeb58366dff68b376d1812f7bc6681ad85..78d6b3737a26acc372037c4201c4820b727503f7 100644 (file)
@@ -375,6 +375,16 @@ enum stmmac_state {
 
 extern const struct dev_pm_ops stmmac_simple_pm_ops;
 
+static inline bool stmmac_wol_enabled_mac(struct stmmac_priv *priv)
+{
+       return priv->plat->pmt && device_may_wakeup(priv->device);
+}
+
+static inline bool stmmac_wol_enabled_phy(struct stmmac_priv *priv)
+{
+       return !priv->plat->pmt && device_may_wakeup(priv->device);
+}
+
 int stmmac_mdio_unregister(struct net_device *ndev);
 int stmmac_mdio_register(struct net_device *ndev);
 int stmmac_mdio_reset(struct mii_bus *mii);
index db0433d0ce401845ecefbc7dc19a993bb6027ca1..b9e8df90e7b5d929702be6a05a85628cbf06689e 100644 (file)
@@ -7857,7 +7857,7 @@ int stmmac_suspend(struct device *dev)
                priv->plat->serdes_powerdown(ndev, priv->plat->bsp_priv);
 
        /* Enable Power down mode by programming the PMT regs */
-       if (device_may_wakeup(priv->device) && priv->plat->pmt) {
+       if (stmmac_wol_enabled_mac(priv)) {
                stmmac_pmt(priv, priv->hw, priv->wolopts);
                priv->irq_wake = 1;
        } else {
@@ -7868,11 +7868,10 @@ int stmmac_suspend(struct device *dev)
        mutex_unlock(&priv->lock);
 
        rtnl_lock();
-       if (device_may_wakeup(priv->device) && !priv->plat->pmt)
+       if (stmmac_wol_enabled_phy(priv))
                phylink_speed_down(priv->phylink, false);
 
-       phylink_suspend(priv->phylink,
-                       device_may_wakeup(priv->device) && priv->plat->pmt);
+       phylink_suspend(priv->phylink, stmmac_wol_enabled_mac(priv));
        rtnl_unlock();
 
        if (stmmac_fpe_supported(priv))
@@ -7948,7 +7947,7 @@ int stmmac_resume(struct device *dev)
         * this bit because it can generate problems while resuming
         * from another devices (e.g. serial console).
         */
-       if (device_may_wakeup(priv->device) && priv->plat->pmt) {
+       if (stmmac_wol_enabled_mac(priv)) {
                mutex_lock(&priv->lock);
                stmmac_pmt(priv, priv->hw, 0);
                mutex_unlock(&priv->lock);
@@ -8008,7 +8007,7 @@ int stmmac_resume(struct device *dev)
         * workqueue thread, which will race with initialisation.
         */
        phylink_resume(priv->phylink);
-       if (device_may_wakeup(priv->device) && !priv->plat->pmt)
+       if (stmmac_wol_enabled_phy(priv))
                phylink_speed_up(priv->phylink);
 
        rtnl_unlock();
index c849676d98e8c998a10fb83948eb85cb5fc9b542..a3e077f225d1dcb33a992158ff89a70a16cac787 100644 (file)
@@ -934,7 +934,7 @@ static int __maybe_unused stmmac_pltfr_noirq_suspend(struct device *dev)
        if (!netif_running(ndev))
                return 0;
 
-       if (!device_may_wakeup(priv->device) || !priv->plat->pmt) {
+       if (!stmmac_wol_enabled_mac(priv)) {
                /* Disable clock in case of PWM is off */
                clk_disable_unprepare(priv->plat->clk_ptp_ref);
 
@@ -955,7 +955,7 @@ static int __maybe_unused stmmac_pltfr_noirq_resume(struct device *dev)
        if (!netif_running(ndev))
                return 0;
 
-       if (!device_may_wakeup(priv->device) || !priv->plat->pmt) {
+       if (!stmmac_wol_enabled_mac(priv)) {
                /* enable the clk previously disabled */
                ret = pm_runtime_force_resume(dev);
                if (ret)