Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
[linux-2.6-microblaze.git] / net / bluetooth / hci_core.c
index 7d71d10..2560ed2 100644 (file)
@@ -545,24 +545,24 @@ static void hci_set_event_mask_page_2(struct hci_request *req)
        u8 events[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
        bool changed = false;
 
-       /* If Connectionless Slave Broadcast master role is supported
+       /* If Connectionless Peripheral Broadcast central role is supported
         * enable all necessary events for it.
         */
-       if (lmp_csb_master_capable(hdev)) {
+       if (lmp_cpb_central_capable(hdev)) {
                events[1] |= 0x40;      /* Triggered Clock Capture */
                events[1] |= 0x80;      /* Synchronization Train Complete */
-               events[2] |= 0x10;      /* Slave Page Response Timeout */
-               events[2] |= 0x20;      /* CSB Channel Map Change */
+               events[2] |= 0x10;      /* Peripheral Page Response Timeout */
+               events[2] |= 0x20;      /* CPB Channel Map Change */
                changed = true;
        }
 
-       /* If Connectionless Slave Broadcast slave role is supported
+       /* If Connectionless Peripheral Broadcast peripheral role is supported
         * enable all necessary events for it.
         */
-       if (lmp_csb_slave_capable(hdev)) {
+       if (lmp_cpb_peripheral_capable(hdev)) {
                events[2] |= 0x01;      /* Synchronization Train Received */
-               events[2] |= 0x02;      /* CSB Receive */
-               events[2] |= 0x04;      /* CSB Timeout */
+               events[2] |= 0x02;      /* CPB Receive */
+               events[2] |= 0x04;      /* CPB Timeout */
                events[2] |= 0x08;      /* Truncated Page Complete */
                changed = true;
        }
@@ -648,7 +648,7 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
                                                 */
 
                /* If the controller supports Extended Scanner Filter
-                * Policies, enable the correspondig event.
+                * Policies, enable the corresponding event.
                 */
                if (hdev->le_features[0] & HCI_LE_EXT_SCAN_POLICY)
                        events[1] |= 0x04;      /* LE Direct Advertising
@@ -749,14 +749,14 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
                }
 
                if (hdev->commands[26] & 0x40) {
-                       /* Read LE White List Size */
-                       hci_req_add(req, HCI_OP_LE_READ_WHITE_LIST_SIZE,
+                       /* Read LE Accept List Size */
+                       hci_req_add(req, HCI_OP_LE_READ_ACCEPT_LIST_SIZE,
                                    0, NULL);
                }
 
                if (hdev->commands[26] & 0x80) {
-                       /* Clear LE White List */
-                       hci_req_add(req, HCI_OP_LE_CLEAR_WHITE_LIST, 0, NULL);
+                       /* Clear LE Accept List */
+                       hci_req_add(req, HCI_OP_LE_CLEAR_ACCEPT_LIST, 0, NULL);
                }
 
                if (hdev->commands[34] & 0x40) {
@@ -1454,7 +1454,7 @@ static int hci_dev_do_open(struct hci_dev *hdev)
                }
 
                /* Check for valid public address or a configured static
-                * random adddress, but let the HCI setup proceed to
+                * random address, but let the HCI setup proceed to
                 * be able to determine if there is a public address
                 * or not.
                 *
@@ -1721,15 +1721,8 @@ int hci_dev_do_close(struct hci_dev *hdev)
 
        BT_DBG("%s %p", hdev->name, hdev);
 
-       if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
-           !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
-           test_bit(HCI_UP, &hdev->flags)) {
-               /* Execute vendor specific shutdown routine */
-               if (hdev->shutdown)
-                       hdev->shutdown(hdev);
-       }
-
        cancel_delayed_work(&hdev->power_off);
+       cancel_delayed_work(&hdev->ncmd_timer);
 
        hci_request_cancel_all(hdev);
        hci_req_sync_lock(hdev);
@@ -1805,6 +1798,14 @@ int hci_dev_do_close(struct hci_dev *hdev)
                clear_bit(HCI_INIT, &hdev->flags);
        }
 
+       if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
+           !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
+           test_bit(HCI_UP, &hdev->flags)) {
+               /* Execute vendor specific shutdown routine */
+               if (hdev->shutdown)
+                       hdev->shutdown(hdev);
+       }
+
        /* flush cmd  work */
        flush_work(&hdev->cmd_work);
 
@@ -2777,6 +2778,24 @@ static void hci_cmd_timeout(struct work_struct *work)
        queue_work(hdev->workqueue, &hdev->cmd_work);
 }
 
