|
@@ -513,7 +513,7 @@ static void hci_setup_event_mask(struct hci_dev *hdev)
|
|
|
if (hdev->features[3] & LMP_RSSI_INQ)
|
|
|
events[4] |= 0x02; /* Inquiry Result with RSSI */
|
|
|
|
|
|
- if (hdev->features[5] & LMP_SNIFF_SUBR)
|
|
|
+ if (lmp_sniffsubr_capable(hdev))
|
|
|
events[5] |= 0x20; /* Sniff Subrating */
|
|
|
|
|
|
if (hdev->features[5] & LMP_PAUSE_ENC)
|
|
@@ -522,13 +522,13 @@ static void hci_setup_event_mask(struct hci_dev *hdev)
|
|
|
if (hdev->features[6] & LMP_EXT_INQ)
|
|
|
events[5] |= 0x40; /* Extended Inquiry Result */
|
|
|
|
|
|
- if (hdev->features[6] & LMP_NO_FLUSH)
|
|
|
+ if (lmp_no_flush_capable(hdev))
|
|
|
events[7] |= 0x01; /* Enhanced Flush Complete */
|
|
|
|
|
|
if (hdev->features[7] & LMP_LSTO)
|
|
|
events[6] |= 0x80; /* Link Supervision Timeout Changed */
|
|
|
|
|
|
- if (hdev->features[6] & LMP_SIMPLE_PAIR) {
|
|
|
+ if (lmp_ssp_capable(hdev)) {
|
|
|
events[6] |= 0x01; /* IO Capability Request */
|
|
|
events[6] |= 0x02; /* IO Capability Response */
|
|
|
events[6] |= 0x04; /* User Confirmation Request */
|
|
@@ -541,7 +541,7 @@ static void hci_setup_event_mask(struct hci_dev *hdev)
|
|
|
* Features Notification */
|
|
|
}
|
|
|
|
|
|
- if (hdev->features[4] & LMP_LE)
|
|
|
+ if (lmp_le_capable(hdev))
|
|
|
events[7] |= 0x20; /* LE Meta-Event */
|
|
|
|
|
|
hci_send_cmd(hdev, HCI_OP_SET_EVENT_MASK, sizeof(events), events);
|
|
@@ -623,11 +623,11 @@ static void hci_setup_link_policy(struct hci_dev *hdev)
|
|
|
struct hci_cp_write_def_link_policy cp;
|
|
|
u16 link_policy = 0;
|
|
|
|
|
|
- if (hdev->features[0] & LMP_RSWITCH)
|
|
|
+ if (lmp_rswitch_capable(hdev))
|
|
|
link_policy |= HCI_LP_RSWITCH;
|
|
|
if (hdev->features[0] & LMP_HOLD)
|
|
|
link_policy |= HCI_LP_HOLD;
|
|
|
- if (hdev->features[0] & LMP_SNIFF)
|
|
|
+ if (lmp_sniff_capable(hdev))
|
|
|
link_policy |= HCI_LP_SNIFF;
|
|
|
if (hdev->features[1] & LMP_PARK)
|
|
|
link_policy |= HCI_LP_PARK;
|
|
@@ -686,7 +686,7 @@ static void hci_cc_read_local_features(struct hci_dev *hdev,
|
|
|
hdev->esco_type |= (ESCO_HV3);
|
|
|
}
|
|
|
|
|
|
- if (hdev->features[3] & LMP_ESCO)
|
|
|
+ if (lmp_esco_capable(hdev))
|
|
|
hdev->esco_type |= (ESCO_EV3);
|
|
|
|
|
|
if (hdev->features[4] & LMP_EV4)
|
|
@@ -746,7 +746,7 @@ static void hci_cc_read_local_ext_features(struct hci_dev *hdev,
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (test_bit(HCI_INIT, &hdev->flags) && hdev->features[4] & LMP_LE)
|
|
|
+ if (test_bit(HCI_INIT, &hdev->flags) && lmp_le_capable(hdev))
|
|
|
hci_set_le_support(hdev);
|
|
|
|
|
|
done:
|
|
@@ -1614,43 +1614,30 @@ static void hci_cs_disconnect(struct hci_dev *hdev, u8 status)
|
|
|
|
|
|
static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
|
|
|
{
|
|
|
- struct hci_cp_le_create_conn *cp;
|
|
|
struct hci_conn *conn;
|
|
|
|
|
|
BT_DBG("%s status 0x%2.2x", hdev->name, status);
|
|
|
|
|
|
- cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN);
|
|
|
- if (!cp)
|
|
|
- return;
|
|
|
+ if (status) {
|
|
|
+ hci_dev_lock(hdev);
|
|
|
|
|
|
- hci_dev_lock(hdev);
|
|
|
+ conn = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT);
|
|
|
+ if (!conn) {
|
|
|
+ hci_dev_unlock(hdev);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->peer_addr);
|
|
|
+ BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&conn->dst),
|
|
|
+ conn);
|
|
|
|
|
|
- BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&cp->peer_addr),
|
|
|
- conn);
|
|
|
+ conn->state = BT_CLOSED;
|
|
|
+ mgmt_connect_failed(hdev, &conn->dst, conn->type,
|
|
|
+ conn->dst_type, status);
|
|
|
+ hci_proto_connect_cfm(conn, status);
|
|
|
+ hci_conn_del(conn);
|
|
|
|
|
|
- if (status) {
|
|
|
- if (conn && conn->state == BT_CONNECT) {
|
|
|
- conn->state = BT_CLOSED;
|
|
|
- mgmt_connect_failed(hdev, &cp->peer_addr, conn->type,
|
|
|
- conn->dst_type, status);
|
|
|
- hci_proto_connect_cfm(conn, status);
|
|
|
- hci_conn_del(conn);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!conn) {
|
|
|
- conn = hci_conn_add(hdev, LE_LINK, &cp->peer_addr);
|
|
|
- if (conn) {
|
|
|
- conn->dst_type = cp->peer_addr_type;
|
|
|
- conn->out = true;
|
|
|
- } else {
|
|
|
- BT_ERR("No memory for new connection");
|
|
|
- }
|
|
|
- }
|
|
|
+ hci_dev_unlock(hdev);
|
|
|
}
|
|
|
-
|
|
|
- hci_dev_unlock(hdev);
|
|
|
}
|
|
|
|
|
|
static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status)
|
|
@@ -3252,12 +3239,8 @@ static void hci_user_passkey_request_evt(struct hci_dev *hdev,
|
|
|
|
|
|
BT_DBG("%s", hdev->name);
|
|
|
|
|
|
- hci_dev_lock(hdev);
|
|
|
-
|
|
|
if (test_bit(HCI_MGMT, &hdev->dev_flags))
|
|
|
mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0);
|
|
|
-
|
|
|
- hci_dev_unlock(hdev);
|
|
|
}
|
|
|
|
|
|
static void hci_simple_pair_complete_evt(struct hci_dev *hdev,
|
|
@@ -3350,11 +3333,23 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
|
|
|
|
|
|
hci_dev_lock(hdev);
|
|
|
|
|
|
- if (ev->status) {
|
|
|
- conn = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT);
|
|
|
- if (!conn)
|
|
|
+ conn = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT);
|
|
|
+ if (!conn) {
|
|
|
+ conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr);
|
|
|
+ if (!conn) {
|
|
|
+ BT_ERR("No memory for new connection");
|
|
|
goto unlock;
|
|
|
+ }
|
|
|
|
|
|
+ conn->dst_type = ev->bdaddr_type;
|
|
|
+
|
|
|
+ if (ev->role == LE_CONN_ROLE_MASTER) {
|
|
|
+ conn->out = true;
|
|
|
+ conn->link_mode |= HCI_LM_MASTER;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ev->status) {
|
|
|
mgmt_connect_failed(hdev, &conn->dst, conn->type,
|
|
|
conn->dst_type, ev->status);
|
|
|
hci_proto_connect_cfm(conn, ev->status);
|
|
@@ -3363,18 +3358,6 @@ static void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
|
|
|
goto unlock;
|
|
|
}
|
|
|
|
|
|
- conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &ev->bdaddr);
|
|
|
- if (!conn) {
|
|
|
- conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr);
|
|
|
- if (!conn) {
|
|
|
- BT_ERR("No memory for new connection");
|
|
|
- hci_dev_unlock(hdev);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- conn->dst_type = ev->bdaddr_type;
|
|
|
- }
|
|
|
-
|
|
|
if (!test_and_set_bit(HCI_CONN_MGMT_CONNECTED, &conn->flags))
|
|
|
mgmt_device_connected(hdev, &ev->bdaddr, conn->type,
|
|
|
conn->dst_type, 0, NULL, 0, NULL);
|