mirror of
https://github.com/torvalds/linux.git
synced 2026-05-05 23:05:25 -04:00
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) <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>
This commit is contained in:
committed by
Jakub Kicinski
parent
d09413dd25
commit
6a9a6ce962
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user