From: Jiri Benc <jbenc@suse.cz>
To: netdev@vger.kernel.org
Cc: "John W. Linville" <linville@tuxdriver.com>
Subject: [PATCH 2/17] d80211: symlinks to wiphy in sysfs
Date: Fri, 21 Apr 2006 22:11:33 +0200 (CEST) [thread overview]
Message-ID: <20060421201133.2AC98482C2@silver.suse.cz> (raw)
In-Reply-To: <20060421220951.205579000.midnight@suse.cz>
This patch adds symlinks under /sys/net/*/wiphy pointing to
/sys/class/ieee80211/phyX.
This allows new interfaces to be added by writing a new name to e.g.
/sys/net/wlan0/wiphy/add_iface.
Signed-off-by: Jiri Benc <jbenc@suse.cz>
---
net/d80211/ieee80211_dev.c | 16 +++++++++++++
net/d80211/ieee80211_i.h | 1 +
net/d80211/ieee80211_sysfs.c | 51 +++++++++++++++++++++++++++++++++++++++++-
3 files changed, 67 insertions(+), 1 deletions(-)
8ac63bdfba39115673abc492d7eb867c364b0fc4
diff --git a/net/d80211/ieee80211_dev.c b/net/d80211/ieee80211_dev.c
index 4302506..6278cfa 100644
--- a/net/d80211/ieee80211_dev.c
+++ b/net/d80211/ieee80211_dev.c
@@ -83,3 +83,19 @@ struct ieee80211_local *ieee80211_dev_fi
spin_unlock(&dev_list_lock);
return dev_item ? dev_item->local : NULL;
}
+
+int ieee80211_dev_find_index(struct ieee80211_local *local)
+{
+ struct ieee80211_dev_list *dev_item;
+ int index = -1;
+
+ spin_lock(&dev_list_lock);
+ list_for_each_entry(dev_item, &dev_list, list) {
+ if (dev_item->local == local) {
+ index = dev_item->dev_index;
+ break;
+ }
+ }
+ spin_unlock(&dev_list_lock);
+ return index;
+}
diff --git a/net/d80211/ieee80211_i.h b/net/d80211/ieee80211_i.h
index 0c1eeac..c217104 100644
--- a/net/d80211/ieee80211_i.h
+++ b/net/d80211/ieee80211_i.h
@@ -587,6 +587,7 @@ int ieee80211_sta_disassociate(struct ne
int ieee80211_dev_alloc_index(struct ieee80211_local *local);
void ieee80211_dev_free_index(struct ieee80211_local *local);
struct ieee80211_local *ieee80211_dev_find(int index);
+int ieee80211_dev_find_index(struct ieee80211_local *local);
/* ieee80211_sysfs.c */
int ieee80211_register_sysfs(struct ieee80211_local *local);
diff --git a/net/d80211/ieee80211_sysfs.c b/net/d80211/ieee80211_sysfs.c
index 6e7d3ea..32fb380 100644
--- a/net/d80211/ieee80211_sysfs.c
+++ b/net/d80211/ieee80211_sysfs.c
@@ -10,6 +10,7 @@ #include <linux/kernel.h>
#include <linux/device.h>
#include <linux/if.h>
#include <linux/interrupt.h>
+#include <linux/netdevice.h>
#include <linux/rtnetlink.h>
#include <net/d80211.h>
#include "ieee80211_i.h"
@@ -124,12 +125,60 @@ void ieee80211_unregister_sysfs(struct i
class_device_del(&local->class_dev);
}
+static int ieee80211_add_netdevice(struct class_device *cd,
+ struct class_interface *cintf)
+{
+ struct net_device *dev = container_of(cd, struct net_device, class_dev);
+ struct ieee80211_local *local = dev->priv;
+
+ if (ieee80211_dev_find_index(local) < 0)
+ return 0;
+ return sysfs_create_link(&cd->kobj, &local->class_dev.kobj, "wiphy");
+}
+
+static void ieee80211_remove_netdevice(struct class_device *cd,
+ struct class_interface *cintf)
+{
+ struct net_device *dev = container_of(cd, struct net_device, class_dev);
+ struct ieee80211_local *local = dev->priv;
+
+ if (ieee80211_dev_find_index(local) >= 0)
+ sysfs_remove_link(&cd->kobj, "wiphy");
+}
+
+static struct class_interface ieee80211_wiphy_cintf = {
+ .add = ieee80211_add_netdevice,
+ .remove = ieee80211_remove_netdevice,
+};
+
+/* Adds class interface watching for new network devices and adding "wiphy"
+ * attribute (symlink) to them. */
+static int ieee80211_register_wiphy_cintf(void)
+{
+ ieee80211_wiphy_cintf.class = loopback_dev.class_dev.class;
+ return class_interface_register(&ieee80211_wiphy_cintf);
+}
+
+static void ieee80211_unregister_wiphy_cintf(void)
+{
+ class_interface_unregister(&ieee80211_wiphy_cintf);
+}
+
int ieee80211_sysfs_init(void)
{
- return class_register(&ieee80211_class);
+ int result;
+
+ result = class_register(&ieee80211_class);
+ if (result)
+ return result;
+ result = ieee80211_register_wiphy_cintf();
+ if (result)
+ class_unregister(&ieee80211_class);
+ return result;
}
void ieee80211_sysfs_deinit(void)
{
+ ieee80211_unregister_wiphy_cintf();
class_unregister(&ieee80211_class);
}
--
1.3.0
next prev parent reply other threads:[~2006-04-21 20:11 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-21 20:11 [PATCH 0/17] d80211 patches Jiri Benc
2006-04-21 20:11 ` [PATCH 1/17] d80211: Replace MODULE_PARM with module_param Jiri Benc
2006-04-21 20:11 ` Jiri Benc [this message]
2006-04-21 20:11 ` [PATCH 3/17] d80211: allow WDS remote to by set by WE Jiri Benc
2006-04-21 20:11 ` [PATCH 4/17] d80211: add IBSS and monitor interface types Jiri Benc
2006-04-21 20:11 ` [PATCH 5/17] d80211: non-shared " Jiri Benc
2006-04-21 20:11 ` [PATCH 6/17] d80211: remove local->bssid variable Jiri Benc
2006-04-21 20:11 ` [PATCH 7/17] d80211: rename IEEE80211_SUB_IF_TYPE_ constants Jiri Benc
2006-04-21 20:11 ` [PATCH 8/17] d80211: ask driver for allowed iface combinations Jiri Benc
2006-04-21 20:11 ` [PATCH 9/17] d80211: remove obsolete stuff Jiri Benc
2006-04-21 20:11 ` [PATCH 10/17] d80211: fix interface configuration Jiri Benc
2006-04-21 20:11 ` [PATCH 11/17] d80211: rename adm_status to radio_enabled Jiri Benc
2006-04-21 20:11 ` [PATCH 12/17] d80211: interface types changeable by SIOCSIWMODE Jiri Benc
2006-04-21 20:11 ` [PATCH 13/17] d80211: master interface auto up/down Jiri Benc
2006-04-21 20:11 ` [PATCH 14/17] d80211: set_multicast_list Jiri Benc
2006-04-21 20:11 ` [PATCH 15/17] d80211: fix handling of received frames Jiri Benc
2006-04-21 20:11 ` [PATCH 16/17] d80211: fix monitor interfaces Jiri Benc
2006-04-21 20:29 ` Johannes Berg
2006-04-21 20:49 ` Jiri Benc
2006-04-21 20:52 ` Johannes Berg
2006-04-21 20:57 ` Jiri Benc
2006-04-21 21:01 ` Johannes Berg
2006-04-21 21:05 ` Jiri Benc
2006-04-21 21:05 ` Johannes Berg
2006-04-21 20:11 ` [PATCH 17/17] d80211: fix AP interfaces Jiri Benc
2006-04-21 20:52 ` [PATCH 0/17] d80211 patches Michael Buesch
2006-04-21 20:52 ` Jiri Benc
2006-04-26 19:39 ` John W. Linville
2006-04-26 21:27 ` Ivo van Doorn
2006-04-27 12:49 ` Michael Buesch
2006-04-28 15:45 ` [PATCH] bcm43xx_d80211: fix bug in open Jiri Benc
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=20060421201133.2AC98482C2@silver.suse.cz \
--to=jbenc@suse.cz \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).