summaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-11-22 11:55:44 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-12-09 18:51:47 -0500
commit196a5e97d13092f783e41001c1112d7f31518ea2 (patch)
tree5a2ce1ae8e33a414df2ff8980cad4b435153418a /net/bluetooth
parent01b1cb87d37fb19cdaa5e7002416fdde156873d0 (diff)
Bluetooth: Move __hci_update_background_scan up in hci_request.c
This way we avoid the need to do a forward declaration in later patches. 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_request.c146
1 files changed, 73 insertions, 73 deletions
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 78c026b4ffa1..7c85435b8982 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -346,6 +346,79 @@ void hci_req_add(struct hci_request *req, u16 opcode, u32 plen,
346 hci_req_add_ev(req, opcode, plen, param, 0); 346 hci_req_add_ev(req, opcode, plen, param, 0);
347} 347}
348 348
349/* This function controls the background scanning based on hdev->pend_le_conns
350 * list. If there are pending LE connection we start the background scanning,
351 * otherwise we stop it.
352 *
353 * This function requires the caller holds hdev->lock.
354 */
355static void __hci_update_background_scan(struct hci_request *req)
356{
357 struct hci_dev *hdev = req->hdev;
358
359 if (!test_bit(HCI_UP, &hdev->flags) ||
360 test_bit(HCI_INIT, &hdev->flags) ||
361 hci_dev_test_flag(hdev, HCI_SETUP) ||
362 hci_dev_test_flag(hdev, HCI_CONFIG) ||
363 hci_dev_test_flag(hdev, HCI_AUTO_OFF) ||
364 hci_dev_test_flag(hdev, HCI_UNREGISTER))
365 return;
366
367 /* No point in doing scanning if LE support hasn't been enabled */
368 if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED))
369 return;
370
371 /* If discovery is active don't interfere with it */
372 if (hdev->discovery.state != DISCOVERY_STOPPED)
373 return;
374
375 /* Reset RSSI and UUID filters when starting background scanning
376 * since these filters are meant for service discovery only.
377 *
378 * The Start Discovery and Start Service Discovery operations
379 * ensure to set proper values for RSSI threshold and UUID
380 * filter list. So it is safe to just reset them here.
381 */
382 hci_discovery_filter_clear(hdev);
383
384 if (list_empty(&hdev->pend_le_conns) &&
385 list_empty(&hdev->pend_le_reports)) {
386 /* If there is no pending LE connections or devices
387 * to be scanned for, we should stop the background
388 * scanning.
389 */
390
391 /* If controller is not scanning we are done. */
392 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN))
393 return;
394
395 hci_req_add_le_scan_disable(req);
396
397 BT_DBG("%s stopping background scanning", hdev->name);
398 } else {
399 /* If there is at least one pending LE connection, we should
400 * keep the background scan running.
401 */
402
403 /* If controller is connecting, we should not start scanning
404 * since some controllers are not able to scan and connect at
405 * the same time.
406 */
407 if (hci_lookup_le_connect(hdev))
408 return;
409
410 /* If controller is currently scanning, we stop it to ensure we
411 * don't miss any advertising (due to duplicates filter).
412 */
413 if (hci_dev_test_flag(hdev, HCI_LE_SCAN))
414 hci_req_add_le_scan_disable(req);
415
416 hci_req_add_le_passive_scan(req);
417
418 BT_DBG("%s starting background scanning", hdev->name);
419 }
420}
421
349void hci_req_add_le_scan_disable(struct hci_request *req) 422void hci_req_add_le_scan_disable(struct hci_request *req)
350{ 423{
351 struct hci_cp_le_set_scan_enable cp; 424 struct hci_cp_le_set_scan_enable cp;
@@ -682,79 +755,6 @@ static void scan_update_work(struct work_struct *work)
682 hci_req_sync(hdev, update_scan, 0, HCI_CMD_TIMEOUT, NULL); 755 hci_req_sync(hdev, update_scan, 0, HCI_CMD_TIMEOUT, NULL);
683} 756}
684 757
685/* This function controls the background scanning based on hdev->pend_le_conns
686 * list. If there are pending LE connection we start the background scanning,
687 * otherwise we stop it.
688 *
689 * This function requires the caller holds hdev->lock.
690 */
691static void __hci_update_background_scan(struct hci_request *req)
692{
693 struct hci_dev *hdev = req->hdev;
694
695 if (!test_bit(HCI_UP, &hdev->flags) ||
696 test_bit(HCI_INIT, &hdev->flags) ||
697 hci_dev_test_flag(hdev, HCI_SETUP) ||
698 hci_dev_test_flag(hdev, HCI_CONFIG) ||
699 hci_dev_test_flag(hdev, HCI_AUTO_OFF) ||
700 hci_dev_test_flag(hdev, HCI_UNREGISTER))
701 return;
702
703 /* No point in doing scanning if LE support hasn't been enabled */
704 if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED))
705 return;
706
707 /* If discovery is active don't interfere with it */
708 if (hdev->discovery.state != DISCOVERY_STOPPED)
709 return;
710
711 /* Reset RSSI and UUID filters when starting background scanning
712 * since these filters are meant for service discovery only.
713 *
714 * The Start Discovery and Start Service Discovery operations
715 * ensure to set proper values for RSSI threshold and UUID
716 * filter list. So it is safe to just reset them here.
717 */
718 hci_discovery_filter_clear(hdev);
719
720 if (list_empty(&hdev->pend_le_conns) &&
721 list_empty(&hdev->pend_le_reports)) {
722 /* If there is no pending LE connections or devices
723 * to be scanned for, we should stop the background
724 * scanning.
725 */
726
727 /* If controller is not scanning we are done. */
728 if (!hci_dev_test_flag(hdev, HCI_LE_SCAN))
729 return;
730
731 hci_req_add_le_scan_disable(req);
732
733 BT_DBG("%s stopping background scanning", hdev->name);
734 } else {
735 /* If there is at least one pending LE connection, we should
736 * keep the background scan running.
737 */
738
739 /* If controller is connecting, we should not start scanning
740 * since some controllers are not able to scan and connect at
741 * the same time.
742 */
743 if (hci_lookup_le_connect(hdev))
744 return;
745
746 /* If controller is currently scanning, we stop it to ensure we
747 * don't miss any advertising (due to duplicates filter).
748 */
749 if (hci_dev_test_flag(hdev, HCI_LE_SCAN))
750 hci_req_add_le_scan_disable(req);
751
752 hci_req_add_le_passive_scan(req);
753
754 BT_DBG("%s starting background scanning", hdev->name);
755 }
756}
757
758void __hci_abort_conn(struct hci_request *req, struct hci_conn *conn, 758void __hci_abort_conn(struct hci_request *req, struct hci_conn *conn,
759 u8 reason) 759 u8 reason)
760{ 760{