+/* HCI ncmd timer function */
+static void hci_ncmd_timeout(struct work_struct *work)
+{
+       struct hci_dev *hdev = container_of(work, struct hci_dev,
+                                           ncmd_timer.work);
+
+       bt_dev_err(hdev, "Controller not accepting commands anymore: ncmd = 0");
+
+       /* During HCI_INIT phase no events can be injected if the ncmd timer
+        * triggers since the procedure has its own timeout handling.
+        */
+       if (test_bit(HCI_INIT, &hdev->flags))
+               return;
+
+       /* This is an irrecoverable state, inject hardware error event */
+       hci_reset_dev(hdev);
+}
+
 struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
                                          bdaddr_t *bdaddr, u8 bdaddr_type)
 {
@@ -3549,7 +3568,7 @@ void hci_conn_params_clear_disabled(struct hci_dev *hdev)
                if (params->auto_connect != HCI_AUTO_CONN_DISABLED)
                        continue;
 
-               /* If trying to estabilish one time connection to disabled
+               /* If trying to establish one time connection to disabled
                 * device, leave the params, but mark them as just once.
                 */
                if (params->explicit_connect) {
@@ -3694,13 +3713,13 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action,
                /* Suspend consists of two actions:
                 *  - First, disconnect everything and make the controller not
                 *    connectable (disabling scanning)
-                *  - Second, program event filter/whitelist and enable scan
+                *  - Second, program event filter/accept list and enable scan
                 */
                ret = hci_change_suspend_state(hdev, BT_SUSPEND_DISCONNECT);
                if (!ret)
                        state = BT_SUSPEND_DISCONNECT;
 
-               /* Only configure whitelist if disconnect succeeded and wake
+               /* Only configure accept list if disconnect succeeded and wake
                 * isn't being prevented.
                 */
                if (!ret && !(hdev->prevent_wake && hdev->prevent_wake(hdev))) {
@@ -3808,14 +3827,14 @@ struct hci_dev *hci_alloc_dev(void)
        mutex_init(&hdev->req_lock);
 
        INIT_LIST_HEAD(&hdev->mgmt_pending);
-       INIT_LIST_HEAD(&hdev->blacklist);
-       INIT_LIST_HEAD(&hdev->whitelist);
+       INIT_LIST_HEAD(&hdev->reject_list);
+       INIT_LIST_HEAD(&hdev->accept_list);
        INIT_LIST_HEAD(&hdev->uuids);
        INIT_LIST_HEAD(&hdev->link_keys);
        INIT_LIST_HEAD(&hdev->long_term_keys);
        INIT_LIST_HEAD(&hdev->identity_resolving_keys);
        INIT_LIST_HEAD(&hdev->remote_oob_data);
-       INIT_LIST_HEAD(&hdev->le_white_list);
+       INIT_LIST_HEAD(&hdev->le_accept_list);
        INIT_LIST_HEAD(&hdev->le_resolv_list);
        INIT_LIST_HEAD(&hdev->le_conn_params);
        INIT_LIST_HEAD(&hdev->pend_le_conns);
@@ -3841,6 +3860,7 @@ struct hci_dev *hci_alloc_dev(void)
        init_waitqueue_head(&hdev->suspend_wait_q);
 
        INIT_DELAYED_WORK(&hdev->cmd_timer, hci_cmd_timeout);
+       INIT_DELAYED_WORK(&hdev->ncmd_timer, hci_ncmd_timeout);
 
        hci_request_setup(hdev);
 
@@ -4027,8 +4047,8 @@ void hci_unregister_dev(struct hci_dev *hdev)
        destroy_workqueue(hdev->req_workqueue);
 
        hci_dev_lock(hdev);
-       hci_bdaddr_list_clear(&hdev->blacklist);
-       hci_bdaddr_list_clear(&hdev->whitelist);
+       hci_bdaddr_list_clear(&hdev->reject_list);
+       hci_bdaddr_list_clear(&hdev->accept_list);
        hci_uuids_clear(hdev);
        hci_link_keys_clear(hdev);
        hci_smp_ltks_clear(hdev);
@@ -4036,7 +4056,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
        hci_remote_oob_data_clear(hdev);
        hci_adv_instances_clear(hdev);
        hci_adv_monitors_clear(hdev);
-       hci_bdaddr_list_clear(&hdev->le_white_list);
+       hci_bdaddr_list_clear(&hdev->le_accept_list);
        hci_bdaddr_list_clear(&hdev->le_resolv_list);
        hci_conn_params_clear_all(hdev);
        hci_discovery_filter_clear(hdev);
@@ -4078,6 +4098,8 @@ int hci_reset_dev(struct hci_dev *hdev)
        hci_skb_pkt_type(skb) = HCI_EVENT_PKT;
        skb_put_data(skb, hw_err, 3);
 
+       bt_dev_err(hdev, "Injecting HCI hardware error event");
+
        /* Send Hardware Error to upper stack */
        return hci_recv_frame(hdev, skb);
 }
@@ -4284,7 +4306,7 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode)
        return hdev->sent_cmd->data + HCI_COMMAND_HDR_SIZE;
 }
 
-/* Send HCI command and wait for command commplete event */
+/* Send HCI command and wait for command complete event */
 struct sk_buff *hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
                             const void *param, u32 timeout)
 {