diff options
-rw-r--r-- | include/net/bluetooth/hci_core.h | 3 | ||||
-rw-r--r-- | net/bluetooth/amp.c | 4 | ||||
-rw-r--r-- | net/bluetooth/hci_conn.c | 17 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 17 |
4 files changed, 19 insertions, 22 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index abe5083becd3..3de000fbecdc 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -695,7 +695,8 @@ void hci_disconnect(struct hci_conn *conn, __u8 reason); | |||
695 | bool hci_setup_sync(struct hci_conn *conn, __u16 handle); | 695 | bool hci_setup_sync(struct hci_conn *conn, __u16 handle); |
696 | void hci_sco_setup(struct hci_conn *conn, __u8 status); | 696 | void hci_sco_setup(struct hci_conn *conn, __u8 status); |
697 | 697 | ||
698 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst); | 698 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst, |
699 | u8 role); | ||
699 | int hci_conn_del(struct hci_conn *conn); | 700 | int hci_conn_del(struct hci_conn *conn); |
700 | void hci_conn_hash_flush(struct hci_dev *hdev); | 701 | void hci_conn_hash_flush(struct hci_dev *hdev); |
701 | void hci_conn_check_pending(struct hci_dev *hdev); | 702 | void hci_conn_check_pending(struct hci_dev *hdev); |
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c index bb39509b3f06..e60603a8969f 100644 --- a/net/bluetooth/amp.c +++ b/net/bluetooth/amp.c | |||
@@ -113,8 +113,9 @@ struct hci_conn *phylink_add(struct hci_dev *hdev, struct amp_mgr *mgr, | |||
113 | { | 113 | { |
114 | bdaddr_t *dst = &mgr->l2cap_conn->hcon->dst; | 114 | bdaddr_t *dst = &mgr->l2cap_conn->hcon->dst; |
115 | struct hci_conn *hcon; | 115 | struct hci_conn *hcon; |
116 | u8 role = out ? HCI_ROLE_MASTER : HCI_ROLE_SLAVE; | ||
116 | 117 | ||
117 | hcon = hci_conn_add(hdev, AMP_LINK, dst); | 118 | hcon = hci_conn_add(hdev, AMP_LINK, dst, role); |
118 | if (!hcon) | 119 | if (!hcon) |
119 | return NULL; | 120 | return NULL; |
120 | 121 | ||
@@ -125,7 +126,6 @@ struct hci_conn *phylink_add(struct hci_dev *hdev, struct amp_mgr *mgr, | |||
125 | hcon->handle = __next_handle(mgr); | 126 | hcon->handle = __next_handle(mgr); |
126 | hcon->remote_id = remote_id; | 127 | hcon->remote_id = remote_id; |
127 | hcon->amp_mgr = amp_mgr_get(mgr); | 128 | hcon->amp_mgr = amp_mgr_get(mgr); |
128 | hcon->out = out; | ||
129 | 129 | ||
130 | return hcon; | 130 | return hcon; |
131 | } | 131 | } |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 6edd55340157..ad5f0b819e90 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -421,7 +421,8 @@ static void le_conn_timeout(struct work_struct *work) | |||
421 | hci_le_create_connection_cancel(conn); | 421 | hci_le_create_connection_cancel(conn); |
422 | } | 422 | } |
423 | 423 | ||
424 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) | 424 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst, |
425 | u8 role) | ||
425 | { | 426 | { |
426 | struct hci_conn *conn; | 427 | struct hci_conn *conn; |
427 | 428 | ||
@@ -435,6 +436,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) | |||
435 | bacpy(&conn->src, &hdev->bdaddr); | 436 | bacpy(&conn->src, &hdev->bdaddr); |
436 | conn->hdev = hdev; | 437 | conn->hdev = hdev; |
437 | conn->type = type; | 438 | conn->type = type; |
439 | conn->role = role; | ||
438 | conn->mode = HCI_CM_ACTIVE; | 440 | conn->mode = HCI_CM_ACTIVE; |
439 | conn->state = BT_OPEN; | 441 | conn->state = BT_OPEN; |
440 | conn->auth_type = HCI_AT_GENERAL_BONDING; | 442 | 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) | |||
447 | set_bit(HCI_CONN_POWER_SAVE, &conn->flags); | 449 | set_bit(HCI_CONN_POWER_SAVE, &conn->flags); |
448 | conn->disc_timeout = HCI_DISCONN_TIMEOUT; | 450 | conn->disc_timeout = HCI_DISCONN_TIMEOUT; |
449 | 451 | ||
452 | if (conn->role == HCI_ROLE_MASTER) | ||
453 | conn->out = true; | ||
454 | |||
450 | switch (type) { | 455 | switch (type) { |
451 | case ACL_LINK: | 456 | case ACL_LINK: |
452 | conn->pkt_type = hdev->pkt_type & ACL_PTYPE_MASK; | 457 | 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, | |||
746 | dst_type = ADDR_LE_DEV_RANDOM; | 751 | dst_type = ADDR_LE_DEV_RANDOM; |
747 | } | 752 | } |
748 | 753 | ||
749 | conn = hci_conn_add(hdev, LE_LINK, dst); | 754 | conn = hci_conn_add(hdev, LE_LINK, dst, role); |
750 | if (!conn) | 755 | if (!conn) |
751 | return ERR_PTR(-ENOMEM); | 756 | return ERR_PTR(-ENOMEM); |
752 | 757 | ||
@@ -769,8 +774,6 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, | |||
769 | &enable); | 774 | &enable); |
770 | } | 775 | } |
771 | 776 | ||
772 | conn->role = role; | ||
773 | |||
774 | /* If requested to connect as slave use directed advertising */ | 777 | /* If requested to connect as slave use directed advertising */ |
775 | if (conn->role == HCI_ROLE_SLAVE) { | 778 | if (conn->role == HCI_ROLE_SLAVE) { |
776 | /* If we're active scanning most controllers are unable | 779 | /* 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, | |||
787 | goto create_conn; | 790 | goto create_conn; |
788 | } | 791 | } |
789 | 792 | ||
790 | conn->out = true; | ||
791 | |||
792 | params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); | 793 | params = hci_conn_params_lookup(hdev, &conn->dst, conn->dst_type); |
793 | if (params) { | 794 | if (params) { |
794 | conn->le_conn_min_interval = params->conn_min_interval; | 795 | 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, | |||
837 | 838 | ||
838 | acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); | 839 | acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); |
839 | if (!acl) { | 840 | if (!acl) { |
840 | acl = hci_conn_add(hdev, ACL_LINK, dst); | 841 | acl = hci_conn_add(hdev, ACL_LINK, dst, HCI_ROLE_MASTER); |
841 | if (!acl) | 842 | if (!acl) |
842 | return ERR_PTR(-ENOMEM); | 843 | return ERR_PTR(-ENOMEM); |
843 | } | 844 | } |
@@ -866,7 +867,7 @@ struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst, | |||
866 | 867 | ||
867 | sco = hci_conn_hash_lookup_ba(hdev, type, dst); | 868 | sco = hci_conn_hash_lookup_ba(hdev, type, dst); |
868 | if (!sco) { | 869 | if (!sco) { |
869 | sco = hci_conn_add(hdev, type, dst); | 870 | sco = hci_conn_add(hdev, type, dst, HCI_ROLE_MASTER); |
870 | if (!sco) { | 871 | if (!sco) { |
871 | hci_conn_drop(acl); | 872 | hci_conn_drop(acl); |
872 | return ERR_PTR(-ENOMEM); | 873 | return ERR_PTR(-ENOMEM); |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 5f7fd410fb3b..c68b93e11686 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1414,11 +1414,9 @@ static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) | |||
1414 | } | 1414 | } |
1415 | } else { | 1415 | } else { |
1416 | if (!conn) { | 1416 | if (!conn) { |
1417 | conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr); | 1417 | conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr, |
1418 | if (conn) { | 1418 | HCI_ROLE_MASTER); |
1419 | conn->out = true; | 1419 | if (!conn) |
1420 | conn->role = HCI_ROLE_MASTER; | ||
1421 | } else | ||
1422 | BT_ERR("No memory for new connection"); | 1420 | BT_ERR("No memory for new connection"); |
1423 | } | 1421 | } |
1424 | } | 1422 | } |
@@ -2156,7 +2154,8 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
2156 | conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, | 2154 | conn = hci_conn_hash_lookup_ba(hdev, ev->link_type, |
2157 | &ev->bdaddr); | 2155 | &ev->bdaddr); |
2158 | if (!conn) { | 2156 | if (!conn) { |
2159 | conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr); | 2157 | conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr, |
2158 | HCI_ROLE_SLAVE); | ||
2160 | if (!conn) { | 2159 | if (!conn) { |
2161 | BT_ERR("No memory for new connection"); | 2160 | BT_ERR("No memory for new connection"); |
2162 | hci_dev_unlock(hdev); | 2161 | hci_dev_unlock(hdev); |
@@ -4100,7 +4099,7 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
4100 | 4099 | ||
4101 | conn = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT); | 4100 | conn = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT); |
4102 | if (!conn) { | 4101 | if (!conn) { |
4103 | conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr); | 4102 | conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr, ev->role); |
4104 | if (!conn) { | 4103 | if (!conn) { |
4105 | BT_ERR("No memory for new connection"); | 4104 | BT_ERR("No memory for new connection"); |
4106 | goto unlock; | 4105 | goto unlock; |
@@ -4108,10 +4107,6 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
4108 | 4107 | ||
4109 | conn->dst_type = ev->bdaddr_type; | 4108 | conn->dst_type = ev->bdaddr_type; |
4110 | 4109 | ||
4111 | conn->role = ev->role; | ||
4112 | if (conn->role == HCI_ROLE_MASTER) | ||
4113 | conn->out = true; | ||
4114 | |||
4115 | /* If we didn't have a hci_conn object previously | 4110 | /* If we didn't have a hci_conn object previously |
4116 | * but we're in master role this must be something | 4111 | * but we're in master role this must be something |
4117 | * initiated using a white list. Since white list based | 4112 | * initiated using a white list. Since white list based |