Skip to content

Commit 86aa4a5

Browse files
Russell King (Oracle)NipaLocal
authored andcommitted
net: stmmac: add helpers to indicate WoL enable status
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) <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 722a1e5 commit 86aa4a5

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,16 @@ enum stmmac_state {
375375

376376
extern const struct dev_pm_ops stmmac_simple_pm_ops;
377377

378+
static inline bool stmmac_wol_enabled_mac(struct stmmac_priv *priv)
379+
{
380+
return priv->plat->pmt && device_may_wakeup(priv->device);
381+
}
382+
383+
static inline bool stmmac_wol_enabled_phy(struct stmmac_priv *priv)
384+
{
385+
return !priv->plat->pmt && device_may_wakeup(priv->device);
386+
}
387+
378388
int stmmac_mdio_unregister(struct net_device *ndev);
379389
int stmmac_mdio_register(struct net_device *ndev);
380390
int stmmac_mdio_reset(struct mii_bus *mii);

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7857,7 +7857,7 @@ int stmmac_suspend(struct device *dev)
78577857
priv->plat->serdes_powerdown(ndev, priv->plat->bsp_priv);
78587858

78597859
/* Enable Power down mode by programming the PMT regs */
7860-
if (device_may_wakeup(priv->device) && priv->plat->pmt) {
7860+
if (stmmac_wol_enabled_mac(priv)) {
78617861
stmmac_pmt(priv, priv->hw, priv->wolopts);
78627862
priv->irq_wake = 1;
78637863
} else {
@@ -7868,11 +7868,10 @@ int stmmac_suspend(struct device *dev)
78687868
mutex_unlock(&priv->lock);
78697869

78707870
rtnl_lock();
7871-
if (device_may_wakeup(priv->device) && !priv->plat->pmt)
7871+
if (stmmac_wol_enabled_phy(priv))
78727872
phylink_speed_down(priv->phylink, false);
78737873

7874-
phylink_suspend(priv->phylink,
7875-
device_may_wakeup(priv->device) && priv->plat->pmt);
7874+
phylink_suspend(priv->phylink, stmmac_wol_enabled_mac(priv));
78767875
rtnl_unlock();
78777876

78787877
if (stmmac_fpe_supported(priv))
@@ -7948,7 +7947,7 @@ int stmmac_resume(struct device *dev)
79487947
* this bit because it can generate problems while resuming
79497948
* from another devices (e.g. serial console).
79507949
*/
7951-
if (device_may_wakeup(priv->device) && priv->plat->pmt) {
7950+
if (stmmac_wol_enabled_mac(priv)) {
79527951
mutex_lock(&priv->lock);
79537952
stmmac_pmt(priv, priv->hw, 0);
79547953
mutex_unlock(&priv->lock);
@@ -8008,7 +8007,7 @@ int stmmac_resume(struct device *dev)
80088007
* workqueue thread, which will race with initialisation.
80098008
*/
80108009
phylink_resume(priv->phylink);
8011-
if (device_may_wakeup(priv->device) && !priv->plat->pmt)
8010+
if (stmmac_wol_enabled_phy(priv))
80128011
phylink_speed_up(priv->phylink);
80138012

80148013
rtnl_unlock();

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ static int __maybe_unused stmmac_pltfr_noirq_suspend(struct device *dev)
934934
if (!netif_running(ndev))
935935
return 0;
936936

937-
if (!device_may_wakeup(priv->device) || !priv->plat->pmt) {
937+
if (!stmmac_wol_enabled_mac(priv)) {
938938
/* Disable clock in case of PWM is off */
939939
clk_disable_unprepare(priv->plat->clk_ptp_ref);
940940

@@ -955,7 +955,7 @@ static int __maybe_unused stmmac_pltfr_noirq_resume(struct device *dev)
955955
if (!netif_running(ndev))
956956
return 0;
957957

958-
if (!device_may_wakeup(priv->device) || !priv->plat->pmt) {
958+
if (!stmmac_wol_enabled_mac(priv)) {
959959
/* enable the clk previously disabled */
960960
ret = pm_runtime_force_resume(dev);
961961
if (ret)

0 commit comments

Comments
 (0)