Skip to content

Commit 81dafad

Browse files
apanditholtmann
authored andcommitted
Bluetooth: Add hook for driver to prevent wake from suspend
Let drivers have a hook to disable configuring scanning during suspend. Drivers should use the device_may_wakeup function call to determine whether hci should be configured for wakeup. For example, an implementation for btusb may look like the following: bool btusb_prevent_wake(struct hci_dev *hdev) { struct btusb_data *data = hci_get_drvdata(hdev); return !device_may_wakeup(&data->udev->dev); } Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> Reviewed-by: Alain Michaud <alainm@chromium.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 0d2c982 commit 81dafad

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎include/net/bluetooth/hci_core.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ struct hci_dev {
503503
int (*set_diag)(struct hci_dev *hdev, bool enable);
504504
int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr);
505505
void (*cmd_timeout)(struct hci_dev *hdev);
506+
bool (*prevent_wake)(struct hci_dev *hdev);
506507
};
507508

508509
#define HCI_PHY_HANDLE(handle) (handle & 0xff)

‎net/bluetooth/hci_core.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3350,8 +3350,10 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action,
33503350
*/
33513351
ret = hci_change_suspend_state(hdev, BT_SUSPEND_DISCONNECT);
33523352

3353-
/* Only configure whitelist if disconnect succeeded */
3354-
if (!ret)
3353+
/* Only configure whitelist if disconnect succeeded and wake
3354+
* isn't being prevented.
3355+
*/
3356+
if (!ret && !(hdev->prevent_wake && hdev->prevent_wake(hdev)))
33553357
ret = hci_change_suspend_state(hdev,
33563358
BT_SUSPEND_CONFIGURE_WAKE);
33573359
} else if (action == PM_POST_SUSPEND) {

0 commit comments

Comments
 (0)