@@ -1780,8 +1780,6 @@ int hci_dev_do_close(struct hci_dev *hdev)
hci_sock_dev_event(hdev, HCI_DEV_DOWN);
- msft_do_close(hdev);
-
if (hdev->flush)
hdev->flush(hdev);
@@ -3869,6 +3867,8 @@ void hci_unregister_dev(struct hci_dev *hdev)
unregister_pm_notifier(&hdev->suspend_notifier);
cancel_work_sync(&hdev->suspend_prepare);
+ msft_do_close(hdev);
+
hci_dev_do_close(hdev);
if (!test_bit(HCI_INIT, &hdev->flags) &&
@@ -76,7 +76,8 @@ void msft_do_open(struct hci_dev *hdev)
{
struct msft_data *msft;
- if (hdev->msft_opcode == HCI_OP_NOP)
+ /* Skip if opcode is not supported or MSFT has been initiatlized */
+ if (hdev->msft_opcode == HCI_OP_NOP || hdev->msft_data)
return;
bt_dev_dbg(hdev, "Initialize MSFT extension");