Commit 359ee4f8 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi Committed by Luiz Augusto von Dentz

Bluetooth: Unregister suspend with userchannel

When HCI_USERCHANNEL is used, unregister the suspend notifier when
binding and register when releasing. The userchannel socket should be
left alone after open is completed.
Signed-off-by: default avatarAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 0acef50b
...@@ -1286,6 +1286,8 @@ void hci_free_dev(struct hci_dev *hdev); ...@@ -1286,6 +1286,8 @@ void hci_free_dev(struct hci_dev *hdev);
int hci_register_dev(struct hci_dev *hdev); int hci_register_dev(struct hci_dev *hdev);
void hci_unregister_dev(struct hci_dev *hdev); void hci_unregister_dev(struct hci_dev *hdev);
void hci_release_dev(struct hci_dev *hdev); void hci_release_dev(struct hci_dev *hdev);
int hci_register_suspend_notifier(struct hci_dev *hdev);
int hci_unregister_suspend_notifier(struct hci_dev *hdev);
int hci_suspend_dev(struct hci_dev *hdev); int hci_suspend_dev(struct hci_dev *hdev);
int hci_resume_dev(struct hci_dev *hdev); int hci_resume_dev(struct hci_dev *hdev);
int hci_reset_dev(struct hci_dev *hdev); int hci_reset_dev(struct hci_dev *hdev);
......
...@@ -2647,12 +2647,8 @@ int hci_register_dev(struct hci_dev *hdev) ...@@ -2647,12 +2647,8 @@ int hci_register_dev(struct hci_dev *hdev)
hci_sock_dev_event(hdev, HCI_DEV_REG); hci_sock_dev_event(hdev, HCI_DEV_REG);
hci_dev_hold(hdev); hci_dev_hold(hdev);
if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks)) { if (hci_register_suspend_notifier(hdev))
hdev->suspend_notifier.notifier_call = hci_suspend_notifier; goto err_wqueue;
error = register_pm_notifier(&hdev->suspend_notifier);
if (error)
goto err_wqueue;
}
queue_work(hdev->req_workqueue, &hdev->power_on); queue_work(hdev->req_workqueue, &hdev->power_on);
...@@ -2687,8 +2683,7 @@ void hci_unregister_dev(struct hci_dev *hdev) ...@@ -2687,8 +2683,7 @@ void hci_unregister_dev(struct hci_dev *hdev)
hci_cmd_sync_clear(hdev); hci_cmd_sync_clear(hdev);
if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks)) hci_unregister_suspend_notifier(hdev);
unregister_pm_notifier(&hdev->suspend_notifier);
msft_unregister(hdev); msft_unregister(hdev);
...@@ -2752,6 +2747,28 @@ void hci_release_dev(struct hci_dev *hdev) ...@@ -2752,6 +2747,28 @@ void hci_release_dev(struct hci_dev *hdev)
} }
EXPORT_SYMBOL(hci_release_dev); EXPORT_SYMBOL(hci_release_dev);
int hci_register_suspend_notifier(struct hci_dev *hdev)
{
int ret = 0;
if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks)) {
hdev->suspend_notifier.notifier_call = hci_suspend_notifier;
ret = register_pm_notifier(&hdev->suspend_notifier);
}
return ret;
}
int hci_unregister_suspend_notifier(struct hci_dev *hdev)
{
int ret = 0;
if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks))
ret = unregister_pm_notifier(&hdev->suspend_notifier);
return ret;
}
/* Suspend HCI device */ /* Suspend HCI device */
int hci_suspend_dev(struct hci_dev *hdev) int hci_suspend_dev(struct hci_dev *hdev)
{ {
......
...@@ -887,6 +887,7 @@ static int hci_sock_release(struct socket *sock) ...@@ -887,6 +887,7 @@ static int hci_sock_release(struct socket *sock)
*/ */
hci_dev_do_close(hdev); hci_dev_do_close(hdev);
hci_dev_clear_flag(hdev, HCI_USER_CHANNEL); hci_dev_clear_flag(hdev, HCI_USER_CHANNEL);
hci_register_suspend_notifier(hdev);
mgmt_index_added(hdev); mgmt_index_added(hdev);
} }
...@@ -1215,6 +1216,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, ...@@ -1215,6 +1216,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
} }
mgmt_index_removed(hdev); mgmt_index_removed(hdev);
hci_unregister_suspend_notifier(hdev);
err = hci_dev_open(hdev->id); err = hci_dev_open(hdev->id);
if (err) { if (err) {
...@@ -1229,6 +1231,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, ...@@ -1229,6 +1231,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr,
err = 0; err = 0;
} else { } else {
hci_dev_clear_flag(hdev, HCI_USER_CHANNEL); hci_dev_clear_flag(hdev, HCI_USER_CHANNEL);
hci_register_suspend_notifier(hdev);
mgmt_index_added(hdev); mgmt_index_added(hdev);
hci_dev_put(hdev); hci_dev_put(hdev);
goto done; goto done;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment