From: Bing Zhao <bzhao@marvell.com>
To: <linux-netdev@vger.kernel.org>, <linux-wireless@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: Paul Stewart <pstew@chromium.org>, Bing Zhao <bzhao@marvell.com>
Subject: [PATCH] net-sysfs: Add entry for nl80211 interface type
Date: Wed, 17 Apr 2013 15:06:09 -0700 [thread overview]
Message-ID: <1366236369-543-1-git-send-email-bzhao@marvell.com> (raw)
Add a "wireless/nl80211_iftype" entry in the net device sysfs
file structure to indicate the mode of the wireless device so
it can be discovered easily from userspace.
Signed-off-by: Paul Stewart <pstew@chromium.org>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
net/core/net-sysfs.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 7427ab5..454bd7f 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -17,6 +17,7 @@
#include <linux/nsproxy.h>
#include <net/sock.h>
#include <net/net_namespace.h>
+#include <net/cfg80211.h>
#include <linux/rtnetlink.h>
#include <linux/vmalloc.h>
#include <linux/export.h>
@@ -448,7 +449,24 @@ static struct attribute_group netstat_group = {
};
#if IS_ENABLED(CONFIG_WIRELESS_EXT) || IS_ENABLED(CONFIG_CFG80211)
+static ssize_t show_nl80211_iftype(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ const struct net_device *netdev = to_net_dev(dev);
+ ssize_t ret = 0;
+
+ if (!rtnl_trylock())
+ return restart_syscall();
+ if (netdev->ieee80211_ptr)
+ ret = sprintf(buf, "%d\n", netdev->ieee80211_ptr->iftype);
+ rtnl_unlock();
+
+ return ret;
+}
+static DEVICE_ATTR(nl80211_iftype, S_IRUGO, show_nl80211_iftype, NULL);
+
static struct attribute *wireless_attrs[] = {
+ &dev_attr_nl80211_iftype.attr,
NULL
};
--
1.7.0.2
next reply other threads:[~2013-04-17 22:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-17 22:06 Bing Zhao [this message]
2013-04-17 22:09 ` Johannes Berg
2013-04-18 6:14 ` Nicolas Cavallari
2013-04-18 6:43 ` Marcel Holtmann
2013-04-18 7:03 ` Paul Stewart
2013-04-18 15:46 ` Marcel Holtmann
[not found] ` <CAMcMvsjh4y=84hM+dCcFvb1xxSq5c3HqTBg6VyaCZkh5s=E5yA@mail.gmail.com>
2013-04-22 13:29 ` Johannes Berg
2013-04-22 13:55 ` Paul Stewart
2013-04-17 22:54 ` Marcel Holtmann
2013-04-18 19:03 ` Bing Zhao
2013-04-18 19:10 ` Marcel Holtmann
2013-04-18 19:18 ` Arend van Spriel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1366236369-543-1-git-send-email-bzhao@marvell.com \
--to=bzhao@marvell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-netdev@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pstew@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®