|
@@ -421,7 +421,8 @@ static void le_conn_timeout(struct work_struct *work)
|
|
|
hci_le_create_connection_cancel(conn);
|
|
|
}
|
|
|
|
|
|
-struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
|
|
|
+struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst,
|
|
|
+ u8 role)
|
|
|
{
|
|
|
struct hci_conn *conn;
|
|
|
|
|
@@ -435,6 +436,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
|
|
|
bacpy(&conn->src, &hdev->bdaddr);
|
|
|
conn->hdev = hdev;
|
|
|
conn->type = type;
|
|
|
+ conn->role = role;
|
|
|
conn->mode = HCI_CM_ACTIVE;
|
|
|
conn->state = BT_OPEN;
|
|
|
conn->auth_type = HCI_AT_GENERAL_BONDING;
|
|
@@ -447,6 +449,9 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
|
|
|
set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
|
|
|
conn->disc_timeout = HCI_DISCONN_TIMEOUT;
|
|
|
|
|
|
+ if (conn->role == HCI_ROLE_MASTER)
|
|
|
+ conn->out = true;
|
|
|
+
|
|
|
switch (type) {
|
|
|
case ACL_LINK:
|
|
|
conn->pkt_type = hdev->pkt_type & ACL_PTYPE_MASK;
|
|
@@ -746,7 +751,7 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
|
|
|
dst_type = ADDR_LE_DEV_RANDOM;
|
|
|
}
|
|
|
|
|
|
- conn = hci_conn_add(hdev, LE_LINK, dst);
|
|
|
+ conn = hci_conn_add(hdev, LE_LINK, dst, role);
|
|
|
if (!conn)
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
@@ -769,8 +774,6 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
|
|
|
&enable);
|
|
|
}
|
|
|
|
|
|
- conn->role = role;
|
|
|
-
|
|
|
/* If requested to connect as slave use directed advertising */
|
|
|
if (conn->role == HCI_ROLE_SLAVE) {
|
|
|
/* If we're active scanning most controllers are unable
|
|
@@ -787,8 +790,6 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
|
|
|
goto create_conn;
|
|
|
}
|
|
|
|
|
|
- conn->out = true;
|
|
|
-
|
|
|
params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type);
|
|
|
if (params) {
|
|
|
conn->le_conn_min_interval = params->conn_min_interval;
|
|
@@ -837,7 +838,7 @@ struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
|
|
|
|
|
|
acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
|
|
|
if (!acl) {
|
|
|
- acl = hci_conn_add(hdev, ACL_LINK, dst);
|
|
|
+ acl = hci_conn_add(hdev, ACL_LINK, dst, HCI_ROLE_MASTER);
|
|
|
if (!acl)
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
}
|
|
@@ -866,7 +867,7 @@ struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
|
|
|
|
|
|
sco = hci_conn_hash_lookup_ba(hdev, type, dst);
|
|
|
if (!sco) {
|
|
|
- sco = hci_conn_add(hdev, type, dst);
|
|
|
+ sco = hci_conn_add(hdev, type, dst, HCI_ROLE_MASTER);
|
|
|
if (!sco) {
|
|
|
hci_conn_drop(acl);
|
|
|
return ERR_PTR(-ENOMEM);
|