{
BT_DBG("%s status 0x%02x", hdev->name, status);
- if (hci_conn_count(hdev) == 0)
+ if (hci_conn_count(hdev) == 0) {
+ cancel_delayed_work(&hdev->power_off);
queue_work(hdev->req_workqueue, &hdev->power_off.work);
+ }
}
static int clean_up_hci_state(struct hci_dev *hdev)
} else {
/* Disconnect connections, stop scans, etc */
err = clean_up_hci_state(hdev);
+ if (!err)
+ queue_delayed_work(hdev->req_workqueue, &hdev->power_off,
+ HCI_POWER_OFF_TIMEOUT);
/* ENODATA means there were no HCI commands queued */
if (err == -ENODATA) {
+ cancel_delayed_work(&hdev->power_off);
queue_work(hdev->req_workqueue, &hdev->power_off.work);
err = 0;
}
/* The connection is still in hci_conn_hash so test for 1
* instead of 0 to know if this is the last one.
*/
- if (!cp->val && hci_conn_count(hdev) == 1)
+ if (!cp->val && hci_conn_count(hdev) == 1) {
+ cancel_delayed_work(&hdev->power_off);
queue_work(hdev->req_workqueue, &hdev->power_off.work);
+ }
}
if (!mgmt_connected)
/* The connection is still in hci_conn_hash so test for 1
* instead of 0 to know if this is the last one.
*/
- if (!cp->val && hci_conn_count(hdev) == 1)
+ if (!cp->val && hci_conn_count(hdev) == 1) {
+ cancel_delayed_work(&hdev->power_off);
queue_work(hdev->req_workqueue, &hdev->power_off.work);
+ }
}
bacpy(&ev.addr.bdaddr, bdaddr);