Skip to content

Commit 2e2515c

Browse files
committed
Bluetooth: hci_event: Set DISCOVERY_FINDING on SCAN_ENABLED
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 <[email protected]>
1 parent 7c2cc5b commit 2e2515c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

net/bluetooth/hci_core.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
149149
{
150150
int old_state = hdev->discovery.state;
151151

152-
BT_DBG("%s state %u -> %u", hdev->name, hdev->discovery.state, state);
153-
154152
if (old_state == state)
155153
return;
156154

@@ -166,13 +164,22 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
166164
case DISCOVERY_STARTING:
167165
break;
168166
case DISCOVERY_FINDING:
167+
/* If discovery was not started then it was initiated by the
168+
* MGMT interface so no MGMT event shall be generated either
169+
*/
170+
if (old_state != DISCOVERY_STARTING) {
171+
hdev->discovery.state = old_state;
172+
return;
173+
}
169174
mgmt_discovering(hdev, 1);
170175
break;
171176
case DISCOVERY_RESOLVING:
172177
break;
173178
case DISCOVERY_STOPPING:
174179
break;
175180
}
181+
182+
bt_dev_dbg(hdev, "state %u -> %u", old_state, state);
176183
}
177184

178185
void hci_inquiry_cache_flush(struct hci_dev *hdev)

net/bluetooth/hci_event.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,8 +1779,7 @@ static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable)
17791779
hci_dev_set_flag(hdev, HCI_LE_SCAN);
17801780
if (hdev->le_scan_type == LE_SCAN_ACTIVE)
17811781
clear_pending_adv_report(hdev);
1782-
if (hci_dev_test_flag(hdev, HCI_MESH))
1783-
hci_discovery_set_state(hdev, DISCOVERY_FINDING);
1782+
hci_discovery_set_state(hdev, DISCOVERY_FINDING);
17841783
break;
17851784

17861785
case LE_SCAN_DISABLE:

0 commit comments

Comments
 (0)