net: bcmgenet: return EOPNOTSUPP for unknown ioctl commands
authorDoug Berger <opendmb@gmail.com>
Tue, 14 Mar 2017 00:41:39 +0000 (17:41 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Mar 2017 04:51:50 +0000 (21:51 -0700)
This commit changes the ioctl handling behavior to return the
EOPNOTSUPP error code instead of the EINVAL error code when an
unknown ioctl command value is detected.

It also removes some redundant parsing of the ioctl command value
and allows the SIOCSHWTSTAMP value to be handled.

Signed-off-by: Doug Berger <opendmb@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/genet/bcmgenet.c

index d90d366b286f31f4c66bbdfe6b2ffba14af88965..3b49c14128e2a332c338e7bf247b98c76a2d135f 100644 (file)
@@ -1062,27 +1062,14 @@ static void bcmgenet_power_up(struct bcmgenet_priv *priv,
 static int bcmgenet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
        struct bcmgenet_priv *priv = netdev_priv(dev);
-       int val = 0;
 
        if (!netif_running(dev))
                return -EINVAL;
 
-       switch (cmd) {
-       case SIOCGMIIPHY:
-       case SIOCGMIIREG:
-       case SIOCSMIIREG:
-               if (!priv->phydev)
-                       val = -ENODEV;
-               else
-                       val = phy_mii_ioctl(priv->phydev, rq, cmd);
-               break;
-
-       default:
-               val = -EINVAL;
-               break;
-       }
+       if (!priv->phydev)
+               return -ENODEV;
 
-       return val;
+       return phy_mii_ioctl(priv->phydev, rq, cmd);
 }
 
 static struct enet_cb *bcmgenet_get_txcb(struct bcmgenet_priv *priv,