Commit bb3e0a33 authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

Bluetooth: Update discovery state earlier in hci_discovery_set_state

In a subsequent patch the hci_update_background_scan() function will
depend on being able to know the current discovery state. For this to be
possible we need to set the new state early in the function. Since we
also need to check what the old state was this patch introduces an extra
variable for tracking it.
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 7e899c94
...@@ -1903,16 +1903,20 @@ bool hci_discovery_active(struct hci_dev *hdev) ...@@ -1903,16 +1903,20 @@ bool hci_discovery_active(struct hci_dev *hdev)
void hci_discovery_set_state(struct hci_dev *hdev, int state) 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); BT_DBG("%s state %u -> %u", hdev->name, hdev->discovery.state, state);
if (hdev->discovery.state == state) if (old_state == state)
return; return;
hdev->discovery.state = state;
switch (state) { switch (state) {
case DISCOVERY_STOPPED: case DISCOVERY_STOPPED:
hci_update_background_scan(hdev); hci_update_background_scan(hdev);
if (hdev->discovery.state != DISCOVERY_STARTING) if (old_state != DISCOVERY_STARTING)
mgmt_discovering(hdev, 0); mgmt_discovering(hdev, 0);
break; break;
case DISCOVERY_STARTING: case DISCOVERY_STARTING:
...@@ -1925,8 +1929,6 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) ...@@ -1925,8 +1929,6 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
case DISCOVERY_STOPPING: case DISCOVERY_STOPPING:
break; break;
} }
hdev->discovery.state = state;
} }
void hci_inquiry_cache_flush(struct hci_dev *hdev) void hci_inquiry_cache_flush(struct hci_dev *hdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment