linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jukka Rissanen <jukka.rissanen@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v4 4/5] Bluetooth: 6LoWPAN: Count module usage
Date: Mon,  2 Jun 2014 13:08:23 +0300	[thread overview]
Message-ID: <1401703704-22451-5-git-send-email-jukka.rissanen@linux.intel.com> (raw)
In-Reply-To: <1401703704-22451-1-git-send-email-jukka.rissanen@linux.intel.com>

Count how many 6LoWPAN connections there exists so that we
do not unload the module if there are still connections alive.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
---
 net/bluetooth/6lowpan.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 79e753b..ae0413f 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -101,6 +101,8 @@ static inline bool peer_del(struct lowpan_dev *dev, struct lowpan_peer *peer)
 {
 	list_del(&peer->list);
 
+	module_put(THIS_MODULE);
+
 	if (atomic_dec_and_test(&dev->peer_count)) {
 		BT_DBG("last peer");
 		return true;
@@ -728,6 +730,9 @@ static inline void bt_6lowpan_chan_ready_cb(struct l2cap_chan *chan)
 		}
 	}
 
+	if (!try_module_get(THIS_MODULE))
+		return;
+
 	add_peer_chan(chan, dev);
 	ifup(dev->netdev);
 }
-- 
1.8.3.1


  parent reply	other threads:[~2014-06-02 10:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-02 10:08 [PATCH v4 0/5] Bluetooth LE 6LoWPAN using CoC Jukka Rissanen
2014-06-02 10:08 ` [PATCH v4 1/5] Bluetooth: Refactor l2cap_sock_sendmsg() to copy user buffer Jukka Rissanen
2014-06-02 12:09   ` Marcel Holtmann
2014-06-02 12:23     ` Jukka Rissanen
2014-06-02 10:08 ` [PATCH v4 2/5] Bluetooth: 6LoWPAN: Use connected oriented channel instead of fixed one Jukka Rissanen
2014-06-02 12:20   ` Marcel Holtmann
2014-06-02 10:08 ` [PATCH v4 3/5] Bluetooth: 6LoWPAN: Create a kernel module Jukka Rissanen
2014-06-02 10:08 ` Jukka Rissanen [this message]
2014-06-02 10:08 ` [PATCH v4 5/5] Bluetooth: 6LoWPAN: Remove network devices when unloading Jukka Rissanen

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=1401703704-22451-5-git-send-email-jukka.rissanen@linux.intel.com \
    --to=jukka.rissanen@linux.intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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).