aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a5a2a6844aea..c25cb648059e 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -339,9 +339,6 @@ static int read_index_list(struct sock *sk)
339 339
340 i = 0; 340 i = 0;
341 list_for_each_entry(d, &hci_dev_list, list) { 341 list_for_each_entry(d, &hci_dev_list, list) {
342 if (test_and_clear_bit(HCI_AUTO_OFF, &d->dev_flags))
343 cancel_delayed_work(&d->power_off);
344
345 if (test_bit(HCI_SETUP, &d->dev_flags)) 342 if (test_bit(HCI_SETUP, &d->dev_flags))
346 continue; 343 continue;
347 344
@@ -392,11 +389,12 @@ static u32 get_current_settings(struct hci_dev *hdev)
392{ 389{
393 u32 settings = 0; 390 u32 settings = 0;
394 391
395 if (test_bit(HCI_UP, &hdev->flags)) 392 if (!test_bit(HCI_UP, &hdev->flags))
396 settings |= MGMT_SETTING_POWERED;
397 else
398 return settings; 393 return settings;
399 394
395 if (!test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
396 settings |= MGMT_SETTING_POWERED;
397
400 if (test_bit(HCI_PSCAN, &hdev->flags)) 398 if (test_bit(HCI_PSCAN, &hdev->flags))
401 settings |= MGMT_SETTING_CONNECTABLE; 399 settings |= MGMT_SETTING_CONNECTABLE;
402 400
@@ -623,9 +621,6 @@ static int read_controller_info(struct sock *sk, u16 index)
623 return cmd_status(sk, index, MGMT_OP_READ_INFO, 621 return cmd_status(sk, index, MGMT_OP_READ_INFO,
624 MGMT_STATUS_INVALID_PARAMS); 622 MGMT_STATUS_INVALID_PARAMS);
625 623
626 if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags))
627 cancel_delayed_work_sync(&hdev->power_off);
628
629 hci_dev_lock(hdev); 624 hci_dev_lock(hdev);
630 625
631 if (test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) 626 if (test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags))
@@ -753,6 +748,16 @@ static int set_powered(struct sock *sk, u16 index, void *data, u16 len)
753 748
754 hci_dev_lock(hdev); 749 hci_dev_lock(hdev);
755 750
751 if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) {
752 cancel_delayed_work(&hdev->power_off);
753
754 if (cp->val) {
755 err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev);
756 mgmt_powered(hdev, 1);
757 goto failed;
758 }
759 }
760
756 up = test_bit(HCI_UP, &hdev->flags); 761 up = test_bit(HCI_UP, &hdev->flags);
757 if ((cp->val && up) || (!cp->val && !up)) { 762 if ((cp->val && up) || (!cp->val && !up)) {
758 err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev); 763 err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev);