From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-stm32@st-md-mailman.stormreply.com,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH RFC net-next 6/7] net: stmmac: add helpers to indicate WoL enable status
Date: Mon, 28 Jul 2025 16:45:57 +0100 [thread overview]
Message-ID: <E1ugQ33-006KDR-Nj@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <aIebMKnQgzQxIY3j@shell.armlinux.org.uk>
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>
---
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 10 ++++++++++
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 +++++------
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 4 ++--
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index e1df59a643e3..2ae7174ec4b8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -373,6 +373,16 @@ enum stmmac_state {
STMMAC_SERVICE_SCHED,
};
+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);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 7d467b494685..f44f8b1b0efa 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -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))
@@ -7939,7 +7938,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);
@@ -7992,7 +7991,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();
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 38b1c04c92a2..19f370bb934c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -954,7 +954,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);
@@ -975,7 +975,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)
--
2.30.2
next prev parent reply other threads:[~2025-07-28 15:46 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-28 15:45 [PATCH RFC net-next 0/7] net: stmmac: EEE and WoL cleanups Russell King (Oracle)
2025-07-28 15:45 ` [PATCH RFC net-next 1/7] net: stmmac: remove unnecessary checks in ethtool eee ops Russell King (Oracle)
2025-07-28 17:03 ` Andrew Lunn
2025-07-28 15:45 ` [PATCH RFC net-next 2/7] net: stmmac: remove write-only mac->pmt Russell King (Oracle)
2025-07-28 17:04 ` Andrew Lunn
2025-07-28 15:45 ` [PATCH RFC net-next 3/7] net: stmmac: remove redundant WoL option validation Russell King (Oracle)
2025-07-28 17:06 ` Andrew Lunn
2025-07-28 15:45 ` [PATCH RFC net-next 4/7] net: stmmac: remove unnecessary "stmmac: wakeup enable" print Russell King (Oracle)
2025-07-28 17:06 ` Andrew Lunn
2025-07-28 15:45 ` [PATCH RFC net-next 5/7] net: stmmac: use core wake IRQ support Russell King (Oracle)
2025-07-28 17:12 ` Andrew Lunn
2025-07-28 15:45 ` Russell King (Oracle) [this message]
2025-07-28 17:28 ` [PATCH RFC net-next 6/7] net: stmmac: add helpers to indicate WoL enable status Andrew Lunn
2025-07-28 17:54 ` Russell King (Oracle)
2025-07-29 8:43 ` [Linux-stm32] " Gatien CHEVALLIER
2025-07-29 9:03 ` Russell King (Oracle)
2025-07-29 9:14 ` Russell King (Oracle)
2025-07-29 15:31 ` Russell King (Oracle)
2025-07-29 12:45 ` Russell King (Oracle)
2025-07-29 13:10 ` Gatien CHEVALLIER
2025-07-29 14:44 ` Russell King (Oracle)
2025-07-29 15:34 ` Gatien CHEVALLIER
2025-07-29 16:35 ` Russell King (Oracle)
2025-07-29 17:27 ` Andrew Lunn
2025-07-29 18:19 ` Russell King (Oracle)
2025-07-29 22:01 ` Florian Fainelli
2025-07-28 15:46 ` [PATCH RFC net-next 7/7] net: stmmac: explain the phylink_speed_down() call in stmmac_release() Russell King (Oracle)
2025-07-28 17:19 ` Andrew Lunn
2025-07-28 17:29 ` Andrew Lunn
2025-07-29 8:47 ` Russell King (Oracle)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1ugQ33-006KDR-Nj@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).