]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: dsa: Do not suspend/resume closed slave_dev
authorFlorian Fainelli <f.fainelli@gmail.com>
Wed, 1 Aug 2018 00:12:52 +0000 (17:12 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Aug 2018 14:18:19 +0000 (16:18 +0200)
[ Upstream commit a94c689e6c9e72e722f28339e12dff191ee5a265 ]

If a DSA slave network device was previously disabled, there is no need
to suspend or resume it.

Fixes: 2446254915a7 ("net: dsa: allow switch drivers to implement suspend/resume hooks")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/dsa/slave.c

index 18561af7a8f1da0ec92773376ecac9a72a64751c..01fa96f2973443249c9c40e8fb31f1c4c3d320a7 100644 (file)
@@ -1195,6 +1195,9 @@ int dsa_slave_suspend(struct net_device *slave_dev)
 {
        struct dsa_slave_priv *p = netdev_priv(slave_dev);
 
+       if (!netif_running(slave_dev))
+               return 0;
+
        netif_device_detach(slave_dev);
 
        if (slave_dev->phydev) {
@@ -1210,6 +1213,9 @@ int dsa_slave_suspend(struct net_device *slave_dev)
 
 int dsa_slave_resume(struct net_device *slave_dev)
 {
+       if (!netif_running(slave_dev))
+               return 0;
+
        netif_device_attach(slave_dev);
 
        if (slave_dev->phydev) {