Bluetooth: Cancel sync command before suspend and power off
[linux-2.6-block.git] / net / bluetooth / mgmt.c
index 5f8c144c84b886533244066f98da905ebca5d50f..13c745876b39080a629a330dc701a292ea050e35 100644 (file)
@@ -1399,6 +1399,10 @@ static int set_powered(struct sock *sk, struct hci_dev *hdev, void *data,
                goto failed;
        }
 
+       /* Cancel potentially blocking sync operation before power off */
+       if (cp->val == 0x00)
+               __hci_cmd_sync_cancel(hdev, -EHOSTDOWN);
+
        err = hci_cmd_sync_queue(hdev, set_powered_sync, cmd,
                                 mgmt_set_powered_complete);