]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: core: add member wol_enabled to struct net_device
authorHeiner Kallweit <hkallweit1@gmail.com>
Mon, 24 Sep 2018 19:58:59 +0000 (21:58 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 27 Sep 2018 03:04:11 +0000 (20:04 -0700)
Add flag wol_enabled to struct net_device indicating whether
Wake-on-LAN is enabled. As first user phy_suspend() will use it to
decide whether PHY can be suspended or not.

Fixes: f1e911d5d0df ("r8169: add basic phylib support")
Fixes: e8cfd9d6c772 ("net: phy: call state machine synchronously in phy_stop")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h
net/core/ethtool.c

index ca5ab98053c8d48312d9f479a861c6c426b33e54..c7861e4b402c131cfb548f7d0ed863c4ec3ee3e5 100644 (file)
@@ -1730,6 +1730,8 @@ enum netdev_priv_flags {
  *                     switch driver and used to set the phys state of the
  *                     switch port.
  *
+ *     @wol_enabled:   Wake-on-LAN is enabled
+ *
  *     FIXME: cleanup struct net_device such that network protocol info
  *     moves out.
  */
@@ -2014,6 +2016,7 @@ struct net_device {
        struct lock_class_key   *qdisc_tx_busylock;
        struct lock_class_key   *qdisc_running_key;
        bool                    proto_down;
+       unsigned                wol_enabled:1;
 };
 #define to_net_dev(d) container_of(d, struct net_device, dev)
 
index 234a0ec2e9327727e95a76f44a29e8cc93feff84..0762aaf8e964ec4c517984fdff8ddfdc4afef99e 100644 (file)
@@ -1483,6 +1483,7 @@ static int ethtool_get_wol(struct net_device *dev, char __user *useraddr)
 static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
 {
        struct ethtool_wolinfo wol;
+       int ret;
 
        if (!dev->ethtool_ops->set_wol)
                return -EOPNOTSUPP;
@@ -1490,7 +1491,13 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
        if (copy_from_user(&wol, useraddr, sizeof(wol)))
                return -EFAULT;
 
-       return dev->ethtool_ops->set_wol(dev, &wol);
+       ret = dev->ethtool_ops->set_wol(dev, &wol);
+       if (ret)
+               return ret;
+
+       dev->wol_enabled = !!wol.wolopts;
+
+       return 0;
 }
 
 static int ethtool_get_eee(struct net_device *dev, char __user *useraddr)