diff options
Diffstat (limited to 'net/bluetooth/a2mp.c')
| -rw-r--r-- | net/bluetooth/a2mp.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c index cedfbda15dad..5a04eb1a7e57 100644 --- a/net/bluetooth/a2mp.c +++ b/net/bluetooth/a2mp.c | |||
| @@ -19,9 +19,11 @@ | |||
| 19 | #include "a2mp.h" | 19 | #include "a2mp.h" |
| 20 | #include "amp.h" | 20 | #include "amp.h" |
| 21 | 21 | ||
| 22 | #define A2MP_FEAT_EXT 0x8000 | ||
| 23 | |||
| 22 | /* Global AMP Manager list */ | 24 | /* Global AMP Manager list */ |
| 23 | LIST_HEAD(amp_mgr_list); | 25 | static LIST_HEAD(amp_mgr_list); |
| 24 | DEFINE_MUTEX(amp_mgr_list_lock); | 26 | static DEFINE_MUTEX(amp_mgr_list_lock); |
| 25 | 27 | ||
| 26 | /* A2MP build & send command helper functions */ | 28 | /* A2MP build & send command helper functions */ |
| 27 | static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data) | 29 | static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data) |
| @@ -43,7 +45,7 @@ static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data) | |||
| 43 | return cmd; | 45 | return cmd; |
| 44 | } | 46 | } |
| 45 | 47 | ||
| 46 | void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data) | 48 | static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data) |
| 47 | { | 49 | { |
| 48 | struct l2cap_chan *chan = mgr->a2mp_chan; | 50 | struct l2cap_chan *chan = mgr->a2mp_chan; |
| 49 | struct a2mp_cmd *cmd; | 51 | struct a2mp_cmd *cmd; |
| @@ -67,7 +69,7 @@ void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data) | |||
| 67 | kfree(cmd); | 69 | kfree(cmd); |
| 68 | } | 70 | } |
| 69 | 71 | ||
| 70 | u8 __next_ident(struct amp_mgr *mgr) | 72 | static u8 __next_ident(struct amp_mgr *mgr) |
| 71 | { | 73 | { |
| 72 | if (++mgr->ident == 0) | 74 | if (++mgr->ident == 0) |
| 73 | mgr->ident = 1; | 75 | mgr->ident = 1; |
| @@ -75,6 +77,23 @@ u8 __next_ident(struct amp_mgr *mgr) | |||
| 75 | return mgr->ident; | 77 | return mgr->ident; |
| 76 | } | 78 | } |
| 77 | 79 | ||
| 80 | static struct amp_mgr *amp_mgr_lookup_by_state(u8 state) | ||
| 81 | { | ||
| 82 | struct amp_mgr *mgr; | ||
| 83 | |||
| 84 | mutex_lock(&_mgr_list_lock); | ||
| 85 | list_for_each_entry(mgr, &_mgr_list, list) { | ||
| 86 | if (test_and_clear_bit(state, &mgr->state)) { | ||
| 87 | amp_mgr_get(mgr); | ||
| 88 | mutex_unlock(&_mgr_list_lock); | ||
| 89 | return mgr; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | mutex_unlock(&_mgr_list_lock); | ||
| 93 | |||
| 94 | return NULL; | ||
| 95 | } | ||
| 96 | |||
| 78 | /* hci_dev_list shall be locked */ | 97 | /* hci_dev_list shall be locked */ |
| 79 | static void __a2mp_add_cl(struct amp_mgr *mgr, struct a2mp_cl *cl) | 98 | static void __a2mp_add_cl(struct amp_mgr *mgr, struct a2mp_cl *cl) |
| 80 | { | 99 | { |
| @@ -860,23 +879,6 @@ struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn, | |||
| 860 | return mgr->a2mp_chan; | 879 | return mgr->a2mp_chan; |
| 861 | } | 880 | } |
| 862 | 881 | ||
| 863 | struct amp_mgr *amp_mgr_lookup_by_state(u8 state) | ||
| 864 | { | ||
| 865 | struct amp_mgr *mgr; | ||
| 866 | |||
| 867 | mutex_lock(&_mgr_list_lock); | ||
| 868 | list_for_each_entry(mgr, &_mgr_list, list) { | ||
| 869 | if (test_and_clear_bit(state, &mgr->state)) { | ||
| 870 | amp_mgr_get(mgr); | ||
| 871 | mutex_unlock(&_mgr_list_lock); | ||
| 872 | return mgr; | ||
| 873 | } | ||
| 874 | } | ||
| 875 | mutex_unlock(&_mgr_list_lock); | ||
| 876 | |||
| 877 | return NULL; | ||
| 878 | } | ||
| 879 | |||
| 880 | void a2mp_send_getinfo_rsp(struct hci_dev *hdev) | 882 | void a2mp_send_getinfo_rsp(struct hci_dev *hdev) |
| 881 | { | 883 | { |
| 882 | struct amp_mgr *mgr; | 884 | struct amp_mgr *mgr; |
