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)
committerDavid S. Miller <davem@davemloft.net>
Wed, 1 Aug 2018 16:53:45 +0000 (09:53 -0700)
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>
net/dsa/slave.c

index 1e3b6a6d8a40dcf69200ead186a6ab8919e63db6..732369c80644a5eb056a1abd2d7de609082ed059 100644 (file)
@@ -1248,6 +1248,9 @@ int dsa_slave_suspend(struct net_device *slave_dev)
 {
        struct dsa_port *dp = dsa_slave_to_port(slave_dev);
 
+       if (!netif_running(slave_dev))
+               return 0;
+
        netif_device_detach(slave_dev);
 
        rtnl_lock();
@@ -1261,6 +1264,9 @@ int dsa_slave_resume(struct net_device *slave_dev)
 {
        struct dsa_port *dp = dsa_slave_to_port(slave_dev);
 
+       if (!netif_running(slave_dev))
+               return 0;
+
        netif_device_attach(slave_dev);
 
        rtnl_lock();