aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-09-29 14:31:30 -0400
committerDavid S. Miller <davem@davemloft.net>2018-09-29 14:31:30 -0400
commit418b9a353a821f5d1787fd310d2af31232e9ff32 (patch)
tree99eb3b37a0ed4201fb5ec88b0d78f07f5de92efb
parent982d608f0f6a9f2700f1a2b35538d686898f78ae (diff)
parentc530c471ba37bdd9fe1c7185b01455c00ae606fb (diff)
Merge branch 'net-usb-Check-for-Wake-on-LAN-modes'
Florian Fainelli says: ==================== net: usb: Check for Wake-on-LAN modes Most of our USB Ethernet drivers don't seem to be checking properly whether the user is supplying a correct Wake-on-LAN mode to enter, so the experience as an user could be confusing, since it would generally lead to either no wake-up, or the device not being marked for wake-up. Please review! Changes in v2: - fixed lan78xx handling, thanks Woojung! ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/asix_common.c3
-rw-r--r--drivers/net/usb/ax88179_178a.c3
-rw-r--r--drivers/net/usb/lan78xx.c17
-rw-r--r--drivers/net/usb/r8152.c3
-rw-r--r--drivers/net/usb/smsc75xx.c3
-rw-r--r--drivers/net/usb/smsc95xx.c3
-rw-r--r--drivers/net/usb/sr9800.c3
7 files changed, 22 insertions, 13 deletions
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index e95dd12edec4..023b8d0bf175 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -607,6 +607,9 @@ int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
607 struct usbnet *dev = netdev_priv(net); 607 struct usbnet *dev = netdev_priv(net);
608 u8 opt = 0; 608 u8 opt = 0;
609 609
610 if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
611 return -EINVAL;
612
610 if (wolinfo->wolopts & WAKE_PHY) 613 if (wolinfo->wolopts & WAKE_PHY)
611 opt |= AX_MONITOR_LINK; 614 opt |= AX_MONITOR_LINK;
612 if (wolinfo->wolopts & WAKE_MAGIC) 615 if (wolinfo->wolopts & WAKE_MAGIC)
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 9e8ad372f419..2207f7a7d1ff 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -566,6 +566,9 @@ ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
566 struct usbnet *dev = netdev_priv(net); 566 struct usbnet *dev = netdev_priv(net);
567 u8 opt = 0; 567 u8 opt = 0;
568 568
569 if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
570 return -EINVAL;
571
569 if (wolinfo->wolopts & WAKE_PHY) 572 if (wolinfo->wolopts & WAKE_PHY)
570 opt |= AX_MONITOR_MODE_RWLC; 573 opt |= AX_MONITOR_MODE_RWLC;
571 if (wolinfo->wolopts & WAKE_MAGIC) 574 if (wolinfo->wolopts & WAKE_MAGIC)
diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index a9991c5f4736..c3c9ba44e2a1 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -1401,19 +1401,10 @@ static int lan78xx_set_wol(struct net_device *netdev,
1401 if (ret < 0) 1401 if (ret < 0)
1402 return ret; 1402 return ret;
1403 1403
1404 pdata->wol = 0; 1404 if (wol->wolopts & ~WAKE_ALL)
1405 if (wol->wolopts & WAKE_UCAST) 1405 return -EINVAL;
1406 pdata->wol |= WAKE_UCAST; 1406
1407 if (wol->wolopts & WAKE_MCAST) 1407 pdata->wol = wol->wolopts;
1408 pdata->wol |= WAKE_MCAST;
1409 if (wol->wolopts & WAKE_BCAST)
1410 pdata->wol |= WAKE_BCAST;
1411 if (wol->wolopts & WAKE_MAGIC)
1412 pdata->wol |= WAKE_MAGIC;
1413 if (wol->wolopts & WAKE_PHY)
1414 pdata->wol |= WAKE_PHY;
1415 if (wol->wolopts & WAKE_ARP)
1416 pdata->wol |= WAKE_ARP;
1417 1408
1418 device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts); 1409 device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts);
1419 1410
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 2cd71bdb6484..f1b5201cc320 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -4506,6 +4506,9 @@ static int rtl8152_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
4506 if (!rtl_can_wakeup(tp)) 4506 if (!rtl_can_wakeup(tp))
4507 return -EOPNOTSUPP; 4507 return -EOPNOTSUPP;
4508 4508
4509 if (wol->wolopts & ~WAKE_ANY)
4510 return -EINVAL;
4511
4509 ret = usb_autopm_get_interface(tp->intf); 4512 ret = usb_autopm_get_interface(tp->intf);
4510 if (ret < 0) 4513 if (ret < 0)
4511 goto out_set_wol; 4514 goto out_set_wol;
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index 05553d252446..e5a4cbb366dc 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -731,6 +731,9 @@ static int smsc75xx_ethtool_set_wol(struct net_device *net,
731 struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); 731 struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
732 int ret; 732 int ret;
733 733
734 if (wolinfo->wolopts & ~SUPPORTED_WAKE)
735 return -EINVAL;
736
734 pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; 737 pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
735 738
736 ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts); 739 ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts);
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 06b4d290784d..262e7a3c23cb 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -774,6 +774,9 @@ static int smsc95xx_ethtool_set_wol(struct net_device *net,
774 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); 774 struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
775 int ret; 775 int ret;
776 776
777 if (wolinfo->wolopts & ~SUPPORTED_WAKE)
778 return -EINVAL;
779
777 pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; 780 pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
778 781
779 ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts); 782 ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts);
diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
index 9277a0f228df..35f39f23d881 100644
--- a/drivers/net/usb/sr9800.c
+++ b/drivers/net/usb/sr9800.c
@@ -421,6 +421,9 @@ sr_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
421 struct usbnet *dev = netdev_priv(net); 421 struct usbnet *dev = netdev_priv(net);
422 u8 opt = 0; 422 u8 opt = 0;
423 423
424 if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
425 return -EINVAL;
426
424 if (wolinfo->wolopts & WAKE_PHY) 427 if (wolinfo->wolopts & WAKE_PHY)
425 opt |= SR_MONITOR_LINK; 428 opt |= SR_MONITOR_LINK;
426 if (wolinfo->wolopts & WAKE_MAGIC) 429 if (wolinfo->wolopts & WAKE_MAGIC)