Browse Source

Bluetooth: 6LoWPAN: Count module usage

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>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Jukka Rissanen 11 years ago
parent
commit
18d93c1766
1 changed files with 5 additions and 0 deletions
  1. 5 0
      net/bluetooth/6lowpan.c

+ 5 - 0
net/bluetooth/6lowpan.c

@@ -100,6 +100,8 @@ static inline bool peer_del(struct lowpan_dev *dev, struct lowpan_peer *peer)
 {
 {
 	list_del(&peer->list);
 	list_del(&peer->list);
 
 
+	module_put(THIS_MODULE);
+
 	if (atomic_dec_and_test(&dev->peer_count)) {
 	if (atomic_dec_and_test(&dev->peer_count)) {
 		BT_DBG("last peer");
 		BT_DBG("last peer");
 		return true;
 		return true;
@@ -752,6 +754,9 @@ static inline void chan_ready_cb(struct l2cap_chan *chan)
 		}
 		}
 	}
 	}
 
 
+	if (!try_module_get(THIS_MODULE))
+		return;
+
 	add_peer_chan(chan, dev);
 	add_peer_chan(chan, dev);
 	ifup(dev->netdev);
 	ifup(dev->netdev);
 }
 }