diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2012-09-27 10:26:07 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2012-09-27 16:10:03 -0400 |
commit | f97268fccdd4e76462195216fcab621b8d4a6cd1 (patch) | |
tree | ab9b2cebee49e3186cd80d366e6d16aeb39e2985 /net/bluetooth/a2mp.c | |
parent | b078b564292ab87cdf4a58de3c2f86d4300a161c (diff) |
Bluetooth: A2MP: Create amp_mgr global list
Create amp_mgr_list global list which will be used by different
hci devices to find amp_mgr.
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 | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c index 0760d1fed6f0..3f930608ecfa 100644 --- a/net/bluetooth/a2mp.c +++ b/net/bluetooth/a2mp.c | |||
@@ -17,6 +17,10 @@ | |||
17 | #include <net/bluetooth/l2cap.h> | 17 | #include <net/bluetooth/l2cap.h> |
18 | #include <net/bluetooth/a2mp.h> | 18 | #include <net/bluetooth/a2mp.h> |
19 | 19 | ||
20 | /* Global AMP Manager list */ | ||
21 | LIST_HEAD(amp_mgr_list); | ||
22 | DEFINE_MUTEX(amp_mgr_list_lock); | ||
23 | |||
20 | /* A2MP build & send command helper functions */ | 24 | /* A2MP build & send command helper functions */ |
21 | static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data) | 25 | static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data) |
22 | { | 26 | { |
@@ -516,6 +520,10 @@ static void amp_mgr_destroy(struct kref *kref) | |||
516 | 520 | ||
517 | BT_DBG("mgr %p", mgr); | 521 | BT_DBG("mgr %p", mgr); |
518 | 522 | ||
523 | mutex_lock(&_mgr_list_lock); | ||
524 | list_del(&mgr->list); | ||
525 | mutex_unlock(&_mgr_list_lock); | ||
526 | |||
519 | kfree(mgr); | 527 | kfree(mgr); |
520 | } | 528 | } |
521 | 529 | ||
@@ -552,6 +560,10 @@ static struct amp_mgr *amp_mgr_create(struct l2cap_conn *conn) | |||
552 | 560 | ||
553 | kref_init(&mgr->kref); | 561 | kref_init(&mgr->kref); |
554 | 562 | ||
563 | mutex_lock(&_mgr_list_lock); | ||
564 | list_add(&mgr->list, &_mgr_list); | ||
565 | mutex_unlock(&_mgr_list_lock); | ||
566 | |||
555 | return mgr; | 567 | return mgr; |
556 | } | 568 | } |
557 | 569 | ||
@@ -570,3 +582,20 @@ struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn, | |||
570 | 582 | ||
571 | return mgr->a2mp_chan; | 583 | return mgr->a2mp_chan; |
572 | } | 584 | } |
585 | |||
586 | struct amp_mgr *amp_mgr_lookup_by_state(u8 state) | ||
587 | { | ||
588 | struct amp_mgr *mgr; | ||
589 | |||
590 | mutex_lock(&_mgr_list_lock); | ||
591 | list_for_each_entry(mgr, &_mgr_list, list) { | ||
592 | if (mgr->state == state) { | ||
593 | amp_mgr_get(mgr); | ||
594 | mutex_unlock(&_mgr_list_lock); | ||
595 | return mgr; | ||
596 | } | ||
597 | } | ||
598 | mutex_unlock(&_mgr_list_lock); | ||
599 | |||
600 | return NULL; | ||
601 | } | ||