diff options
author | Andre Guedes <andre.guedes@openbossa.org> | 2014-02-26 18:21:44 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-02-26 22:41:34 -0500 |
commit | 04a6c5898e8cbb46313b7d425001b701f0fa4e3d (patch) | |
tree | 33193eddde45abfa9683b1daea8be4ae9d761a3c /net/bluetooth | |
parent | c99ed8343cdf84279f4d1937d25a3b644a14ed0d (diff) |
Bluetooth: Refactor HCI connection code
hci_connect() is a very simple and useless wrapper of hci_connect_acl
and hci_connect_le functions. Addtionally, all places where hci_connect
is called the link type value is passed explicitly. This way, we can
safely delete hci_connect, declare hci_connect_acl and hci_connect_le
in hci_core.h and call them directly.
No functionality is changed by this patch.
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_conn.c | 24 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 7 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 8 |
3 files changed, 11 insertions, 28 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 296b8ee42451..5c392aaed5a9 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -624,8 +624,8 @@ static void stop_scan_complete(struct hci_dev *hdev, u8 status) | |||
624 | } | 624 | } |
625 | } | 625 | } |
626 | 626 | ||
627 | static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, | 627 | struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, |
628 | u8 dst_type, u8 sec_level, u8 auth_type) | 628 | u8 dst_type, u8 sec_level, u8 auth_type) |
629 | { | 629 | { |
630 | struct hci_conn_params *params; | 630 | struct hci_conn_params *params; |
631 | struct hci_conn *conn; | 631 | struct hci_conn *conn; |
@@ -729,8 +729,8 @@ done: | |||
729 | return conn; | 729 | return conn; |
730 | } | 730 | } |
731 | 731 | ||
732 | static struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst, | 732 | struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst, |
733 | u8 sec_level, u8 auth_type) | 733 | u8 sec_level, u8 auth_type) |
734 | { | 734 | { |
735 | struct hci_conn *acl; | 735 | struct hci_conn *acl; |
736 | 736 | ||
@@ -799,22 +799,6 @@ struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst, | |||
799 | return sco; | 799 | return sco; |
800 | } | 800 | } |
801 | 801 | ||
802 | /* Create SCO, ACL or LE connection. */ | ||
803 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, | ||
804 | __u8 dst_type, __u8 sec_level, __u8 auth_type) | ||
805 | { | ||
806 | BT_DBG("%s dst %pMR type 0x%x", hdev->name, dst, type); | ||
807 | |||
808 | switch (type) { | ||
809 | case LE_LINK: | ||
810 | return hci_connect_le(hdev, dst, dst_type, sec_level, auth_type); | ||
811 | case ACL_LINK: | ||
812 | return hci_connect_acl(hdev, dst, sec_level, auth_type); | ||
813 | } | ||
814 | |||
815 | return ERR_PTR(-EINVAL); | ||
816 | } | ||
817 | |||
818 | /* Check link security requirement */ | 802 | /* Check link security requirement */ |
819 | int hci_conn_check_link_mode(struct hci_conn *conn) | 803 | int hci_conn_check_link_mode(struct hci_conn *conn) |
820 | { | 804 | { |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index d8d990215158..ab5e2bd113ed 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -7109,11 +7109,10 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
7109 | auth_type = l2cap_get_auth_type(chan); | 7109 | auth_type = l2cap_get_auth_type(chan); |
7110 | 7110 | ||
7111 | if (bdaddr_type_is_le(dst_type)) | 7111 | if (bdaddr_type_is_le(dst_type)) |
7112 | hcon = hci_connect(hdev, LE_LINK, dst, dst_type, | 7112 | hcon = hci_connect_le(hdev, dst, dst_type, chan->sec_level, |
7113 | chan->sec_level, auth_type); | 7113 | auth_type); |
7114 | else | 7114 | else |
7115 | hcon = hci_connect(hdev, ACL_LINK, dst, dst_type, | 7115 | hcon = hci_connect_acl(hdev, dst, chan->sec_level, auth_type); |
7116 | chan->sec_level, auth_type); | ||
7117 | 7116 | ||
7118 | if (IS_ERR(hcon)) { | 7117 | if (IS_ERR(hcon)) { |
7119 | err = PTR_ERR(hcon); | 7118 | err = PTR_ERR(hcon); |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index cfcaf97c998b..9fc7c1d9fcbb 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2816,11 +2816,11 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, | |||
2816 | auth_type = HCI_AT_DEDICATED_BONDING_MITM; | 2816 | auth_type = HCI_AT_DEDICATED_BONDING_MITM; |
2817 | 2817 | ||
2818 | if (cp->addr.type == BDADDR_BREDR) | 2818 | if (cp->addr.type == BDADDR_BREDR) |
2819 | conn = hci_connect(hdev, ACL_LINK, &cp->addr.bdaddr, | 2819 | conn = hci_connect_acl(hdev, &cp->addr.bdaddr, sec_level, |
2820 | cp->addr.type, sec_level, auth_type); | 2820 | auth_type); |
2821 | else | 2821 | else |
2822 | conn = hci_connect(hdev, LE_LINK, &cp->addr.bdaddr, | 2822 | conn = hci_connect_le(hdev, &cp->addr.bdaddr, cp->addr.type, |
2823 | cp->addr.type, sec_level, auth_type); | 2823 | sec_level, auth_type); |
2824 | 2824 | ||
2825 | if (IS_ERR(conn)) { | 2825 | if (IS_ERR(conn)) { |
2826 | int status; | 2826 | int status; |