Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6c13965 authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by David S. Miller
Browse files

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: default avatarNikolay Aleksandrov <naleksan@redhat.com>

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f6fe569f
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -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;