* [PATCH] net: add unknown state to sysfs NIC duplex export
@ 2012-09-05 14:11 Nikolay Aleksandrov
2012-09-05 21:40 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Aleksandrov @ 2012-09-05 14:11 UTC (permalink / raw)
To: netdev
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>
---
net/core/net-sysfs.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 7260717..7720fb1 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)) {
+ 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;
--
1.7.11.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: add unknown state to sysfs NIC duplex export
2012-09-05 14:11 [PATCH] net: add unknown state to sysfs NIC duplex export Nikolay Aleksandrov
@ 2012-09-05 21:40 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-09-05 21:40 UTC (permalink / raw)
To: naleksan; +Cc: netdev
From: Nikolay Aleksandrov <naleksan@redhat.com>
Date: Wed, 5 Sep 2012 16:11:28 +0200
> 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>
Applied with two minor corrections:
> + char *duplex;
I made this "const char *"
> + switch(cmd.duplex) {
I added the missing space between 'switch' and '(cmd.duplex)'.
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-05 21:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-05 14:11 [PATCH] net: add unknown state to sysfs NIC duplex export Nikolay Aleksandrov
2012-09-05 21:40 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).