aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-03-15 18:07:14 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-03-18 14:36:04 -0400
commit4c01f8b845238710ff4b6c7fa8148ca52613f199 (patch)
tree276708c633d9b2b3b75cd5bf3e4bbdf708f8412e
parentbd98b9966f915411a32ecee3fa434cb051167d8a (diff)
Bluetooth: Fix fast connectable state when enabling page scan
When powering on or enabling page scan we need to ensure that the page scan parameters are as they should be. This is because some controllers do not properly reset these values upon HCI_Reset. Since the write_scan_parameters function is now called from several new places it also checks for the >= 1.2 HCI version requirement before sending the commands. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
-rw-r--r--net/bluetooth/mgmt.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 7783b8d8e1d4..75c9d9269d77 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1006,6 +1006,9 @@ static void write_fast_connectable(struct hci_request *req, bool enable)
1006 struct hci_cp_write_page_scan_activity acp; 1006 struct hci_cp_write_page_scan_activity acp;
1007 u8 type; 1007 u8 type;
1008 1008
1009 if (hdev->hci_ver < BLUETOOTH_VER_1_2)
1010 return;
1011
1009 if (enable) { 1012 if (enable) {
1010 type = PAGE_SCAN_TYPE_INTERLACED; 1013 type = PAGE_SCAN_TYPE_INTERLACED;
1011 1014
@@ -1125,7 +1128,13 @@ static int set_connectable(struct sock *sk, struct hci_dev *hdev, void *data,
1125 1128
1126 hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); 1129 hci_req_add(&req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
1127 1130
1128 if (!cp->val && test_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags)) 1131 /* If we're going from non-connectable to connectable or
1132 * vice-versa when fast connectable is enabled ensure that fast
1133 * connectable gets disabled. write_fast_connectable won't do
1134 * anything if the page scan parameters are already what they
1135 * should be.
1136 */
1137 if (cp->val || test_bit(HCI_FAST_CONNECTABLE, &hdev->dev_flags))
1129 write_fast_connectable(&req, false); 1138 write_fast_connectable(&req, false);
1130 1139
1131 err = hci_req_run(&req, set_connectable_complete); 1140 err = hci_req_run(&req, set_connectable_complete);
@@ -3287,6 +3296,12 @@ static void set_bredr_scan(struct hci_request *req)
3287 struct hci_dev *hdev = req->hdev; 3296 struct hci_dev *hdev = req->hdev;
3288 u8 scan = 0; 3297 u8 scan = 0;
3289 3298
3299 /* Ensure that fast connectable is disabled. This function will
3300 * not do anything if the page scan parameters are already what
3301 * they should be.
3302 */
3303 write_fast_connectable(req, false);
3304
3290 if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags)) 3305 if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
3291 scan |= SCAN_PAGE; 3306 scan |= SCAN_PAGE;
3292 if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags)) 3307 if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags))