summaryrefslogtreecommitdiffstats
path: root/net/ieee802154/core.c
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-11-09 08:36:53 +0100
committerMarcel Holtmann <marcel@holtmann.org>2014-11-09 19:50:29 +0100
commit79fe1a2aa7b504c68642e510154f17e2de60da60 (patch)
tree8915b7af57b06dc0185ee5f41a3a010e6a864a06 /net/ieee802154/core.c
parent3ae75e02c34b5b8d521b0470522e540512ce24e3 (diff)
downloadlinux-79fe1a2aa7b504c68642e510154f17e2de60da60.tar.bz2
ieee802154: add nl802154 framework
This patch adds a basic nl802154 framework. Most of this code was grabbed from nl80211 framework. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/ieee802154/core.c')
-rw-r--r--net/ieee802154/core.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index 3ee00bf0e514..ae5ecbc2ca0a 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -21,11 +21,12 @@
#include <net/rtnetlink.h>
#include "ieee802154.h"
+#include "nl802154.h"
#include "sysfs.h"
#include "core.h"
/* RCU-protected (and RTNL for writers) */
-static LIST_HEAD(cfg802154_rdev_list);
+LIST_HEAD(cfg802154_rdev_list);
static int cfg802154_rdev_list_generation;
static int wpan_phy_match(struct device *dev, const void *data)
@@ -74,6 +75,23 @@ int wpan_phy_for_each(int (*fn)(struct wpan_phy *phy, void *data),
}
EXPORT_SYMBOL(wpan_phy_for_each);
+struct cfg802154_registered_device *
+cfg802154_rdev_by_wpan_phy_idx(int wpan_phy_idx)
+{
+ struct cfg802154_registered_device *result = NULL, *rdev;
+
+ ASSERT_RTNL();
+
+ list_for_each_entry(rdev, &cfg802154_rdev_list, list) {
+ if (rdev->wpan_phy_idx == wpan_phy_idx) {
+ result = rdev;
+ break;
+ }
+ }
+
+ return result;
+}
+
struct wpan_phy *
wpan_phy_new(const struct cfg802154_ops *ops, size_t priv_size)
{
@@ -270,8 +288,15 @@ static int __init wpan_phy_class_init(void)
if (rc)
goto err_notifier;
+ rc = nl802154_init();
+ if (rc)
+ goto err_ieee802154_nl;
+
return 0;
+err_ieee802154_nl:
+ ieee802154_nl_exit();
+
err_notifier:
unregister_netdevice_notifier(&cfg802154_netdev_notifier);
err_nl:
@@ -283,6 +308,7 @@ subsys_initcall(wpan_phy_class_init);
static void __exit wpan_phy_class_exit(void)
{
+ nl802154_exit();
ieee802154_nl_exit();
unregister_netdevice_notifier(&cfg802154_netdev_notifier);
wpan_phy_sysfs_exit();