aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/a2mp.c
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2012-09-27 10:26:13 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-09-27 16:13:04 -0400
commitcb8488c0b60a947c0ef4a1a94573a7fefd3f20b4 (patch)
tree6393f4d2e59f376890506cb91abfe5eae43413d2 /net/bluetooth/a2mp.c
parent52c0d6e56b634b195e377192182391d526cdd5e4 (diff)
Bluetooth: AMP: Handle create / disc phylink req
Use hci_conn structure to keep track about AMP physical connections. 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.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index 35e188c7a441..0125417695eb 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -321,6 +321,7 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
321 321
322 struct a2mp_physlink_rsp rsp; 322 struct a2mp_physlink_rsp rsp;
323 struct hci_dev *hdev; 323 struct hci_dev *hdev;
324 struct hci_conn *hcon;
324 325
325 if (le16_to_cpu(hdr->len) < sizeof(*req)) 326 if (le16_to_cpu(hdr->len) < sizeof(*req))
326 return -EINVAL; 327 return -EINVAL;
@@ -338,7 +339,14 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
338 339
339 /* TODO process physlink create */ 340 /* TODO process physlink create */
340 341
341 rsp.status = A2MP_STATUS_SUCCESS; 342 hcon = phylink_add(hdev, mgr, req->local_id);
343 if (hcon) {
344 BT_DBG("hcon %p", hcon);
345
346 rsp.status = A2MP_STATUS_SUCCESS;
347 } else {
348 rsp.status = A2MP_STATUS_UNABLE_START_LINK_CREATION;
349 }
342 350
343send_rsp: 351send_rsp:
344 if (hdev) 352 if (hdev)
@@ -357,6 +365,7 @@ static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
357 struct a2mp_physlink_req *req = (void *) skb->data; 365 struct a2mp_physlink_req *req = (void *) skb->data;
358 struct a2mp_physlink_rsp rsp; 366 struct a2mp_physlink_rsp rsp;
359 struct hci_dev *hdev; 367 struct hci_dev *hdev;
368 struct hci_conn *hcon;
360 369
361 if (le16_to_cpu(hdr->len) < sizeof(*req)) 370 if (le16_to_cpu(hdr->len) < sizeof(*req))
362 return -EINVAL; 371 return -EINVAL;
@@ -367,14 +376,22 @@ static int a2mp_discphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
367 rsp.remote_id = req->local_id; 376 rsp.remote_id = req->local_id;
368 rsp.status = A2MP_STATUS_SUCCESS; 377 rsp.status = A2MP_STATUS_SUCCESS;
369 378
370 hdev = hci_dev_get(req->local_id); 379 hdev = hci_dev_get(req->remote_id);
371 if (!hdev) { 380 if (!hdev) {
372 rsp.status = A2MP_STATUS_INVALID_CTRL_ID; 381 rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
373 goto send_rsp; 382 goto send_rsp;
374 } 383 }
375 384
385 hcon = hci_conn_hash_lookup_ba(hdev, AMP_LINK, mgr->l2cap_conn->dst);
386 if (!hcon) {
387 BT_ERR("No phys link exist");
388 rsp.status = A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS;
389 goto clean;
390 }
391
376 /* TODO Disconnect Phys Link here */ 392 /* TODO Disconnect Phys Link here */
377 393
394clean:
378 hci_dev_put(hdev); 395 hci_dev_put(hdev);
379 396
380send_rsp: 397send_rsp: