summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-11-09 08:36:48 +0100
committerMarcel Holtmann <marcel@holtmann.org>2014-11-09 19:50:28 +0100
commitf3ada640c25f2d57beef79b7b98619748be3f3ca (patch)
tree857fcf7f0017be551269badb5b5144bd8f12285f
parentf601379fa113906b8bf4389a62002def283519c9 (diff)
downloadop-kernel-dev-f3ada640c25f2d57beef79b7b98619748be3f3ca.zip
op-kernel-dev-f3ada640c25f2d57beef79b7b98619748be3f3ca.tar.gz
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>
-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 a3aa23f..11a1d2e 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -18,11 +18,16 @@
#include <linux/device.h>
#include <net/cfg802154.h>
+#include <net/rtnetlink.h>
#include "ieee802154.h"
#include "sysfs.h"
#include "core.h"
+/* RCU-protected (and RTNL for writers) */
+static LIST_HEAD(cfg802154_rdev_list);
+static int cfg802154_rdev_list_generation;
+
static int wpan_phy_match(struct device *dev, const void *data)
{
return !strcmp(dev_name(dev), (const char *)data);
@@ -109,13 +114,51 @@ EXPORT_SYMBOL(wpan_phy_new);
int wpan_phy_register(struct wpan_phy *phy)
{
- return device_add(&phy->dev);
+ struct cfg802154_registered_device *rdev = wpan_phy_to_rdev(phy);
+ int ret;
+
+ rtnl_lock();
+ ret = device_add(&phy->dev);
+ if (ret) {
+ rtnl_unlock();
+ return ret;
+ }
+
+ list_add_rcu(&rdev->list, &cfg802154_rdev_list);
+ cfg802154_rdev_list_generation++;
+
+ /* TODO phy registered lock */
+ rtnl_unlock();
+
+ /* TODO nl802154 phy notify */
+
+ return 0;
}
EXPORT_SYMBOL(wpan_phy_register);
void wpan_phy_unregister(struct wpan_phy *phy)
{
+ struct cfg802154_registered_device *rdev = wpan_phy_to_rdev(phy);
+
+ /* TODO open count */
+
+ rtnl_lock();
+ /* TODO nl802154 phy notify */
+ /* TODO phy registered lock */
+
+ /* TODO WARN_ON wpan_dev_list */
+
+ /* First remove the hardware from everywhere, this makes
+ * it impossible to find from userspace.
+ */
+ list_del_rcu(&rdev->list);
+ synchronize_rcu();
+
+ cfg802154_rdev_list_generation++;
+
device_del(&phy->dev);
+
+ rtnl_unlock();
}
EXPORT_SYMBOL(wpan_phy_unregister);
diff --git a/net/ieee802154/core.h b/net/ieee802154/core.h
index fea60b3..38887cb2 100644
--- a/net/ieee802154/core.h
+++ b/net/ieee802154/core.h
@@ -5,6 +5,7 @@
struct cfg802154_registered_device {
const struct cfg802154_ops *ops;
+ struct list_head list;
/* wpan_phy index, internal only */
int wpan_phy_idx;
OpenPOWER on IntegriCloud