Commit d04aef4c authored by Vinicius Costa Gomes's avatar Vinicius Costa Gomes Committed by Gustavo Padovan

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: default avatarVinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent 1aef8669
...@@ -470,22 +470,14 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) ...@@ -470,22 +470,14 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
} }
EXPORT_SYMBOL(hci_get_route); EXPORT_SYMBOL(hci_get_route);
/* Create SCO, ACL or LE connection. static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
* Device _must_ be locked */ u8 dst_type, u8 sec_level, u8 auth_type)
struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
__u8 dst_type, __u8 sec_level, __u8 auth_type)
{ {
struct hci_conn *acl;
struct hci_conn *sco;
struct hci_conn *le; struct hci_conn *le;
BT_DBG("%s dst %s", hdev->name, batostr(dst));
if (type == LE_LINK) {
le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst); le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
if (!le) { if (!le) {
le = hci_conn_hash_lookup_state(hdev, LE_LINK, le = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT);
BT_CONNECT);
if (le) if (le)
return ERR_PTR(-EBUSY); return ERR_PTR(-EBUSY);
...@@ -503,7 +495,20 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, ...@@ -503,7 +495,20 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
hci_conn_hold(le); hci_conn_hold(le);
return le; return le;
} }
/* Create SCO, ACL or LE connection.
* Device _must_ be locked */
struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
__u8 dst_type, __u8 sec_level, __u8 auth_type)
{
struct hci_conn *acl;
struct hci_conn *sco;
BT_DBG("%s dst %s", hdev->name, batostr(dst));
if (type == LE_LINK)
return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type);
acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
if (!acl) { if (!acl) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment