Bluetooth: Add l2cap_chan_lock
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Tue, 21 Feb 2012 10:54:56 +0000 (12:54 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 23 Feb 2012 11:06:58 +0000 (13:06 +0200)
Channel lock will be used to lock L2CAP channels which are locked
currently by socket locks.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: Ulisses Furquim <ulisses@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/l2cap.h
net/bluetooth/l2cap_core.c

index bbb0e214e51db7226fefd7e7f91281bc19938b6a..d6d8ec8eb8cfbb79b8a834739c4e3ed38772fabc 100644 (file)
@@ -497,6 +497,7 @@ struct l2cap_chan {
 
        void            *data;
        struct l2cap_ops *ops;
+       struct mutex            lock;
 };
 
 struct l2cap_ops {
@@ -609,6 +610,16 @@ static inline void l2cap_chan_put(struct l2cap_chan *c)
                kfree(c);
 }
 
+static inline void l2cap_chan_lock(struct l2cap_chan *chan)
+{
+       mutex_lock(&chan->lock);
+}
+
+static inline void l2cap_chan_unlock(struct l2cap_chan *chan)
+{
+       mutex_unlock(&chan->lock);
+}
+
 static inline void l2cap_set_timer(struct l2cap_chan *chan,
                                        struct delayed_work *work, long timeout)
 {
index 8e8e9e93fb343bb7a25253348b3ee8b67395636f..e39eba1ac4da900d690f588f3ee405e3be4e87a4 100644 (file)
@@ -247,6 +247,8 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk)
        if (!chan)
                return NULL;
 
+       mutex_init(&chan->lock);
+
        chan->sk = sk;
 
        write_lock(&chan_list_lock);