]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: stmmac: simplify phylink_suspend() and phylink_resume() calls
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tue, 4 Mar 2025 11:21:27 +0000 (11:21 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 7 Mar 2025 00:37:20 +0000 (16:37 -0800)
Currently, the calls to phylink's suspend and resume functions are
inside overly complex tests, and boil down to:

if (device_may_wakeup(priv->device) && priv->plat->pmt) {
call phylink
} else {
call phylink and
if (device_may_wakeup(priv->device))
do something else
}

This results in phylink always being called, possibly with differing
arguments for phylink_suspend().

Simplify this code, noting that each site is slightly different due to
the order in which phylink is called and the "something else".

Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/E1tpQL1-005St4-Hn@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 767c83b0b2bb48ff954bb17edef276b2caaa360f..a3accab213b035f4b72cd5a8ffd8586fcd9bc35b 100644 (file)
@@ -7842,13 +7842,11 @@ int stmmac_suspend(struct device *dev)
        mutex_unlock(&priv->lock);
 
        rtnl_lock();
-       if (device_may_wakeup(priv->device) && priv->plat->pmt) {
-               phylink_suspend(priv->phylink, true);
-       } else {
-               if (device_may_wakeup(priv->device))
-                       phylink_speed_down(priv->phylink, false);
-               phylink_suspend(priv->phylink, false);
-       }
+       if (device_may_wakeup(priv->device) && !priv->plat->pmt)
+               phylink_speed_down(priv->phylink, false);
+
+       phylink_suspend(priv->phylink,
+                       device_may_wakeup(priv->device) && priv->plat->pmt);
        rtnl_unlock();
 
        if (stmmac_fpe_supported(priv))
@@ -7938,13 +7936,9 @@ int stmmac_resume(struct device *dev)
        }
 
        rtnl_lock();
-       if (device_may_wakeup(priv->device) && priv->plat->pmt) {
-               phylink_resume(priv->phylink);
-       } else {
-               phylink_resume(priv->phylink);
-               if (device_may_wakeup(priv->device))
-                       phylink_speed_up(priv->phylink);
-       }
+       phylink_resume(priv->phylink);
+       if (device_may_wakeup(priv->device) && !priv->plat->pmt)
+               phylink_speed_up(priv->phylink);
        rtnl_unlock();
 
        rtnl_lock();