Skip to content

Commit

Permalink
netdev: octeon_mgmt: Improve ethtool_ops.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Daney committed Aug 31, 2012
1 parent 3d30585 commit f21105d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions drivers/net/ethernet/octeon/octeon_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ static int octeon_mgmt_get_settings(struct net_device *netdev,
if (p->phydev)
return phy_ethtool_gset(p->phydev, cmd);

return -EINVAL;
return -EOPNOTSUPP;
}

static int octeon_mgmt_set_settings(struct net_device *netdev,
Expand All @@ -1393,14 +1393,28 @@ static int octeon_mgmt_set_settings(struct net_device *netdev,
if (p->phydev)
return phy_ethtool_sset(p->phydev, cmd);

return -EINVAL;
return -EOPNOTSUPP;
}

static int octeon_mgmt_nway_reset(struct net_device *dev)
{
struct octeon_mgmt *p = netdev_priv(dev);

if (!capable(CAP_NET_ADMIN))
return -EPERM;

if (p->phydev)
return phy_start_aneg(p->phydev);

return -EOPNOTSUPP;
}

static const struct ethtool_ops octeon_mgmt_ethtool_ops = {
.get_drvinfo = octeon_mgmt_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_settings = octeon_mgmt_get_settings,
.set_settings = octeon_mgmt_set_settings
.set_settings = octeon_mgmt_set_settings,
.nway_reset = octeon_mgmt_nway_reset,
.get_link = ethtool_op_get_link,
};

static const struct net_device_ops octeon_mgmt_ops = {
Expand Down

0 comments on commit f21105d

Please sign in to comment.