diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-07-16 04:56:07 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-07-16 05:58:03 -0400 |
commit | a5c4e309b9f23b9de5475029b2cb1641ec293137 (patch) | |
tree | ac87f81382e57f718cd52062c4234f463cf026e0 /net/bluetooth/hci_event.c | |
parent | e804d25d4a07c0ff9e5e1c58ea5ee67232aa9af8 (diff) |
Bluetooth: Add a role parameter to hci_conn_add()
We need to be able to track slave vs master LE connections in
hci_conn_hash, and to be able to do that we need to know the role of the
connection by the time hci_conn_add_has() is called. This means in
practice the hci_conn_add() call that creates the hci_conn_object.
This patch adds a new role parameter to hci_conn_add() function to give
the object its initial role value, and updates the callers to pass the
appropriate role to it. Since the function now takes care of
initializing both conn->role and conn->out values we can remove some
other unnecessary assignments.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r-- | net/bluetooth/hci_event.c | 17 |
1 files changed, 6 insertions, 11 deletions
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 |