aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2012-07-27 18:32:56 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-08-14 23:53:14 -0400
commitd04aef4cccf203fdfd1716e9ba458060cbab0928 (patch)
treea41f25fdb7b418cc8483847b755f6b7ad1541d37 /net
parent1aef866968223ddfd7268457b642a9233f0b8006 (diff)
Bluetooth: Refactor LE connection into its own function
The code that handles LE connection is already quite separated from the rest of the connection procedure, so we can easily put it into its own. Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_conn.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index c30c507345f8..0a74399dde5e 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -470,6 +470,33 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
470} 470}
471EXPORT_SYMBOL(hci_get_route); 471EXPORT_SYMBOL(hci_get_route);
472 472
473static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
474 u8 dst_type, u8 sec_level, u8 auth_type)
475{
476 struct hci_conn *le;
477
478 le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
479 if (!le) {
480 le = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT);
481 if (le)
482 return ERR_PTR(-EBUSY);
483
484 le = hci_conn_add(hdev, LE_LINK, dst);
485 if (!le)
486 return ERR_PTR(-ENOMEM);
487
488 le->dst_type = bdaddr_to_le(dst_type);
489 hci_le_create_connection(le);
490 }
491
492 le->pending_sec_level = sec_level;
493 le->auth_type = auth_type;
494
495 hci_conn_hold(le);
496
497 return le;
498}
499
473/* Create SCO, ACL or LE connection. 500/* Create SCO, ACL or LE connection.
474 * Device _must_ be locked */ 501 * Device _must_ be locked */
475struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, 502struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
@@ -477,33 +504,11 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
477{ 504{
478 struct hci_conn *acl; 505 struct hci_conn *acl;
479 struct hci_conn *sco; 506 struct hci_conn *sco;
480 struct hci_conn *le;
481 507
482 BT_DBG("%s dst %s", hdev->name, batostr(dst)); 508 BT_DBG("%s dst %s", hdev->name, batostr(dst));
483 509
484 if (type == LE_LINK) { 510 if (type == LE_LINK)
485 le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst); 511 return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
486 if (!le) {
487 le = hci_conn_hash_lookup_state(hdev, LE_LINK,
488 BT_CONNECT);
489 if (le)
490 return ERR_PTR(-EBUSY);
491
492 le = hci_conn_add(hdev, LE_LINK, dst);
493 if (!le)
494 return ERR_PTR(-ENOMEM);
495
496 le->dst_type = bdaddr_to_le(dst_type);
497 hci_le_create_connection(le);
498 }
499
500 le->pending_sec_level = sec_level;
501 le->auth_type = auth_type;
502
503 hci_conn_hold(le);
504
505 return le;
506 }
507 512
508 acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); 513 acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
509 if (!acl) { 514 if (!acl) {