aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-11-09 02:36:48 -0500
committerMarcel Holtmann <marcel@holtmann.org>2014-11-09 13:50:28 -0500
commitf3ada640c25f2d57beef79b7b98619748be3f3ca (patch)
tree857fcf7f0017be551269badb5b5144bd8f12285f /net
parentf601379fa113906b8bf4389a62002def283519c9 (diff)
ieee802154: add cfg802154_registered_device list
This patch adds a new cfg802154_rdev_list to remember all registered cfg802154_registered_device structs. This is needed to prepare the upcomming nl802154 framework. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/ieee802154/core.c45
-rw-r--r--net/ieee802154/core.h1
2 files changed, 45 insertions, 1 deletions
diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index a3aa23f8c36c..11a1d2ed5b26 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -18,11 +18,16 @@
18#include <linux/device.h> 18#include <linux/device.h>
19 19
20#include <net/cfg802154.h> 20#include <net/cfg802154.h>
21#include <net/rtnetlink.h>
21 22
22#include "ieee802154.h" 23#include "ieee802154.h"
23#include "sysfs.h" 24#include "sysfs.h"
24#include "core.h" 25#include "core.h"
25 26
27/* RCU-protected (and RTNL for writers) */
28static LIST_HEAD(cfg802154_rdev_list);
29static int cfg802154_rdev_list_generation;
30
26static int wpan_phy_match(struct device *dev, const void *data) 31static int wpan_phy_match(struct device *dev, const void *data)
27{ 32{
28 return !strcmp(dev_name(dev), (const char *)data); 33 return !strcmp(dev_name(dev), (const char *)data);
@@ -109,13 +114,51 @@ EXPORT_SYMBOL(wpan_phy_new);
109 114
110int wpan_phy_register(struct wpan_phy *phy) 115int wpan_phy_register(struct wpan_phy *phy)
111{ 116{
112 return device_add(&phy->dev); 117 struct cfg802154_registered_device *rdev = wpan_phy_to_rdev(phy);
118 int ret;
119
120 rtnl_lock();
121 ret = device_add(&phy->dev);
122 if (ret) {
123 rtnl_unlock();
124 return ret;
125 }
126
127 list_add_rcu(&rdev->list, &cfg802154_rdev_list);
128 cfg802154_rdev_list_generation++;
129
130 /* TODO phy registered lock */
131 rtnl_unlock();
132
133 /* TODO nl802154 phy notify */
134
135 return 0;
113} 136}
114EXPORT_SYMBOL(wpan_phy_register); 137EXPORT_SYMBOL(wpan_phy_register);
115 138
116void wpan_phy_unregister(struct wpan_phy *phy) 139void wpan_phy_unregister(struct wpan_phy *phy)
117{ 140{
141 struct cfg802154_registered_device *rdev = wpan_phy_to_rdev(phy);
142
143 /* TODO open count */
144
145 rtnl_lock();
146 /* TODO nl802154 phy notify */
147 /* TODO phy registered lock */
148
149 /* TODO WARN_ON wpan_dev_list */
150
151 /* First remove the hardware from everywhere, this makes
152 * it impossible to find from userspace.
153 */
154 list_del_rcu(&rdev->list);
155 synchronize_rcu();
156
157 cfg802154_rdev_list_generation++;
158
118 device_del(&phy->dev); 159 device_del(&phy->dev);
160
161 rtnl_unlock();
119} 162}
120EXPORT_SYMBOL(wpan_phy_unregister); 163EXPORT_SYMBOL(wpan_phy_unregister);
121 164
diff --git a/net/ieee802154/core.h b/net/ieee802154/core.h
index fea60b3a8846..38887cb2eaf4 100644
--- a/net/ieee802154/core.h
+++ b/net/ieee802154/core.h
@@ -5,6 +5,7 @@
5 5
6struct cfg802154_registered_device { 6struct cfg802154_registered_device {
7 const struct cfg802154_ops *ops; 7 const struct cfg802154_ops *ops;
8 struct list_head list;
8 9
9 /* wpan_phy index, internal only */ 10 /* wpan_phy index, internal only */
10 int wpan_phy_idx; 11 int wpan_phy_idx;