]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Bluetooth: hci_event: Set DISCOVERY_FINDING on SCAN_ENABLED
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 28 Mar 2024 21:40:53 +0000 (17:40 -0400)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 14 May 2024 14:51:04 +0000 (10:51 -0400)
This makes sure that discovery state is properly synchronized otherwise
reports may not generate MGMT DeviceFound events as it would be assumed
that it was not initiated by a discovery session.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_core.c
net/bluetooth/hci_event.c

index d35015219c2631f20f477275a5d816732f7bf35e..34cd058564018f58cbbcf22a4541851c63d8c971 100644 (file)
@@ -149,8 +149,6 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
 {
        int old_state = hdev->discovery.state;
 
-       BT_DBG("%s state %u -> %u", hdev->name, hdev->discovery.state, state);
-
        if (old_state == state)
                return;
 
@@ -166,6 +164,13 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
        case DISCOVERY_STARTING:
                break;
        case DISCOVERY_FINDING:
+               /* If discovery was not started then it was initiated by the
+                * MGMT interface so no MGMT event shall be generated either
+                */
+               if (old_state != DISCOVERY_STARTING) {
+                       hdev->discovery.state = old_state;
+                       return;
+               }
                mgmt_discovering(hdev, 1);
                break;
        case DISCOVERY_RESOLVING:
@@ -173,6 +178,8 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
        case DISCOVERY_STOPPING:
                break;
        }
+
+       bt_dev_dbg(hdev, "state %u -> %u", old_state, state);
 }
 
 void hci_inquiry_cache_flush(struct hci_dev *hdev)
index d72d238c1656ed442aa89c3026dbafb9ac1cdf6b..71fedb2d4b48c777d00dd0fb73e0b871c99d13c3 100644 (file)
@@ -1779,8 +1779,7 @@ static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable)
                hci_dev_set_flag(hdev, HCI_LE_SCAN);
                if (hdev->le_scan_type == LE_SCAN_ACTIVE)
                        clear_pending_adv_report(hdev);
-               if (hci_dev_test_flag(hdev, HCI_MESH))
-                       hci_discovery_set_state(hdev, DISCOVERY_FINDING);
+               hci_discovery_set_state(hdev, DISCOVERY_FINDING);
                break;
 
        case LE_SCAN_DISABLE: