aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-12-19 16:18:22 -0500
committerMarcel Holtmann <marcel@holtmann.org>2014-12-19 16:23:19 -0500
commit405a26110a735b88963875459efe63f4d274f49d (patch)
treeea459d404dd4e73a196c2ed4d0a20ddad6e2f03b /net/bluetooth
parent9df7465351c00707d7d63a52e01187a6e169fe4a (diff)
Bluetooth: Move hci_update_page_scan to hci_request.c
This is a left-over from the patch that created hci_request.c. The hci_update_page_scan functions should have been moved from hci_core.c there. 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/hci_core.c56
-rw-r--r--net/bluetooth/hci_request.c56
2 files changed, 56 insertions, 56 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index ee2096c7ec2c..9790a0108e69 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -5253,59 +5253,3 @@ static void hci_cmd_work(struct work_struct *work)
5253 } 5253 }
5254 } 5254 }
5255} 5255}
5256
5257static bool disconnected_whitelist_entries(struct hci_dev *hdev)
5258{
5259 struct bdaddr_list *b;
5260
5261 list_for_each_entry(b, &hdev->whitelist, list) {
5262 struct hci_conn *conn;
5263
5264 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &b->bdaddr);
5265 if (!conn)
5266 return true;
5267
5268 if (conn->state != BT_CONNECTED && conn->state != BT_CONFIG)
5269 return true;
5270 }
5271
5272 return false;
5273}
5274
5275void __hci_update_page_scan(struct hci_request *req)
5276{
5277 struct hci_dev *hdev = req->hdev;
5278 u8 scan;
5279
5280 if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
5281 return;
5282
5283 if (!hdev_is_powered(hdev))
5284 return;
5285
5286 if (mgmt_powering_down(hdev))
5287 return;
5288
5289 if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags) ||
5290 disconnected_whitelist_entries(hdev))
5291 scan = SCAN_PAGE;
5292 else
5293 scan = SCAN_DISABLED;
5294
5295 if (test_bit(HCI_PSCAN, &hdev->flags) == !!(scan & SCAN_PAGE))
5296 return;
5297
5298 if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags))
5299 scan |= SCAN_INQUIRY;
5300
5301 hci_req_add(req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
5302}
5303
5304void hci_update_page_scan(struct hci_dev *hdev)
5305{
5306 struct hci_request req;
5307
5308 hci_req_init(&req, hdev);
5309 __hci_update_page_scan(&req);
5310 hci_req_run(&req, NULL);
5311}
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index e49f682f1550..5e64ea70a106 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -396,6 +396,62 @@ int hci_update_random_address(struct hci_request *req, bool require_privacy,
396 return 0; 396 return 0;
397} 397}
398 398
399static bool disconnected_whitelist_entries(struct hci_dev *hdev)
400{
401 struct bdaddr_list *b;
402
403 list_for_each_entry(b, &hdev->whitelist, list) {
404 struct hci_conn *conn;
405
406 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &b->bdaddr);
407 if (!conn)
408 return true;
409
410 if (conn->state != BT_CONNECTED && conn->state != BT_CONFIG)
411 return true;
412 }
413
414 return false;
415}
416
417void __hci_update_page_scan(struct hci_request *req)
418{
419 struct hci_dev *hdev = req->hdev;
420 u8 scan;
421
422 if (!test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags))
423 return;
424
425 if (!hdev_is_powered(hdev))
426 return;
427
428 if (mgmt_powering_down(hdev))
429 return;
430
431 if (test_bit(HCI_CONNECTABLE, &hdev->dev_flags) ||
432 disconnected_whitelist_entries(hdev))
433 scan = SCAN_PAGE;
434 else
435 scan = SCAN_DISABLED;
436
437 if (test_bit(HCI_PSCAN, &hdev->flags) == !!(scan & SCAN_PAGE))
438 return;
439
440 if (test_bit(HCI_DISCOVERABLE, &hdev->dev_flags))
441 scan |= SCAN_INQUIRY;
442
443 hci_req_add(req, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
444}
445
446void hci_update_page_scan(struct hci_dev *hdev)
447{
448 struct hci_request req;
449
450 hci_req_init(&req, hdev);
451 __hci_update_page_scan(&req);
452 hci_req_run(&req, NULL);
453}
454
399/* This function controls the background scanning based on hdev->pend_le_conns 455/* This function controls the background scanning based on hdev->pend_le_conns
400 * list. If there are pending LE connection we start the background scanning, 456 * list. If there are pending LE connection we start the background scanning,
401 * otherwise we stop it. 457 * otherwise we stop it.