From 6b6ce488f64d5530e1886072f64b034d5a65e5f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bjorn@mork.no>
Date: Fri, 7 Dec 2012 12:14:02 +0100
Subject: [RFC] net: fix ethtool_ops for wireless
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
commit 2c60db03 ("net: provide a default dev->ethtool_ops") made
tests for unset ethtool_ops always fail. This caused a regression
for wireless drivers relying on the wireless specific ethtool_ops
default.
Adding a new test for code which need to know whether ethtool_ops
was changed after netdev allocation, and update the wireless core
to use it.
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
include/linux/netdevice.h | 14 ++++++++++++++
net/core/dev.c | 1 +
net/wireless/core.c | 2 +-
3 files changed, 16 insertions(+), 1 deletion(-)
@@ -2707,6 +2707,20 @@ static inline bool netif_supports_nofcs(struct net_device *dev)
extern struct pernet_operations __net_initdata loopback_net_ops;
+extern struct ethtool_ops default_ethtool_ops;
+
+/**
+ * netdev_has_default_ethtool_ops - test for default ethtool_ops
+ * @dev: device
+ *
+ * This function returns true if dev is using the generic default
+ * ethtool_ops
+ */
+static inline bool netdev_has_default_ethtool_ops(struct net_device *dev)
+{
+ return dev->ethtool_ops && (dev->ethtool_ops == &default_ethtool_ops);
+}
+
/* Logging, debugging and troubleshooting/diagnostic helpers. */
/* netdev_printk helpers, similar to dev_printk */
@@ -6107,6 +6107,7 @@ struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
}
static const struct ethtool_ops default_ethtool_ops;
+EXPORT_SYMBOL_GPL(default_ethtool_ops);
/**
* alloc_netdev_mqs - allocate network device
@@ -866,7 +866,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
/* allow mac80211 to determine the timeout */
wdev->ps_timeout = -1;
- if (!dev->ethtool_ops)
+ if (netdev_has_default_ethtool_ops(dev)
dev->ethtool_ops = &cfg80211_ethtool_ops;
if ((wdev->iftype == NL80211_IFTYPE_STATION ||
--
1.7.10.4