diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2012-05-29 06:59:02 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-06-04 23:34:11 -0400 |
commit | 9740e49d17e55f3832661fd99a8e0a17e921a82e (patch) | |
tree | 865915ab8d3c13d1ff74429c84b95a0acab37ee9 /net/bluetooth/a2mp.c | |
parent | 466f8004f364e9cb46d9124109972489eccfb404 (diff) |
Bluetooth: A2MP: AMP Manager basic functions
Define AMP Manager and some basic functions.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/a2mp.c')
-rw-r--r-- | net/bluetooth/a2mp.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c index de455a264451..3c241c2b3e1a 100644 --- a/net/bluetooth/a2mp.c +++ b/net/bluetooth/a2mp.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <net/bluetooth/bluetooth.h> | 15 | #include <net/bluetooth/bluetooth.h> |
16 | #include <net/bluetooth/hci_core.h> | 16 | #include <net/bluetooth/hci_core.h> |
17 | #include <net/bluetooth/l2cap.h> | 17 | #include <net/bluetooth/l2cap.h> |
18 | #include <net/bluetooth/a2mp.h> | ||
18 | 19 | ||
19 | static struct l2cap_ops a2mp_chan_ops = { | 20 | static struct l2cap_ops a2mp_chan_ops = { |
20 | .name = "L2CAP A2MP channel", | 21 | .name = "L2CAP A2MP channel", |
@@ -67,3 +68,56 @@ static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn) | |||
67 | 68 | ||
68 | return chan; | 69 | return chan; |
69 | } | 70 | } |
71 | |||
72 | /* AMP Manager functions */ | ||
73 | void amp_mgr_get(struct amp_mgr *mgr) | ||
74 | { | ||
75 | BT_DBG("mgr %p", mgr); | ||
76 | |||
77 | kref_get(&mgr->kref); | ||
78 | } | ||
79 | |||
80 | static void amp_mgr_destroy(struct kref *kref) | ||
81 | { | ||
82 | struct amp_mgr *mgr = container_of(kref, struct amp_mgr, kref); | ||
83 | |||
84 | BT_DBG("mgr %p", mgr); | ||
85 | |||
86 | kfree(mgr); | ||
87 | } | ||
88 | |||
89 | int amp_mgr_put(struct amp_mgr *mgr) | ||
90 | { | ||
91 | BT_DBG("mgr %p", mgr); | ||
92 | |||
93 | return kref_put(&mgr->kref, &_mgr_destroy); | ||
94 | } | ||
95 | |||
96 | static struct amp_mgr *amp_mgr_create(struct l2cap_conn *conn) | ||
97 | { | ||
98 | struct amp_mgr *mgr; | ||
99 | struct l2cap_chan *chan; | ||
100 | |||
101 | mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); | ||
102 | if (!mgr) | ||
103 | return NULL; | ||
104 | |||
105 | BT_DBG("conn %p mgr %p", conn, mgr); | ||
106 | |||
107 | mgr->l2cap_conn = conn; | ||
108 | |||
109 | chan = a2mp_chan_open(conn); | ||
110 | if (!chan) { | ||
111 | kfree(mgr); | ||
112 | return NULL; | ||
113 | } | ||
114 | |||
115 | mgr->a2mp_chan = chan; | ||
116 | chan->data = mgr; | ||
117 | |||
118 | conn->hcon->amp_mgr = mgr; | ||
119 | |||
120 | kref_init(&mgr->kref); | ||
121 | |||
122 | return mgr; | ||
123 | } | ||