Commit 418b9a35 authored by David S. Miller's avatar David S. Miller
Browse files

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 982d608f c530c471
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -607,6 +607,9 @@ int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
	struct usbnet *dev = netdev_priv(net);
	struct usbnet *dev = netdev_priv(net);
	u8 opt = 0;
	u8 opt = 0;


	if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
		return -EINVAL;

	if (wolinfo->wolopts & WAKE_PHY)
	if (wolinfo->wolopts & WAKE_PHY)
		opt |= AX_MONITOR_LINK;
		opt |= AX_MONITOR_LINK;
	if (wolinfo->wolopts & WAKE_MAGIC)
	if (wolinfo->wolopts & WAKE_MAGIC)
+3 −0
Original line number Original line Diff line number Diff line
@@ -566,6 +566,9 @@ ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
	struct usbnet *dev = netdev_priv(net);
	struct usbnet *dev = netdev_priv(net);
	u8 opt = 0;
	u8 opt = 0;


	if (wolinfo->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
		return -EINVAL;

	if (wolinfo->wolopts & WAKE_PHY)
	if (wolinfo->wolopts & WAKE_PHY)
		opt |= AX_MONITOR_MODE_RWLC;
		opt |= AX_MONITOR_MODE_RWLC;
	if (wolinfo->wolopts & WAKE_MAGIC)
	if (wolinfo->wolopts & WAKE_MAGIC)
+4 −13
Original line number Original line Diff line number Diff line
@@ -1401,19 +1401,10 @@ static int lan78xx_set_wol(struct net_device *netdev,
	if (ret < 0)
	if (ret < 0)
		return ret;
		return ret;


	pdata->wol = 0;
	if (wol->wolopts & ~WAKE_ALL)
	if (wol->wolopts & WAKE_UCAST)
		return -EINVAL;
		pdata->wol |= WAKE_UCAST;

	if (wol->wolopts & WAKE_MCAST)
	pdata->wol = wol->wolopts;
		pdata->wol |= WAKE_MCAST;
	if (wol->wolopts & WAKE_BCAST)
		pdata->wol |= WAKE_BCAST;
	if (wol->wolopts & WAKE_MAGIC)
		pdata->wol |= WAKE_MAGIC;
	if (wol->wolopts & WAKE_PHY)
		pdata->wol |= WAKE_PHY;
	if (wol->wolopts & WAKE_ARP)
		pdata->wol |= WAKE_ARP;


	device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts);
	device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts);


+3 −0
Original line number Original line Diff line number Diff line
@@ -4506,6 +4506,9 @@ static int rtl8152_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
	if (!rtl_can_wakeup(tp))
	if (!rtl_can_wakeup(tp))
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;


	if (wol->wolopts & ~WAKE_ANY)
		return -EINVAL;

	ret = usb_autopm_get_interface(tp->intf);
	ret = usb_autopm_get_interface(tp->intf);
	if (ret < 0)
	if (ret < 0)
		goto out_set_wol;
		goto out_set_wol;
+3 −0
Original line number Original line Diff line number Diff line
@@ -731,6 +731,9 @@ static int smsc75xx_ethtool_set_wol(struct net_device *net,
	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
	struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]);
	int ret;
	int ret;


	if (wolinfo->wolopts & ~SUPPORTED_WAKE)
		return -EINVAL;

	pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;
	pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE;


	ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts);
	ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts);
Loading