aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2012-09-27 10:26:08 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-09-27 16:10:18 -0400
commit8e2a0d92c56ec6955526a8b60838c9b00f70540d (patch)
treea8a8796ad17d8450a82e16c7ecc82d2a42f9cf0e /net
parentf97268fccdd4e76462195216fcab621b8d4a6cd1 (diff)
Bluetooth: AMP: Use HCI cmd to Read AMP Info
When receiving A2MP Get Info Request execute Read Local AMP Info HCI command to AMP controller with function to be executed upon receiving command complete event. Function will handle A2MP Get Info Response. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/a2mp.c57
-rw-r--r--net/bluetooth/hci_event.c6
2 files changed, 46 insertions, 17 deletions
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index 3f930608ecfa..0e97b3b42ab1 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -41,8 +41,7 @@ static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data)
41 return cmd; 41 return cmd;
42} 42}
43 43
44static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, 44void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data)
45 void *data)
46{ 45{
47 struct l2cap_chan *chan = mgr->a2mp_chan; 46 struct l2cap_chan *chan = mgr->a2mp_chan;
48 struct a2mp_cmd *cmd; 47 struct a2mp_cmd *cmd;
@@ -185,7 +184,6 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
185 struct a2mp_cmd *hdr) 184 struct a2mp_cmd *hdr)
186{ 185{
187 struct a2mp_info_req *req = (void *) skb->data; 186 struct a2mp_info_req *req = (void *) skb->data;
188 struct a2mp_info_rsp rsp;
189 struct hci_dev *hdev; 187 struct hci_dev *hdev;
190 188
191 if (le16_to_cpu(hdr->len) < sizeof(*req)) 189 if (le16_to_cpu(hdr->len) < sizeof(*req))
@@ -193,23 +191,23 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
193 191
194 BT_DBG("id %d", req->id); 192 BT_DBG("id %d", req->id);
195 193
196 rsp.id = req->id;
197 rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
198
199 hdev = hci_dev_get(req->id); 194 hdev = hci_dev_get(req->id);
200 if (hdev && hdev->amp_type != HCI_BREDR) { 195 if (!hdev) {
201 rsp.status = 0; 196 struct a2mp_info_rsp rsp;
202 rsp.total_bw = cpu_to_le32(hdev->amp_total_bw); 197
203 rsp.max_bw = cpu_to_le32(hdev->amp_max_bw); 198 rsp.id = req->id;
204 rsp.min_latency = cpu_to_le32(hdev->amp_min_latency); 199 rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
205 rsp.pal_cap = cpu_to_le16(hdev->amp_pal_cap); 200
206 rsp.assoc_size = cpu_to_le16(hdev->amp_assoc_size); 201 a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp),
202 &rsp);
207 } 203 }
208 204
209 if (hdev) 205 if (hdev->dev_type != HCI_BREDR) {
210 hci_dev_put(hdev); 206 mgr->state = READ_LOC_AMP_INFO;
207 hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL);
208 }
211 209
212 a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp), &rsp); 210 hci_dev_put(hdev);
213 211
214 skb_pull(skb, sizeof(*req)); 212 skb_pull(skb, sizeof(*req));
215 return 0; 213 return 0;
@@ -599,3 +597,30 @@ struct amp_mgr *amp_mgr_lookup_by_state(u8 state)
599 597
600 return NULL; 598 return NULL;
601} 599}
600
601void a2mp_send_getinfo_rsp(struct hci_dev *hdev)
602{
603 struct amp_mgr *mgr;
604 struct a2mp_info_rsp rsp;
605
606 mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_INFO);
607 if (!mgr)
608 return;
609
610 BT_DBG("%s mgr %p", hdev->name, mgr);
611
612 rsp.id = hdev->id;
613 rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
614
615 if (hdev->amp_type != HCI_BREDR) {
616 rsp.status = 0;
617 rsp.total_bw = cpu_to_le32(hdev->amp_total_bw);
618 rsp.max_bw = cpu_to_le32(hdev->amp_max_bw);
619 rsp.min_latency = cpu_to_le32(hdev->amp_min_latency);
620 rsp.pal_cap = cpu_to_le16(hdev->amp_pal_cap);
621 rsp.assoc_size = cpu_to_le16(hdev->amp_assoc_size);
622 }
623
624 a2mp_send(mgr, A2MP_GETINFO_RSP, mgr->ident, sizeof(rsp), &rsp);
625 amp_mgr_put(mgr);
626}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 2022b43c7353..eb45774165f4 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -30,6 +30,7 @@
30#include <net/bluetooth/bluetooth.h> 30#include <net/bluetooth/bluetooth.h>
31#include <net/bluetooth/hci_core.h> 31#include <net/bluetooth/hci_core.h>
32#include <net/bluetooth/mgmt.h> 32#include <net/bluetooth/mgmt.h>
33#include <net/bluetooth/a2mp.h>
33 34
34/* Handle HCI Event packets */ 35/* Handle HCI Event packets */
35 36
@@ -846,7 +847,7 @@ static void hci_cc_read_local_amp_info(struct hci_dev *hdev,
846 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status); 847 BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
847 848
848 if (rp->status) 849 if (rp->status)
849 return; 850 goto a2mp_rsp;
850 851
851 hdev->amp_status = rp->amp_status; 852 hdev->amp_status = rp->amp_status;
852 hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); 853 hdev->amp_total_bw = __le32_to_cpu(rp->total_bw);
@@ -860,6 +861,9 @@ static void hci_cc_read_local_amp_info(struct hci_dev *hdev,
860 hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); 861 hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to);
861 862
862 hci_req_complete(hdev, HCI_OP_READ_LOCAL_AMP_INFO, rp->status); 863 hci_req_complete(hdev, HCI_OP_READ_LOCAL_AMP_INFO, rp->status);
864
865a2mp_rsp:
866 a2mp_send_getinfo_rsp(hdev);
863} 867}
864 868
865static void hci_cc_delete_stored_link_key(struct hci_dev *hdev, 869static void hci_cc_delete_stored_link_key(struct hci_dev *hdev,