aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-03-10 14:14:27 -0400
committerMarcel Holtmann <marcel@holtmann.org>2015-03-10 14:37:02 -0400
commit406ef2a67bd0bb13d77d5e5d700e36a2caea09ae (patch)
tree1c07b55741dcef767b510d6be85c5d778da42c8a /net/bluetooth
parent0402d9f233ac5d66b39452037fef88333b06d51c (diff)
Bluetooth: Make Fast Connectable available while powered off
To maximize the usability of the Fast Connectable feature we should make it possible to set (or unset) it at any given moment. This means removing the dependency on the 'connectable' setting as well as the 'powered' setting. The former makes also sense since page scan may get enabled through add_device even if 'connectable' is false. To keep the setting available over power cycles its flag also needs to be removed from the flags that are cleared upon HCI_Reset. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/mgmt.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index d769b428b630..49b8e09ffe67 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1968,15 +1968,6 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
1968 } 1968 }
1969 1969
1970no_scan_update: 1970no_scan_update:
1971 /* If we're going from non-connectable to connectable or
1972 * vice-versa when fast connectable is enabled ensure that fast
1973 * connectable gets disabled. write_fast_connectable won't do
1974 * anything if the page scan parameters are already what they
1975 * should be.
1976 */
1977 if (cp->val || test_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags))
1978 write_fast_connectable(&req, false);
1979
1980 /* Update the advertising parameters if necessary */ 1971 /* Update the advertising parameters if necessary */
1981 if (test_bit(HCI_ADVERTISING, &hdev->dev_flags)) 1972 if (test_bit(HCI_ADVERTISING, &hdev->dev_flags))
1982 enable_advertising(&req); 1973 enable_advertising(&req);
@@ -4660,14 +4651,6 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
4660 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE, 4651 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
4661 MGMT_STATUS_INVALID_PARAMS); 4652 MGMT_STATUS_INVALID_PARAMS);
4662 4653
4663 if (!hdev_is_powered(hdev))
4664 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
4665 MGMT_STATUS_NOT_POWERED);
4666
4667 if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
4668 return mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_FAST_CONNECTABLE,
4669 MGMT_STATUS_REJECTED);
4670
4671 hci_dev_lock(hdev); 4654 hci_dev_lock(hdev);
4672 4655
4673 if (mgmt_pending_find(MGMT_OP_SET_FAST_CONNECTABLE, hdev)) { 4656 if (mgmt_pending_find(MGMT_OP_SET_FAST_CONNECTABLE, hdev)) {
@@ -4682,6 +4665,14 @@ static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
4682 goto unlock; 4665 goto unlock;
4683 } 4666 }
4684 4667
4668 if (!hdev_is_powered(hdev)) {
4669 change_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags);
4670 err = send_settings_rsp(sk, MGMT_OP_SET_FAST_CONNECTABLE,
4671 hdev);
4672 new_settings(hdev, sk);
4673 goto unlock;
4674 }
4675
4685 cmd = mgmt_pending_add(sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev, 4676 cmd = mgmt_pending_add(sk, MGMT_OP_SET_FAST_CONNECTABLE, hdev,
4686 data, len); 4677 data, len);
4687 if (!cmd) { 4678 if (!cmd) {
@@ -6481,7 +6472,10 @@ static int powered_update_hci(struct hci_dev *hdev)
6481 sizeof(link_sec), &link_sec); 6472 sizeof(link_sec), &link_sec);
6482 6473
6483 if (lmp_bredr_capable(hdev)) { 6474 if (lmp_bredr_capable(hdev)) {
6484 write_fast_connectable(&req, false); 6475 if (test_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags))
6476 write_fast_connectable(&req, true);
6477 else
6478 write_fast_connectable(&req, false);
6485 __hci_update_page_scan(&req); 6479 __hci_update_page_scan(&req);
6486 update_class(&req); 6480 update_class(&req);
6487 update_name(&req); 6481 update_name(&req);