Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[firefly-linux-kernel-4.4.55.git] / net / bluetooth / hci_event.c
index 0dd85a0c05f4ddfa502eda0f78ae07116b27a123..138580745c2ce2679e04475b86131c3f34effca9 100644 (file)
@@ -194,8 +194,7 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
        clear_bit(HCI_RESET, &hdev->flags);
 
        /* Reset all non-persistent flags */
-       hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS) |
-                            BIT(HCI_PERIODIC_INQ));
+       hdev->dev_flags &= ~HCI_PERSISTENT_MASK;
 
        hdev->discovery.state = DISCOVERY_STOPPED;
        hdev->inq_tx_power = HCI_TX_POWER_INVALID;
@@ -224,9 +223,6 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
                memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH);
 
        hci_dev_unlock(hdev);
-
-       if (!status && !test_bit(HCI_INIT, &hdev->flags))
-               hci_update_ad(hdev);
 }
 
 static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb)
@@ -424,13 +420,6 @@ static void hci_cc_write_voice_setting(struct hci_dev *hdev,
                hdev->notify(hdev, HCI_NOTIFY_VOICE_SETTING);
 }
 
-static void hci_cc_host_buffer_size(struct hci_dev *hdev, struct sk_buff *skb)
-{
-       __u8 status = *((__u8 *) skb->data);
-
-       BT_DBG("%s status 0x%2.2x", hdev->name, status);
-}
-
 static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
 {
        __u8 status = *((__u8 *) skb->data);
@@ -612,6 +601,65 @@ static void hci_cc_read_bd_addr(struct hci_dev *hdev, struct sk_buff *skb)
                bacpy(&hdev->bdaddr, &rp->bdaddr);
 }
 
+static void hci_cc_read_page_scan_activity(struct hci_dev *hdev,
+                                          struct sk_buff *skb)
+{
+       struct hci_rp_read_page_scan_activity *rp = (void *) skb->data;
+
+       BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
+
+       if (test_bit(HCI_INIT, &hdev->flags) && !rp->status) {
+               hdev->page_scan_interval = __le16_to_cpu(rp->interval);
+               hdev->page_scan_window = __le16_to_cpu(rp->window);
+       }
+}
+
+static void hci_cc_write_page_scan_activity(struct hci_dev *hdev,
+                                           struct sk_buff *skb)
+{
+       u8 status = *((u8 *) skb->data);
+       struct hci_cp_write_page_scan_activity *sent;
+
+       BT_DBG("%s status 0x%2.2x", hdev->name, status);
+
+       if (status)
+               return;
+
+       sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_ACTIVITY);
+       if (!sent)
+               return;
+
+       hdev->page_scan_interval = __le16_to_cpu(sent->interval);
+       hdev->page_scan_window = __le16_to_cpu(sent->window);
+}
+
+static void hci_cc_read_page_scan_type(struct hci_dev *hdev,
+                                          struct sk_buff *skb)
+{
+       struct hci_rp_read_page_scan_type *rp = (void *) skb->data;
+
+       BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
+
+       if (test_bit(HCI_INIT, &hdev->flags) && !rp->status)
+               hdev->page_scan_type = rp->type;
+}
+
+static void hci_cc_write_page_scan_type(struct hci_dev *hdev,
+                                       struct sk_buff *skb)
+{
+       u8 status = *((u8 *) skb->data);
+       u8 *type;
+
+       BT_DBG("%s status 0x%2.2x", hdev->name, status);
+
+       if (status)
+               return;
+
+       type = hci_sent_cmd_data(hdev, HCI_OP_WRITE_PAGE_SCAN_TYPE);
+       if (type)
+               hdev->page_scan_type = *type;
+}
+
 static void hci_cc_read_data_block_size(struct hci_dev *hdev,
                                        struct sk_buff *skb)
 {
@@ -632,13 +680,6 @@ static void hci_cc_read_data_block_size(struct hci_dev *hdev,
               hdev->block_cnt, hdev->block_len);
 }
 
-static void hci_cc_write_ca_timeout(struct hci_dev *hdev, struct sk_buff *skb)
-{
-       __u8 status = *((__u8 *) skb->data);
-
-       BT_DBG("%s status 0x%2.2x", hdev->name, status);
-}
-
 static void hci_cc_read_local_amp_info(struct hci_dev *hdev,
                                       struct sk_buff *skb)
 {
@@ -701,29 +742,6 @@ a2mp_rsp:
        a2mp_send_create_phy_link_req(hdev, rp->status);
 }
 
-static void hci_cc_delete_stored_link_key(struct hci_dev *hdev,
-                                         struct sk_buff *skb)
-{
-       __u8 status = *((__u8 *) skb->data);
-
-       BT_DBG("%s status 0x%2.2x", hdev->name, status);
-}
-
-static void hci_cc_set_event_mask(struct hci_dev *hdev, struct sk_buff *skb)
-{
-       __u8 status = *((__u8 *) skb->data);
-
-       BT_DBG("%s status 0x%2.2x", hdev->name, status);
-}
-
-static void hci_cc_write_inquiry_mode(struct hci_dev *hdev,
-                                     struct sk_buff *skb)
-{
-       __u8 status = *((__u8 *) skb->data);
-
-       BT_DBG("%s status 0x%2.2x", hdev->name, status);
-}
-
 static void hci_cc_read_inq_rsp_tx_power(struct hci_dev *hdev,
                                         struct sk_buff *skb)
 {
@@ -735,13 +753,6 @@ static void hci_cc_read_inq_rsp_tx_power(struct hci_dev *hdev,
                hdev->inq_tx_power = rp->tx_power;
 }
 
-static void hci_cc_set_event_flt(struct hci_dev *hdev, struct sk_buff *skb)
-{
-       __u8 status = *((__u8 *) skb->data);
-
-       BT_DBG("%s status 0x%2.2x", hdev->name, status);
-}
-
 static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb)
 {
        struct hci_rp_pin_code_reply *rp = (void *) skb->data;
@@ -821,18 +832,8 @@ static void hci_cc_le_read_adv_tx_power(struct hci_dev *hdev,
 
        BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
 
-       if (!rp->status) {
+       if (!rp->status)
                hdev->adv_tx_power = rp->tx_power;
-               if (!test_bit(HCI_INIT, &hdev->flags))
-                       hci_update_ad(hdev);
-       }
-}
-
-static void hci_cc_le_set_event_mask(struct hci_dev *hdev, struct sk_buff *skb)
-{
-       __u8 status = *((__u8 *) skb->data);
-
-       BT_DBG("%s status 0x%2.2x", hdev->name, status);
 }
 
 static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb)
@@ -929,10 +930,15 @@ static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb)
                        clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
        }
 
-       hci_dev_unlock(hdev);
+       if (!test_bit(HCI_INIT, &hdev->flags)) {
+               struct hci_request req;
+
+               hci_req_init(&req, hdev);
+               hci_update_ad(&req);
+               hci_req_run(&req, NULL);
+       }
 
-       if (!test_bit(HCI_INIT, &hdev->flags))
-               hci_update_ad(hdev);
+       hci_dev_unlock(hdev);
 }
 
 static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb)
@@ -1015,26 +1021,6 @@ static void hci_cc_le_read_white_list_size(struct hci_dev *hdev,
                hdev->le_white_list_size = rp->size;
 }
 
-static void hci_cc_le_ltk_reply(struct hci_dev *hdev, struct sk_buff *skb)
-{
-       struct hci_rp_le_ltk_reply *rp = (void *) skb->data;
-
-       BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
-
-       if (rp->status)
-               return;
-}
-
-static void hci_cc_le_ltk_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
-{
-       struct hci_rp_le_ltk_neg_reply *rp = (void *) skb->data;
-
-       BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
-
-       if (rp->status)
-               return;
-}
-
 static void hci_cc_le_read_supported_states(struct hci_dev *hdev,
                                            struct sk_buff *skb)
 {
@@ -1565,11 +1551,6 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
        }
 }
 
-static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status)
-{
-       BT_DBG("%s status 0x%2.2x", hdev->name, status);
-}
-
 static void hci_cs_create_phylink(struct hci_dev *hdev, u8 status)
 {
        struct hci_cp_create_phy_link *cp;
@@ -1611,11 +1592,6 @@ static void hci_cs_accept_phylink(struct hci_dev *hdev, u8 status)
        amp_write_remote_assoc(hdev, cp->phy_handle);
 }
 
-static void hci_cs_create_logical_link(struct hci_dev *hdev, u8 status)
-{
-       BT_DBG("%s status 0x%2.2x", hdev->name, status);
-}
-
 static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
        __u8 status = *((__u8 *) skb->data);
@@ -2172,17 +2148,6 @@ unlock:
        hci_dev_unlock(hdev);
 }
 
-static void hci_remote_version_evt(struct hci_dev *hdev, struct sk_buff *skb)
-{
-       BT_DBG("%s", hdev->name);
-}
-
-static void hci_qos_setup_complete_evt(struct hci_dev *hdev,
-                                      struct sk_buff *skb)
-{
-       BT_DBG("%s", hdev->name);
-}
-
 static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
        struct hci_ev_cmd_complete *ev = (void *) skb->data;
@@ -2270,10 +2235,6 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
                hci_cc_write_voice_setting(hdev, skb);
                break;
 
-       case HCI_OP_HOST_BUFFER_SIZE:
-               hci_cc_host_buffer_size(hdev, skb);
-               break;
-
        case HCI_OP_WRITE_SSP_MODE:
                hci_cc_write_ssp_mode(hdev, skb);
                break;
@@ -2302,46 +2263,42 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
                hci_cc_read_bd_addr(hdev, skb);
                break;
 
-       case HCI_OP_READ_DATA_BLOCK_SIZE:
-               hci_cc_read_data_block_size(hdev, skb);
+       case HCI_OP_READ_PAGE_SCAN_ACTIVITY:
+               hci_cc_read_page_scan_activity(hdev, skb);
                break;
 
-       case HCI_OP_WRITE_CA_TIMEOUT:
-               hci_cc_write_ca_timeout(hdev, skb);
+       case HCI_OP_WRITE_PAGE_SCAN_ACTIVITY:
+               hci_cc_write_page_scan_activity(hdev, skb);
                break;
 
-       case HCI_OP_READ_FLOW_CONTROL_MODE:
-               hci_cc_read_flow_control_mode(hdev, skb);
+       case HCI_OP_READ_PAGE_SCAN_TYPE:
+               hci_cc_read_page_scan_type(hdev, skb);
                break;
 
-       case HCI_OP_READ_LOCAL_AMP_INFO:
-               hci_cc_read_local_amp_info(hdev, skb);
+       case HCI_OP_WRITE_PAGE_SCAN_TYPE:
+               hci_cc_write_page_scan_type(hdev, skb);
                break;
 
-       case HCI_OP_READ_LOCAL_AMP_ASSOC:
-               hci_cc_read_local_amp_assoc(hdev, skb);
+       case HCI_OP_READ_DATA_BLOCK_SIZE:
+               hci_cc_read_data_block_size(hdev, skb);
                break;
 
-       case HCI_OP_DELETE_STORED_LINK_KEY:
-               hci_cc_delete_stored_link_key(hdev, skb);
+       case HCI_OP_READ_FLOW_CONTROL_MODE:
+               hci_cc_read_flow_control_mode(hdev, skb);
                break;
 
-       case HCI_OP_SET_EVENT_MASK:
-               hci_cc_set_event_mask(hdev, skb);
+       case HCI_OP_READ_LOCAL_AMP_INFO:
+               hci_cc_read_local_amp_info(hdev, skb);
                break;
 
-       case HCI_OP_WRITE_INQUIRY_MODE:
-               hci_cc_write_inquiry_mode(hdev, skb);
+       case HCI_OP_READ_LOCAL_AMP_ASSOC:
+               hci_cc_read_local_amp_assoc(hdev, skb);
                break;
 
        case HCI_OP_READ_INQ_RSP_TX_POWER:
                hci_cc_read_inq_rsp_tx_power(hdev, skb);
                break;
 
-       case HCI_OP_SET_EVENT_FLT:
-               hci_cc_set_event_flt(hdev, skb);
-               break;
-
        case HCI_OP_PIN_CODE_REPLY:
                hci_cc_pin_code_reply(hdev, skb);
                break;
@@ -2366,10 +2323,6 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
                hci_cc_le_read_adv_tx_power(hdev, skb);
                break;
 
-       case HCI_OP_LE_SET_EVENT_MASK:
-               hci_cc_le_set_event_mask(hdev, skb);
-               break;
-
        case HCI_OP_USER_CONFIRM_REPLY:
                hci_cc_user_confirm_reply(hdev, skb);
                break;
@@ -2402,14 +2355,6 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
                hci_cc_le_read_white_list_size(hdev, skb);
                break;
 
-       case HCI_OP_LE_LTK_REPLY:
-               hci_cc_le_ltk_reply(hdev, skb);
-               break;
-
-       case HCI_OP_LE_LTK_NEG_REPLY:
-               hci_cc_le_ltk_neg_reply(hdev, skb);
-               break;
-
        case HCI_OP_LE_READ_SUPPORTED_STATES:
                hci_cc_le_read_supported_states(hdev, skb);
                break;
@@ -2427,10 +2372,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
                break;
        }
 
-       if (ev->opcode != HCI_OP_NOP)
+       if (opcode != HCI_OP_NOP)
                del_timer(&hdev->cmd_timer);
 
-       hci_req_cmd_complete(hdev, ev->opcode, status);
+       hci_req_cmd_complete(hdev, opcode, status);
 
        if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) {
                atomic_set(&hdev->cmd_cnt, 1);
@@ -2501,10 +2446,6 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
                hci_cs_le_create_conn(hdev, ev->status);
                break;
 
-       case HCI_OP_LE_START_ENC:
-               hci_cs_le_start_enc(hdev, ev->status);
-               break;
-
        case HCI_OP_CREATE_PHY_LINK:
                hci_cs_create_phylink(hdev, ev->status);
                break;
@@ -2513,19 +2454,15 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
                hci_cs_accept_phylink(hdev, ev->status);
                break;
 
-       case HCI_OP_CREATE_LOGICAL_LINK:
-               hci_cs_create_logical_link(hdev, ev->status);
-               break;
-
        default:
                BT_DBG("%s opcode 0x%4.4x", hdev->name, opcode);
                break;
        }
 
-       if (ev->opcode != HCI_OP_NOP)
+       if (opcode != HCI_OP_NOP)
                del_timer(&hdev->cmd_timer);
 
-       hci_req_cmd_status(hdev, ev->opcode, ev->status);
+       hci_req_cmd_status(hdev, opcode, ev->status);
 
        if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) {
                atomic_set(&hdev->cmd_cnt, 1);
@@ -3077,18 +3014,6 @@ unlock:
        hci_dev_unlock(hdev);
 }
 
-static void hci_sync_conn_changed_evt(struct hci_dev *hdev, struct sk_buff *skb)
-{
-       BT_DBG("%s", hdev->name);
-}
-
-static void hci_sniff_subrate_evt(struct hci_dev *hdev, struct sk_buff *skb)
-{
-       struct hci_ev_sniff_subrate *ev = (void *) skb->data;
-
-       BT_DBG("%s status 0x%2.2x", hdev->name, ev->status);
-}
-
 static void hci_extended_inquiry_result_evt(struct hci_dev *hdev,
                                            struct sk_buff *skb)
 {
@@ -3816,14 +3741,6 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
                hci_remote_features_evt(hdev, skb);
                break;
 
-       case HCI_EV_REMOTE_VERSION:
-               hci_remote_version_evt(hdev, skb);
-               break;
-
-       case HCI_EV_QOS_SETUP_COMPLETE:
-               hci_qos_setup_complete_evt(hdev, skb);
-               break;
-
        case HCI_EV_CMD_COMPLETE:
                hci_cmd_complete_evt(hdev, skb);
                break;
@@ -3880,14 +3797,6 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
                hci_sync_conn_complete_evt(hdev, skb);
                break;
 
-       case HCI_EV_SYNC_CONN_CHANGED:
-               hci_sync_conn_changed_evt(hdev, skb);
-               break;
-
-       case HCI_EV_SNIFF_SUBRATE:
-               hci_sniff_subrate_evt(hdev, skb);
-               break;
-
        case HCI_EV_EXTENDED_INQUIRY_RESULT:
                hci_extended_inquiry_result_evt(hdev, skb);
                break;