diff options
author | Nikolay Aleksandrov <naleksan@redhat.com> | 2012-09-05 08:11:28 +0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-09-06 01:40:07 +0400 |
commit | c6c13965f4ffca6163af0c9419095aedc103648c (patch) | |
tree | 1c23b7c0dacd86dcde7835070504abb4f0e6caef /net/core | |
parent | f6fe569fe056388166575af1cfaed0bcbc688305 (diff) | |
download | linux-c6c13965f4ffca6163af0c9419095aedc103648c.tar.xz |
net: add unknown state to sysfs NIC duplex export
Currently when the NIC duplex state is DUPLEX_UNKNOWN it is exported as
full through sysfs, this patch adds support for DUPLEX_UNKNOWN. It is
handled the same way as in ethtool.
Signed-off-by: Nikolay Aleksandrov <naleksan@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/net-sysfs.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 72607174ea5a..bcf02f608cbf 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -166,9 +166,21 @@ static ssize_t show_duplex(struct device *dev, if (netif_running(netdev)) { struct ethtool_cmd cmd; - if (!__ethtool_get_settings(netdev, &cmd)) - ret = sprintf(buf, "%s\n", - cmd.duplex ? "full" : "half"); + if (!__ethtool_get_settings(netdev, &cmd)) { + const char *duplex; + switch (cmd.duplex) { + case DUPLEX_HALF: + duplex = "half"; + break; + case DUPLEX_FULL: + duplex = "full"; + break; + default: + duplex = "unknown"; + break; + } + ret = sprintf(buf, "%s\n", duplex); + } } rtnl_unlock(); return ret; |