diff options
| author | Vinicius Costa Gomes <vinicius.gomes@openbossa.org> | 2012-07-28 21:35:59 -0400 |
|---|---|---|
| committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2012-08-14 23:53:16 -0400 |
| commit | db4742756ae2a836618cd5acf599522573589149 (patch) | |
| tree | 97fc4ac9927d8311c6891078aff635dae79a2f1d /net/bluetooth | |
| parent | d04aef4cccf203fdfd1716e9ba458060cbab0928 (diff) | |
Bluetooth: Refactor ACL connection into its own function
The hci_connect() function was starting to get too complicated to be
quickly understood. We can separate the creation of a new ACL
connection into its own function.
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')
| -rw-r--r-- | net/bluetooth/hci_conn.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 0a74399dde5e..1d70e9fc7a4c 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
| @@ -497,18 +497,10 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, | |||
| 497 | return le; | 497 | return le; |
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | /* Create SCO, ACL or LE connection. | 500 | static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst, |
| 501 | * Device _must_ be locked */ | 501 | u8 sec_level, u8 auth_type) |
| 502 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, | ||
| 503 | __u8 dst_type, __u8 sec_level, __u8 auth_type) | ||
| 504 | { | 502 | { |
| 505 | struct hci_conn *acl; | 503 | struct hci_conn *acl; |
| 506 | struct hci_conn *sco; | ||
| 507 | |||
| 508 | BT_DBG("%s dst %s", hdev->name, batostr(dst)); | ||
| 509 | |||
| 510 | if (type == LE_LINK) | ||
| 511 | return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type); | ||
| 512 | 504 | ||
| 513 | acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); | 505 | acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); |
| 514 | if (!acl) { | 506 | if (!acl) { |
| @@ -526,6 +518,26 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, | |||
| 526 | hci_acl_create_connection(acl); | 518 | hci_acl_create_connection(acl); |
| 527 | } | 519 | } |
| 528 | 520 | ||
| 521 | return acl; | ||
| 522 | } | ||
| 523 | |||
| 524 | /* Create SCO, ACL or LE connection. | ||
| 525 | * Device _must_ be locked */ | ||
| 526 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, | ||
| 527 | __u8 dst_type, __u8 sec_level, __u8 auth_type) | ||
| 528 | { | ||
| 529 | struct hci_conn *acl; | ||
| 530 | struct hci_conn *sco; | ||
| 531 | |||
| 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); | ||
| 538 | if (IS_ERR(acl)) | ||
| 539 | return acl; | ||
| 540 | |||
| 529 | if (type == ACL_LINK) | 541 | if (type == ACL_LINK) |
| 530 | return acl; | 542 | return acl; |
| 531 | 543 | ||
