Commit f0d4b78a authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg

Bluetooth: Only keep controller up after init if powered on

When a new controller gets added to the system, it needs to be brought
up briefly to read basic information like features, BD_ADDR etc. and
after a timeout it will be brought back down.

The only command that should overwrite this timeout is the set power
command from the management interface. Just reading the controller
list or information is not a good reason to keep the controller up.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent c059e053
...@@ -339,9 +339,6 @@ static int read_index_list(struct sock *sk) ...@@ -339,9 +339,6 @@ static int read_index_list(struct sock *sk)
i = 0; i = 0;
list_for_each_entry(d, &hci_dev_list, list) { list_for_each_entry(d, &hci_dev_list, list) {
if (test_and_clear_bit(HCI_AUTO_OFF, &d->dev_flags))
cancel_delayed_work(&d->power_off);
if (test_bit(HCI_SETUP, &d->dev_flags)) if (test_bit(HCI_SETUP, &d->dev_flags))
continue; continue;
...@@ -392,11 +389,12 @@ static u32 get_current_settings(struct hci_dev *hdev) ...@@ -392,11 +389,12 @@ static u32 get_current_settings(struct hci_dev *hdev)
{ {
u32 settings = 0; u32 settings = 0;
if (test_bit(HCI_UP, &hdev->flags)) if (!test_bit(HCI_UP, &hdev->flags))
settings |= MGMT_SETTING_POWERED;
else
return settings; return settings;
if (!test_bit(HCI_AUTO_OFF, &hdev->dev_flags))
settings |= MGMT_SETTING_POWERED;
if (test_bit(HCI_PSCAN, &hdev->flags)) if (test_bit(HCI_PSCAN, &hdev->flags))
settings |= MGMT_SETTING_CONNECTABLE; settings |= MGMT_SETTING_CONNECTABLE;
...@@ -623,9 +621,6 @@ static int read_controller_info(struct sock *sk, u16 index) ...@@ -623,9 +621,6 @@ static int read_controller_info(struct sock *sk, u16 index)
return cmd_status(sk, index, MGMT_OP_READ_INFO, return cmd_status(sk, index, MGMT_OP_READ_INFO,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags))
cancel_delayed_work_sync(&hdev->power_off);
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (test_and_clear_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags)) 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,6 +748,16 @@ static int set_powered(struct sock *sk, u16 index, void *data, u16 len)
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) {
cancel_delayed_work(&hdev->power_off);
if (cp->val) {
err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev);
mgmt_powered(hdev, 1);
goto failed;
}
}
up = test_bit(HCI_UP, &hdev->flags); up = test_bit(HCI_UP, &hdev->flags);
if ((cp->val && up) || (!cp->val && !up)) { if ((cp->val && up) || (!cp->val && !up)) {
err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev); err = send_settings_rsp(sk, MGMT_OP_SET_POWERED, hdev);
......
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