aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2014-02-26 18:21:45 -0500
committerMarcel Holtmann <marcel@holtmann.org>2014-02-26 22:41:34 -0500
commit6f77d8c757523f675679d845ff0e15d3276a168a (patch)
tree69ad7cf050bdfa281610c5098b33ac9beff410ac
parent04a6c5898e8cbb46313b7d425001b701f0fa4e3d (diff)
Bluetooth: Move address type conversion to outside hci_connect_le
This patch moves address type conversion (L2CAP address type to HCI address type) to outside hci_connect_le. This way, we avoid back and forth address type conversion in a comming patch. So hci_connect_le() now expects 'dst_type' parameter in HCI address type convention. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--net/bluetooth/hci_conn.c6
-rw-r--r--net/bluetooth/l2cap_core.c12
-rw-r--r--net/bluetooth/mgmt.c16
3 files changed, 23 insertions, 11 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 5c392aaed5a9..46b27133740f 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -659,12 +659,6 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
659 if (conn) 659 if (conn)
660 return ERR_PTR(-EBUSY); 660 return ERR_PTR(-EBUSY);
661 661
662 /* Convert from L2CAP channel address type to HCI address type */
663 if (dst_type == BDADDR_LE_PUBLIC)
664 dst_type = ADDR_LE_DEV_PUBLIC;
665 else
666 dst_type = ADDR_LE_DEV_RANDOM;
667
668 /* When given an identity address with existing identity 662 /* When given an identity address with existing identity
669 * resolving key, the connection needs to be established 663 * resolving key, the connection needs to be established
670 * to a resolvable random address. 664 * to a resolvable random address.
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index ab5e2bd113ed..9ed2168fa59f 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -7108,11 +7108,19 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
7108 7108
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 /* Convert from L2CAP channel address type to HCI address type
7113 */
7114 if (dst_type == BDADDR_LE_PUBLIC)
7115 dst_type = ADDR_LE_DEV_PUBLIC;
7116 else
7117 dst_type = ADDR_LE_DEV_RANDOM;
7118
7112 hcon = hci_connect_le(hdev, dst, dst_type, chan->sec_level, 7119 hcon = hci_connect_le(hdev, dst, dst_type, chan->sec_level,
7113 auth_type); 7120 auth_type);
7114 else 7121 } else {
7115 hcon = hci_connect_acl(hdev, dst, chan->sec_level, auth_type); 7122 hcon = hci_connect_acl(hdev, dst, chan->sec_level, auth_type);
7123 }
7116 7124
7117 if (IS_ERR(hcon)) { 7125 if (IS_ERR(hcon)) {
7118 err = PTR_ERR(hcon); 7126 err = PTR_ERR(hcon);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 9fc7c1d9fcbb..bad23d5fdd35 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2815,12 +2815,22 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
2815 else 2815 else
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_acl(hdev, &cp->addr.bdaddr, sec_level, 2819 conn = hci_connect_acl(hdev, &cp->addr.bdaddr, sec_level,
2820 auth_type); 2820 auth_type);
2821 else 2821 } else {
2822 conn = hci_connect_le(hdev, &cp->addr.bdaddr, cp->addr.type, 2822 u8 addr_type;
2823
2824 /* Convert from L2CAP channel address type to HCI address type
2825 */
2826 if (cp->addr.type == BDADDR_LE_PUBLIC)
2827 addr_type = ADDR_LE_DEV_PUBLIC;
2828 else
2829 addr_type = ADDR_LE_DEV_RANDOM;
2830
2831 conn = hci_connect_le(hdev, &cp->addr.bdaddr, addr_type,
2823 sec_level, auth_type); 2832 sec_level, auth_type);
2833 }
2824 2834
2825 if (IS_ERR(conn)) { 2835 if (IS_ERR(conn)) {
2826 int status; 2836 int status;