OSDN Git Service

net: stmmac: Move device_can_wakeup() check earlier in set_wol
authorJisheng Zhang <Jisheng.Zhang@synaptics.com>
Mon, 27 Jul 2020 11:02:13 +0000 (19:02 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 Jul 2020 00:48:20 +0000 (17:48 -0700)
If !device_can_wakeup(), there's no need to futher check. And return
-EOPNOTSUPP rather than -EINVAL if !device_can_wakeup().

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c

index 9e0af62..79795be 100644 (file)
@@ -615,15 +615,15 @@ static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
        struct stmmac_priv *priv = netdev_priv(dev);
        u32 support = WAKE_MAGIC | WAKE_UCAST;
 
+       if (!device_can_wakeup(priv->device))
+               return -EOPNOTSUPP;
+
        /* By default almost all GMAC devices support the WoL via
         * magic frame but we can disable it if the HW capability
         * register shows no support for pmt_magic_frame. */
        if ((priv->hw_cap_support) && (!priv->dma_cap.pmt_magic_frame))
                wol->wolopts &= ~WAKE_MAGIC;
 
-       if (!device_can_wakeup(priv->device))
-               return -EINVAL;
-
        if (wol->wolopts & ~support)
                return -EINVAL;