aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_conn.c
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2012-07-27 18:32:58 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-08-14 23:53:17 -0400
commitb7d839bfff78a01705f3d7b0acd5257dc7b067c9 (patch)
tree5a24e1614114f7950fe0642de944b600e2d2d167 /net/bluetooth/hci_conn.c
parentdb4742756ae2a836618cd5acf599522573589149 (diff)
Bluetooth: Refactor SCO connection into its own function
We can do the same that we did for the other link types, for SCO connections. The only thing that's worth noting is that as SCO links need an ACL link, this functions uses the function that adds an ACL link. Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/hci_conn.c')
-rw-r--r--net/bluetooth/hci_conn.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 1d70e9fc7a4c..de7df88a396b 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -521,29 +521,19 @@ static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
521 return acl; 521 return acl;
522} 522}
523 523
524/* Create SCO, ACL or LE connection. 524static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, bdaddr_t *dst,
525 * Device _must_ be locked */ 525 u8 sec_level, u8 auth_type)
526struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
527 __u8 dst_type, __u8 sec_level, __u8 auth_type)
528{ 526{
529 struct hci_conn *acl; 527 struct hci_conn *acl;
530 struct hci_conn *sco; 528 struct hci_conn *sco;
531 529
532 BT_DBG("%s dst %s", hdev->name, batostr(dst));
533
534 if (type == LE_LINK)
535 return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
536
537 acl = hci_connect_acl(hdev, dst, sec_level, auth_type); 530 acl = hci_connect_acl(hdev, dst, sec_level, auth_type);
538 if (IS_ERR(acl)) 531 if (IS_ERR(acl))
539 return acl; 532 return acl;
540 533
541 if (type == ACL_LINK) 534 sco = hci_conn_hash_lookup_ba(hdev, SCO_LINK, dst);
542 return acl;
543
544 sco = hci_conn_hash_lookup_ba(hdev, type, dst);
545 if (!sco) { 535 if (!sco) {
546 sco = hci_conn_add(hdev, type, dst); 536 sco = hci_conn_add(hdev, SCO_LINK, dst);
547 if (!sco) { 537 if (!sco) {
548 hci_conn_put(acl); 538 hci_conn_put(acl);
549 return ERR_PTR(-ENOMEM); 539 return ERR_PTR(-ENOMEM);
@@ -572,6 +562,21 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
572 return sco; 562 return sco;
573} 563}
574 564
565/* Create SCO, ACL or LE connection. */
566struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
567 __u8 dst_type, __u8 sec_level, __u8 auth_type)
568{
569 BT_DBG("%s dst %s", hdev->name, batostr(dst));
570
571 if (type == LE_LINK)
572 return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
573
574 if (type == ACL_LINK)
575 return hci_connect_acl(hdev, dst, sec_level, auth_type);
576
577 return hci_connect_sco(hdev, dst, sec_level, auth_type);
578}
579
575/* Check link security requirement */ 580/* Check link security requirement */
576int hci_conn_check_link_mode(struct hci_conn *conn) 581int hci_conn_check_link_mode(struct hci_conn *conn)
577{ 582{