@@ -289,6 +289,8 @@ int lowpan_register_netdev(struct net_device *dev,
void lowpan_unregister_netdevice(struct net_device *dev);
void lowpan_unregister_netdev(struct net_device *dev);
+int lowpan_initialize_ctx(struct lowpan_dev *ldev, enum lowpan_lltypes lltype);
+
/**
* lowpan_header_decompress - replace 6LoWPAN header with IPv6 header
*
@@ -18,10 +18,24 @@
#include "6lowpan_i.h"
+int lowpan_initialize_ctx(struct lowpan_dev *ldev, enum lowpan_lltypes lltype)
+{
+ int i;
+
+ ldev->lltype = lltype;
+
+ spin_lock_init(&ldev->ctx.lock);
+ for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
+ ldev->ctx.table[i].id = i;
+
+ return 0;
+}
+EXPORT_SYMBOL(lowpan_initialize_ctx);
+
int lowpan_register_netdevice(struct net_device *dev,
enum lowpan_lltypes lltype)
{
- int i, ret;
+ int ret;
switch (lltype) {
case LOWPAN_LLTYPE_IEEE802154:
@@ -36,11 +50,7 @@ int lowpan_register_netdevice(struct net_device *dev,
dev->type = ARPHRD_6LOWPAN;
dev->mtu = IPV6_MIN_MTU;
- lowpan_dev(dev)->lltype = lltype;
-
- spin_lock_init(&lowpan_dev(dev)->ctx.lock);
- for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
- lowpan_dev(dev)->ctx.table[i].id = i;
+ lowpan_initialize_ctx(lowpan_dev(dev), lltype);
dev->ndisc_ops = &lowpan_ndisc_ops;
6lowpan context initialization will be used in other places, factor it out without any changes in functionality. Signed-off-by: Patrik Flykt <patrik.flykt@linux.intel.com> --- include/net/6lowpan.h | 2 ++ net/6lowpan/core.c | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-)