aboutsummaryrefslogtreecommitdiffstats
path: root/net/ieee802154/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ieee802154/core.c')
-rw-r--r--net/ieee802154/core.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/net/ieee802154/core.c b/net/ieee802154/core.c
index dc294a415d05..ed5b014dbec7 100644
--- a/net/ieee802154/core.c
+++ b/net/ieee802154/core.c
@@ -21,6 +21,7 @@
#include "ieee802154.h"
#include "sysfs.h"
+#include "core.h"
static DEFINE_MUTEX(wpan_phy_mutex);
static int wpan_phy_idx;
@@ -76,31 +77,38 @@ static int wpan_phy_idx_valid(int idx)
return idx >= 0;
}
-struct wpan_phy *wpan_phy_alloc(size_t priv_size)
+struct wpan_phy *
+wpan_phy_alloc(const struct cfg802154_ops *ops, size_t priv_size)
{
- struct wpan_phy *phy = kzalloc(sizeof(*phy) + priv_size,
- GFP_KERNEL);
+ struct cfg802154_registered_device *rdev;
+ size_t alloc_size;
+
+ alloc_size = sizeof(*rdev) + priv_size;
+ rdev = kzalloc(alloc_size, GFP_KERNEL);
+ if (!rdev)
+ return NULL;
+
+ rdev->ops = ops;
- if (!phy)
- goto out;
mutex_lock(&wpan_phy_mutex);
- phy->idx = wpan_phy_idx++;
- if (unlikely(!wpan_phy_idx_valid(phy->idx))) {
+ rdev->wpan_phy.idx = wpan_phy_idx++;
+ if (unlikely(!wpan_phy_idx_valid(rdev->wpan_phy.idx))) {
wpan_phy_idx--;
mutex_unlock(&wpan_phy_mutex);
- kfree(phy);
+ kfree(rdev);
goto out;
}
mutex_unlock(&wpan_phy_mutex);
- mutex_init(&phy->pib_lock);
+ mutex_init(&rdev->wpan_phy.pib_lock);
- device_initialize(&phy->dev);
- dev_set_name(&phy->dev, "wpan-phy%d", phy->idx);
+ device_initialize(&rdev->wpan_phy.dev);
+ dev_set_name(&rdev->wpan_phy.dev, "wpan-phy%d", rdev->wpan_phy.idx);
- phy->dev.class = &wpan_phy_class;
+ rdev->wpan_phy.dev.class = &wpan_phy_class;
+ rdev->wpan_phy.dev.platform_data = rdev;
- return phy;
+ return &rdev->wpan_phy;
out:
return NULL;
@@ -125,6 +133,11 @@ void wpan_phy_free(struct wpan_phy *phy)
}
EXPORT_SYMBOL(wpan_phy_free);
+void cfg802154_dev_free(struct cfg802154_registered_device *rdev)
+{
+ kfree(rdev);
+}
+
static int __init wpan_phy_class_init(void)
{
int rc;