Lines Matching refs:mgr

42 static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data)  in a2mp_send()  argument
44 struct l2cap_chan *chan = mgr->a2mp_chan; in a2mp_send()
66 static u8 __next_ident(struct amp_mgr *mgr) in __next_ident() argument
68 if (++mgr->ident == 0) in __next_ident()
69 mgr->ident = 1; in __next_ident()
71 return mgr->ident; in __next_ident()
76 struct amp_mgr *mgr; in amp_mgr_lookup_by_state() local
79 list_for_each_entry(mgr, &amp_mgr_list, list) { in amp_mgr_lookup_by_state()
80 if (test_and_clear_bit(state, &mgr->state)) { in amp_mgr_lookup_by_state()
81 amp_mgr_get(mgr); in amp_mgr_lookup_by_state()
83 return mgr; in amp_mgr_lookup_by_state()
92 static void __a2mp_add_cl(struct amp_mgr *mgr, struct a2mp_cl *cl) in __a2mp_add_cl() argument
115 static int a2mp_command_rej(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_command_rej() argument
130 static int a2mp_discover_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discover_req() argument
180 __a2mp_add_cl(mgr, rsp->cl); in a2mp_discover_req()
184 a2mp_send(mgr, A2MP_DISCOVER_RSP, hdr->ident, len, rsp); in a2mp_discover_req()
190 static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discover_rsp() argument
233 a2mp_send(mgr, A2MP_GETINFO_REQ, __next_ident(mgr), in a2mp_discover_rsp()
243 struct l2cap_conn *conn = mgr->l2cap_conn; in a2mp_discover_rsp()
270 static int a2mp_change_notify(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_change_notify() argument
294 static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getinfo_req() argument
316 a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp), in a2mp_getinfo_req()
322 set_bit(READ_LOC_AMP_INFO, &mgr->state); in a2mp_getinfo_req()
337 static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getinfo_rsp() argument
352 ctrl = amp_ctrl_add(mgr, rsp->id); in a2mp_getinfo_rsp()
359 a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req), in a2mp_getinfo_rsp()
366 static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getampassoc_req() argument
395 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, hdr->ident, sizeof(rsp), in a2mp_getampassoc_req()
401 amp_read_loc_assoc(hdev, mgr); in a2mp_getampassoc_req()
411 static int a2mp_getampassoc_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_getampassoc_rsp() argument
433 ctrl = amp_ctrl_lookup(mgr, rsp->id); in a2mp_getampassoc_rsp()
456 hcon = phylink_add(hdev, mgr, rsp->id, true); in a2mp_getampassoc_rsp()
462 mgr->bredr_chan->remote_amp_id = rsp->id; in a2mp_getampassoc_rsp()
464 amp_create_phylink(hdev, mgr, hcon); in a2mp_getampassoc_rsp()
472 static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_createphyslink_req() argument
497 ctrl = amp_ctrl_lookup(mgr, rsp.remote_id); in a2mp_createphyslink_req()
499 ctrl = amp_ctrl_add(mgr, rsp.remote_id); in a2mp_createphyslink_req()
527 hcon = phylink_add(hdev, mgr, req->local_id, false); in a2mp_createphyslink_req()
529 amp_accept_phylink(hdev, mgr, hcon); in a2mp_createphyslink_req()
543 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, hdr->ident, in a2mp_createphyslink_req()
546 set_bit(WRITE_REMOTE_AMP_ASSOC, &mgr->state); in a2mp_createphyslink_req()
547 mgr->ident = hdr->ident; in a2mp_createphyslink_req()
554 static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_discphyslink_req() argument
580 &mgr->l2cap_conn->hcon->dst); in a2mp_discphyslink_req()
593 a2mp_send(mgr, A2MP_DISCONNPHYSLINK_RSP, hdr->ident, sizeof(rsp), &rsp); in a2mp_discphyslink_req()
599 static inline int a2mp_cmd_rsp(struct amp_mgr *mgr, struct sk_buff *skb, in a2mp_cmd_rsp() argument
612 struct amp_mgr *mgr = chan->data; in a2mp_chan_recv_cb() local
615 amp_mgr_get(mgr); in a2mp_chan_recv_cb()
632 mgr->ident = hdr->ident; in a2mp_chan_recv_cb()
636 a2mp_command_rej(mgr, skb, hdr); in a2mp_chan_recv_cb()
640 err = a2mp_discover_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
644 err = a2mp_change_notify(mgr, skb, hdr); in a2mp_chan_recv_cb()
648 err = a2mp_getinfo_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
652 err = a2mp_getampassoc_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
656 err = a2mp_createphyslink_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
660 err = a2mp_discphyslink_req(mgr, skb, hdr); in a2mp_chan_recv_cb()
664 err = a2mp_discover_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
668 err = a2mp_getinfo_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
672 err = a2mp_getampassoc_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
678 err = a2mp_cmd_rsp(mgr, skb, hdr); in a2mp_chan_recv_cb()
698 a2mp_send(mgr, A2MP_COMMAND_REJ, hdr->ident, sizeof(rej), in a2mp_chan_recv_cb()
706 amp_mgr_put(mgr); in a2mp_chan_recv_cb()
719 struct amp_mgr *mgr = chan->data; in a2mp_chan_state_change_cb() local
721 if (!mgr) in a2mp_chan_state_change_cb()
730 if (mgr) in a2mp_chan_state_change_cb()
731 amp_mgr_put(mgr); in a2mp_chan_state_change_cb()
819 struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr) in amp_mgr_get() argument
821 BT_DBG("mgr %p orig refcnt %d", mgr, kref_read(&mgr->kref)); in amp_mgr_get()
823 kref_get(&mgr->kref); in amp_mgr_get()
825 return mgr; in amp_mgr_get()
830 struct amp_mgr *mgr = container_of(kref, struct amp_mgr, kref); in amp_mgr_destroy() local
832 BT_DBG("mgr %p", mgr); in amp_mgr_destroy()
835 list_del(&mgr->list); in amp_mgr_destroy()
838 amp_ctrl_list_flush(mgr); in amp_mgr_destroy()
839 kfree(mgr); in amp_mgr_destroy()
842 int amp_mgr_put(struct amp_mgr *mgr) in amp_mgr_put() argument
844 BT_DBG("mgr %p orig refcnt %d", mgr, kref_read(&mgr->kref)); in amp_mgr_put()
846 return kref_put(&mgr->kref, &amp_mgr_destroy); in amp_mgr_put()
851 struct amp_mgr *mgr; in amp_mgr_create() local
854 mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); in amp_mgr_create()
855 if (!mgr) in amp_mgr_create()
858 BT_DBG("conn %p mgr %p", conn, mgr); in amp_mgr_create()
860 mgr->l2cap_conn = conn; in amp_mgr_create()
864 kfree(mgr); in amp_mgr_create()
868 mgr->a2mp_chan = chan; in amp_mgr_create()
869 chan->data = mgr; in amp_mgr_create()
871 conn->hcon->amp_mgr = mgr; in amp_mgr_create()
873 kref_init(&mgr->kref); in amp_mgr_create()
876 INIT_LIST_HEAD(&mgr->amp_ctrls); in amp_mgr_create()
877 mutex_init(&mgr->amp_ctrls_lock); in amp_mgr_create()
880 list_add(&mgr->list, &amp_mgr_list); in amp_mgr_create()
883 return mgr; in amp_mgr_create()
889 struct amp_mgr *mgr; in a2mp_channel_create() local
894 mgr = amp_mgr_create(conn, false); in a2mp_channel_create()
895 if (!mgr) { in a2mp_channel_create()
900 BT_DBG("mgr: %p chan %p", mgr, mgr->a2mp_chan); in a2mp_channel_create()
902 return mgr->a2mp_chan; in a2mp_channel_create()
907 struct amp_mgr *mgr; in a2mp_send_getinfo_rsp() local
910 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_INFO); in a2mp_send_getinfo_rsp()
911 if (!mgr) in a2mp_send_getinfo_rsp()
914 BT_DBG("%s mgr %p", hdev->name, mgr); in a2mp_send_getinfo_rsp()
930 a2mp_send(mgr, A2MP_GETINFO_RSP, mgr->ident, sizeof(rsp), &rsp); in a2mp_send_getinfo_rsp()
931 amp_mgr_put(mgr); in a2mp_send_getinfo_rsp()
936 struct amp_mgr *mgr; in a2mp_send_getampassoc_rsp() local
941 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC); in a2mp_send_getampassoc_rsp()
942 if (!mgr) in a2mp_send_getampassoc_rsp()
945 BT_DBG("%s mgr %p", hdev->name, mgr); in a2mp_send_getampassoc_rsp()
950 amp_mgr_put(mgr); in a2mp_send_getampassoc_rsp()
963 a2mp_send(mgr, A2MP_GETAMPASSOC_RSP, mgr->ident, len, rsp); in a2mp_send_getampassoc_rsp()
964 amp_mgr_put(mgr); in a2mp_send_getampassoc_rsp()
970 struct amp_mgr *mgr; in a2mp_send_create_phy_link_req() local
976 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_ASSOC_FINAL); in a2mp_send_create_phy_link_req()
977 if (!mgr) in a2mp_send_create_phy_link_req()
982 BT_DBG("%s mgr %p assoc_len %zu", hdev->name, mgr, len); in a2mp_send_create_phy_link_req()
986 amp_mgr_put(mgr); in a2mp_send_create_phy_link_req()
990 bredr_chan = mgr->bredr_chan; in a2mp_send_create_phy_link_req()
998 a2mp_send(mgr, A2MP_CREATEPHYSLINK_REQ, __next_ident(mgr), len, req); in a2mp_send_create_phy_link_req()
1001 amp_mgr_put(mgr); in a2mp_send_create_phy_link_req()
1007 struct amp_mgr *mgr; in a2mp_send_create_phy_link_rsp() local
1011 mgr = amp_mgr_lookup_by_state(WRITE_REMOTE_AMP_ASSOC); in a2mp_send_create_phy_link_rsp()
1012 if (!mgr) in a2mp_send_create_phy_link_rsp()
1025 BT_DBG("%s mgr %p hs_hcon %p status %u", hdev->name, mgr, hs_hcon, in a2mp_send_create_phy_link_rsp()
1029 a2mp_send(mgr, A2MP_CREATEPHYSLINK_RSP, mgr->ident, sizeof(rsp), &rsp); in a2mp_send_create_phy_link_rsp()
1030 amp_mgr_put(mgr); in a2mp_send_create_phy_link_rsp()
1036 struct amp_mgr *mgr = conn->hcon->amp_mgr; in a2mp_discover_amp() local
1039 BT_DBG("chan %p conn %p mgr %p", chan, conn, mgr); in a2mp_discover_amp()
1041 if (!mgr) { in a2mp_discover_amp()
1042 mgr = amp_mgr_create(conn, true); in a2mp_discover_amp()
1043 if (!mgr) in a2mp_discover_amp()
1047 mgr->bredr_chan = chan; in a2mp_discover_amp()
1053 a2mp_send(mgr, A2MP_DISCOVER_REQ, 1, sizeof(req), &req); in a2mp_discover_amp()