Bluetooth: Send power off notification earlier in the device close process
Notifying Bluez userspace of a shutdown earlier prevents new commands from
being sent. The extra commands were interfering with reinitialization of
the device
Change-Id: I862a658585ffa69348fbb4bdfba96f3916d0e5ef
Signed-off-by: Bhasker Neti <bneti@codeaurora.org>
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e1a90f8..dd1d6e8 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -639,6 +639,12 @@
hci_notify(hdev, HCI_DEV_DOWN);
+ if (hdev->dev_type == HCI_BREDR) {
+ hci_dev_lock_bh(hdev);
+ mgmt_powered(hdev->id, 0);
+ hci_dev_unlock_bh(hdev);
+ }
+
if (hdev->flush)
hdev->flush(hdev);
@@ -671,12 +677,6 @@
* and no tasks are scheduled. */
hdev->close(hdev);
- if (hdev->dev_type == HCI_BREDR) {
- hci_dev_lock_bh(hdev);
- mgmt_powered(hdev->id, 0);
- hci_dev_unlock_bh(hdev);
- }
-
/* Clear only non-persistent flags */
if (test_bit(HCI_MGMT, &hdev->flags))
set_bit(HCI_MGMT, &keepflags);