diff options
author | David Daney <david.daney@cavium.com> | 2012-08-21 14:45:08 -0400 |
---|---|---|
committer | David Daney <david.daney@cavium.com> | 2012-08-31 14:49:40 -0400 |
commit | f21105df0f999f468f1f03e1ff53fe055e149341 (patch) | |
tree | 9d5024d59b997a50e42f4341df3a497356840a28 | |
parent | 3d305850261dfbf815eb7a0f0b768d4e1a11485a (diff) |
netdev: octeon_mgmt: Improve ethtool_ops.
Correctly show no link when the interface is down, and return
-EOPNOTSUPP for things that don't work. This quiets the ethtool
program when run on down interfaces.
Signed-off-by: David Daney <david.daney@cavium.com>
Acked-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/octeon/octeon_mgmt.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/net/ethernet/octeon/octeon_mgmt.c b/drivers/net/ethernet/octeon/octeon_mgmt.c index 687a6a0c7147..cf06cf23935e 100644 --- a/drivers/net/ethernet/octeon/octeon_mgmt.c +++ b/drivers/net/ethernet/octeon/octeon_mgmt.c | |||
@@ -1379,7 +1379,7 @@ static int octeon_mgmt_get_settings(struct net_device *netdev, | |||
1379 | if (p->phydev) | 1379 | if (p->phydev) |
1380 | return phy_ethtool_gset(p->phydev, cmd); | 1380 | return phy_ethtool_gset(p->phydev, cmd); |
1381 | 1381 | ||
1382 | return -EINVAL; | 1382 | return -EOPNOTSUPP; |
1383 | } | 1383 | } |
1384 | 1384 | ||
1385 | static int octeon_mgmt_set_settings(struct net_device *netdev, | 1385 | static int octeon_mgmt_set_settings(struct net_device *netdev, |
@@ -1393,14 +1393,28 @@ static int octeon_mgmt_set_settings(struct net_device *netdev, | |||
1393 | if (p->phydev) | 1393 | if (p->phydev) |
1394 | return phy_ethtool_sset(p->phydev, cmd); | 1394 | return phy_ethtool_sset(p->phydev, cmd); |
1395 | 1395 | ||
1396 | return -EINVAL; | 1396 | return -EOPNOTSUPP; |
1397 | } | ||
1398 | |||
1399 | static int octeon_mgmt_nway_reset(struct net_device *dev) | ||
1400 | { | ||
1401 | struct octeon_mgmt *p = netdev_priv(dev); | ||
1402 | |||
1403 | if (!capable(CAP_NET_ADMIN)) | ||
1404 | return -EPERM; | ||
1405 | |||
1406 | if (p->phydev) | ||
1407 | return phy_start_aneg(p->phydev); | ||
1408 | |||
1409 | return -EOPNOTSUPP; | ||
1397 | } | 1410 | } |
1398 | 1411 | ||
1399 | static const struct ethtool_ops octeon_mgmt_ethtool_ops = { | 1412 | static const struct ethtool_ops octeon_mgmt_ethtool_ops = { |
1400 | .get_drvinfo = octeon_mgmt_get_drvinfo, | 1413 | .get_drvinfo = octeon_mgmt_get_drvinfo, |
1401 | .get_link = ethtool_op_get_link, | ||
1402 | .get_settings = octeon_mgmt_get_settings, | 1414 | .get_settings = octeon_mgmt_get_settings, |
1403 | .set_settings = octeon_mgmt_set_settings | 1415 | .set_settings = octeon_mgmt_set_settings, |
1416 | .nway_reset = octeon_mgmt_nway_reset, | ||
1417 | .get_link = ethtool_op_get_link, | ||
1404 | }; | 1418 | }; |
1405 | 1419 | ||
1406 | static const struct net_device_ops octeon_mgmt_ops = { | 1420 | static const struct net_device_ops octeon_mgmt_ops = { |