Commit 343f935b authored by Andre Guedes's avatar Andre Guedes Committed by Johan Hedberg

Bluetooth: Merge INQUIRY and LE_SCAN discovery states

This patch merges DISCOVERY_INQUIRY and DISCOVERY_LE_SCAN states
into a new state called DISCOVERY_FINDING.

From the discovery perspective, we are pretty much worried about
to know just if we are finding devices than what exactly phase of
"finding devices" (inquiry or LE scan) we are currently running.
Besides, to know if the controller is performing inquiry or LE scan
we should check HCI_INQUIRY or HCI_LE_SCAN bits in hdev flags.

Moreover, merging this two states will simplify the discovery state
machine and will keep interleaved discovery implementation simpler.
Signed-off-by: default avatarAndre Guedes <andre.guedes@openbossa.org>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 4aab14e5
...@@ -61,8 +61,7 @@ struct discovery_state { ...@@ -61,8 +61,7 @@ struct discovery_state {
enum { enum {
DISCOVERY_STOPPED, DISCOVERY_STOPPED,
DISCOVERY_STARTING, DISCOVERY_STARTING,
DISCOVERY_INQUIRY, DISCOVERY_FINDING,
DISCOVERY_LE_SCAN,
DISCOVERY_RESOLVING, DISCOVERY_RESOLVING,
DISCOVERY_STOPPING, DISCOVERY_STOPPING,
} state; } state;
......
...@@ -361,8 +361,7 @@ bool hci_discovery_active(struct hci_dev *hdev) ...@@ -361,8 +361,7 @@ bool hci_discovery_active(struct hci_dev *hdev)
struct discovery_state *discov = &hdev->discovery; struct discovery_state *discov = &hdev->discovery;
switch (discov->state) { switch (discov->state) {
case DISCOVERY_INQUIRY: case DISCOVERY_FINDING:
case DISCOVERY_LE_SCAN:
case DISCOVERY_RESOLVING: case DISCOVERY_RESOLVING:
return true; return true;
...@@ -387,8 +386,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) ...@@ -387,8 +386,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
break; break;
case DISCOVERY_STARTING: case DISCOVERY_STARTING:
break; break;
case DISCOVERY_INQUIRY: case DISCOVERY_FINDING:
case DISCOVERY_LE_SCAN:
mgmt_discovering(hdev, 1); mgmt_discovering(hdev, 1);
break; break;
case DISCOVERY_RESOLVING: case DISCOVERY_RESOLVING:
......
...@@ -1080,7 +1080,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, ...@@ -1080,7 +1080,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
hci_dev_lock(hdev); hci_dev_lock(hdev);
hci_adv_entries_clear(hdev); hci_adv_entries_clear(hdev);
hci_discovery_set_state(hdev, DISCOVERY_LE_SCAN); hci_discovery_set_state(hdev, DISCOVERY_FINDING);
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
break; break;
...@@ -1159,7 +1159,7 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) ...@@ -1159,7 +1159,7 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
set_bit(HCI_INQUIRY, &hdev->flags); set_bit(HCI_INQUIRY, &hdev->flags);
hci_dev_lock(hdev); hci_dev_lock(hdev);
hci_discovery_set_state(hdev, DISCOVERY_INQUIRY); hci_discovery_set_state(hdev, DISCOVERY_FINDING);
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
} }
...@@ -1645,7 +1645,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff ...@@ -1645,7 +1645,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (discov->state != DISCOVERY_INQUIRY) if (discov->state != DISCOVERY_FINDING)
goto unlock; goto unlock;
if (list_empty(&discov->resolve)) { if (list_empty(&discov->resolve)) {
......
...@@ -2250,7 +2250,7 @@ static int stop_discovery(struct sock *sk, u16 index) ...@@ -2250,7 +2250,7 @@ static int stop_discovery(struct sock *sk, u16 index)
goto unlock; goto unlock;
} }
if (hdev->discovery.state == DISCOVERY_INQUIRY) { if (hdev->discovery.state == DISCOVERY_FINDING) {
err = hci_cancel_inquiry(hdev); err = hci_cancel_inquiry(hdev);
if (err < 0) if (err < 0)
mgmt_pending_remove(cmd); mgmt_pending_remove(cmd);
......
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