Bluetooth: hci_request: Remove bg_scan_update work
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 12 Nov 2021 00:48:44 +0000 (16:48 -0800)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 16 Nov 2021 14:13:34 +0000 (15:13 +0100)
This work is no longer necessary since all the code using it has been
converted to use hci_passive_scan/hci_passive_scan_sync.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_request.c
net/bluetooth/hci_request.h

index acb46ae..2560cfe 100644 (file)
@@ -493,7 +493,6 @@ struct hci_dev {
        struct work_struct      tx_work;
 
        struct work_struct      discov_update;
-       struct work_struct      bg_scan_update;
        struct work_struct      scan_update;
        struct delayed_work     le_scan_disable;
        struct delayed_work     le_scan_restart;
index 98bf425..8b3205e 100644 (file)
@@ -368,82 +368,6 @@ static bool __hci_update_interleaved_scan(struct hci_dev *hdev)
        return false;
 }
 
-/* This function controls the background scanning based on hdev->pend_le_conns
- * list. If there are pending LE connection we start the background scanning,
- * otherwise we stop it.
- *
- * This function requires the caller holds hdev->lock.
- */
-static void __hci_update_background_scan(struct hci_request *req)
-{
-       struct hci_dev *hdev = req->hdev;
-
-       if (!test_bit(HCI_UP, &hdev->flags) ||
-           test_bit(HCI_INIT, &hdev->flags) ||
-           hci_dev_test_flag(hdev, HCI_SETUP) ||
-           hci_dev_test_flag(hdev, HCI_CONFIG) ||
-           hci_dev_test_flag(hdev, HCI_AUTO_OFF) ||
-           hci_dev_test_flag(hdev, HCI_UNREGISTER))
-               return;
-
-       /* No point in doing scanning if LE support hasn't been enabled */
-       if (!hci_dev_test_flag(hdev, HCI_LE_ENABLED))
-               return;
-
-       /* If discovery is active don't interfere with it */
-       if (hdev->discovery.state != DISCOVERY_STOPPED)
-               return;
-
-       /* Reset RSSI and UUID filters when starting background scanning
-        * since these filters are meant for service discovery only.
-        *
-        * The Start Discovery and Start Service Discovery operations
-        * ensure to set proper values for RSSI threshold and UUID
-        * filter list. So it is safe to just reset them here.
-        */
-       hci_discovery_filter_clear(hdev);
-
-       bt_dev_dbg(hdev, "ADV monitoring is %s",
-                  hci_is_adv_monitoring(hdev) ? "on" : "off");
-
-       if (list_empty(&hdev->pend_le_conns) &&
-           list_empty(&hdev->pend_le_reports) &&
-           !hci_is_adv_monitoring(hdev)) {
-               /* If there is no pending LE connections or devices
-                * to be scanned for or no ADV monitors, we should stop the
-                * background scanning.
-                */
-
-               /* If controller is not scanning we are done. */
-               if (!hci_dev_test_flag(hdev, HCI_LE_SCAN))
-                       return;
-
-               hci_req_add_le_scan_disable(req, false);
-
-               bt_dev_dbg(hdev, "stopping background scanning");
-       } else {
-               /* If there is at least one pending LE connection, we should
-                * keep the background scan running.
-                */
-
-               /* If controller is connecting, we should not start scanning
-                * since some controllers are not able to scan and connect at
-                * the same time.
-                */
-               if (hci_lookup_le_connect(hdev))
-                       return;
-
-               /* If controller is currently scanning, we stop it to ensure we
-                * don't miss any advertising (due to duplicates filter).
-                */
-               if (hci_dev_test_flag(hdev, HCI_LE_SCAN))
-                       hci_req_add_le_scan_disable(req, false);
-
-               hci_req_add_le_passive_scan(req);
-               bt_dev_dbg(hdev, "starting background scanning");
-       }
-}
-
 void __hci_req_update_name(struct hci_request *req)
 {
        struct hci_dev *hdev = req->hdev;
@@ -2183,35 +2107,6 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason)
        return 0;
 }
 
-static int update_bg_scan(struct hci_request *req, unsigned long opt)
-{
-       hci_dev_lock(req->hdev);
-       __hci_update_background_scan(req);
-       hci_dev_unlock(req->hdev);
-       return 0;
-}
-
-static void bg_scan_update(struct work_struct *work)
-{
-       struct hci_dev *hdev = container_of(work, struct hci_dev,
-                                           bg_scan_update);
-       struct hci_conn *conn;
-       u8 status;
-       int err;
-
-       err = hci_req_sync(hdev, update_bg_scan, 0, HCI_CMD_TIMEOUT, &status);
-       if (!err)
-               return;
-
-       hci_dev_lock(hdev);
-
-       conn = hci_conn_hash_lookup_state(hdev, LE_LINK, BT_CONNECT);
-       if (conn)
-               hci_le_conn_failed(conn, status);
-
-       hci_dev_unlock(hdev);
-}
-
 static int le_scan_disable(struct hci_request *req, unsigned long opt)
 {
        hci_req_add_le_scan_disable(req, false);
@@ -2798,7 +2693,6 @@ int __hci_req_hci_power_on(struct hci_dev *hdev)
 void hci_request_setup(struct hci_dev *hdev)
 {
        INIT_WORK(&hdev->discov_update, discov_update);
-       INIT_WORK(&hdev->bg_scan_update, bg_scan_update);
        INIT_WORK(&hdev->scan_update, scan_update_work);
        INIT_DELAYED_WORK(&hdev->discov_off, discov_off);
        INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work);
@@ -2812,7 +2706,6 @@ void hci_request_cancel_all(struct hci_dev *hdev)
        hci_req_sync_cancel(hdev, ENODEV);
 
        cancel_work_sync(&hdev->discov_update);
-       cancel_work_sync(&hdev->bg_scan_update);
        cancel_work_sync(&hdev->scan_update);
        cancel_delayed_work_sync(&hdev->discov_off);
        cancel_delayed_work_sync(&hdev->le_scan_disable);
index ba75c2d..5f8e884 100644 (file)
@@ -127,10 +127,5 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason);
 void __hci_abort_conn(struct hci_request *req, struct hci_conn *conn,
                      u8 reason);
 
-static inline void hci_update_background_scan(struct hci_dev *hdev)
-{
-       queue_work(hdev->req_workqueue, &hdev->bg_scan_update);
-}
-
 void hci_request_setup(struct hci_dev *hdev);
 void hci_request_cancel_all(struct hci_dev *hdev);