diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-04-06 14:28:44 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2013-04-17 02:02:10 -0400 |
commit | 9c903e373c11f62d62bce1209f662ca92589a075 (patch) | |
tree | 285f6ef70c1e869b7ebd86dcad2a4057ea61134e /include/net | |
parent | 3764eaa922c78037ad9bed06be5c8b8a5c83b37d (diff) |
Bluetooth: l2cap: introduce l2cap_conn ref-counting
If we want to use l2cap_conn outside of l2cap_core.c, we need refcounting
for these objects. Otherwise, we cannot synchronize l2cap locks with
outside locks and end up with deadlocks.
Hence, introduce ref-counting for l2cap_conn objects. This doesn't affect
l2cap internals at all, as they use a direct synchronization.
We also keep a reference to the parent hci_conn for locking purposes as
l2cap_conn depends on this. This doesn't affect the connection itself but
only the lifetime of the (dead) object.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/bluetooth/l2cap.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 278830ef92cd..7b4cc5b98535 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -583,6 +583,7 @@ struct l2cap_conn { | |||
583 | 583 | ||
584 | struct list_head chan_l; | 584 | struct list_head chan_l; |
585 | struct mutex chan_lock; | 585 | struct mutex chan_lock; |
586 | struct kref ref; | ||
586 | }; | 587 | }; |
587 | 588 | ||
588 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | 589 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 |
@@ -813,4 +814,7 @@ void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan, | |||
813 | u8 status); | 814 | u8 status); |
814 | void __l2cap_physical_cfm(struct l2cap_chan *chan, int result); | 815 | void __l2cap_physical_cfm(struct l2cap_chan *chan, int result); |
815 | 816 | ||
817 | void l2cap_conn_get(struct l2cap_conn *conn); | ||
818 | void l2cap_conn_put(struct l2cap_conn *conn); | ||
819 | |||
816 | #endif /* __L2CAP_H */ | 820 | #endif /* __L2CAP_H */ |