linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrik Flykt <patrik.flykt@linux.intel.com>
To: linux-bluetooth@vger.kernel.org, linux-wpan@vger.kernel.org
Cc: luiz.von.dentz@intel.com
Subject: [RFC 2/3] 6lowpan: Factor out lowpan device context initialization
Date: Wed, 18 Oct 2017 15:06:14 +0300	[thread overview]
Message-ID: <20171018120615.24126-3-patrik.flykt@linux.intel.com> (raw)
In-Reply-To: <20171018120615.24126-1-patrik.flykt@linux.intel.com>

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(-)

diff --git a/include/net/6lowpan.h b/include/net/6lowpan.h
index 7f21e156c9d6..1df9ecf22a57 100644
--- a/include/net/6lowpan.h
+++ b/include/net/6lowpan.h
@@ -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
  *
diff --git a/net/6lowpan/core.c b/net/6lowpan/core.c
index 40d3d72beb53..29150a2c5e04 100644
--- a/net/6lowpan/core.c
+++ b/net/6lowpan/core.c
@@ -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;
 
-- 
2.11.0


  parent reply	other threads:[~2017-10-18 12:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18 12:06 [RFC 0/3] 6LoWPAN tun/tap device Patrik Flykt
2017-10-18 12:06 ` [RFC 1/3] 6lowpan: Use struct lowpan_dev instead of net_device Patrik Flykt
2017-10-18 12:06 ` Patrik Flykt [this message]
2017-10-18 12:06 ` [RFC 3/3] tun: Add 6LoWPAN compression/decompression to tun driver Patrik Flykt
2017-10-18 12:27   ` Patrik Flykt
2017-10-26 14:54     ` Alexander Aring
2017-10-27  8:35       ` Luiz Augusto von Dentz
2017-10-27 10:19       ` Patrik Flykt
2017-10-18 12:17 ` [RFC 0/3] 6LoWPAN tun/tap device Patrik Flykt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171018120615.24126-3-patrik.flykt@linux.intel.com \
    --to=patrik.flykt@linux.intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=luiz.von.dentz@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).