diff options
author | Andre Guedes <andre.guedes@openbossa.org> | 2012-02-17 18:39:37 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-19 05:34:09 -0500 |
commit | 343f935bfa44189c68527102c409286b0cfc4526 (patch) | |
tree | 7597224c044e879c31bda46e32dd5a3f256ffd1b | |
parent | 4aab14e5504e84c42534378f91e836e6f55d0886 (diff) |
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: Andre Guedes <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 3 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 6 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 6 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 2 |
4 files changed, 7 insertions, 10 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index d7c79b5335c2..942de7764278 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -61,8 +61,7 @@ struct discovery_state { | |||
61 | enum { | 61 | enum { |
62 | DISCOVERY_STOPPED, | 62 | DISCOVERY_STOPPED, |
63 | DISCOVERY_STARTING, | 63 | DISCOVERY_STARTING, |
64 | DISCOVERY_INQUIRY, | 64 | DISCOVERY_FINDING, |
65 | DISCOVERY_LE_SCAN, | ||
66 | DISCOVERY_RESOLVING, | 65 | DISCOVERY_RESOLVING, |
67 | DISCOVERY_STOPPING, | 66 | DISCOVERY_STOPPING, |
68 | } state; | 67 | } state; |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 29a9b01c3b9b..fabca080ae70 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -361,8 +361,7 @@ bool hci_discovery_active(struct hci_dev *hdev) | |||
361 | struct discovery_state *discov = &hdev->discovery; | 361 | struct discovery_state *discov = &hdev->discovery; |
362 | 362 | ||
363 | switch (discov->state) { | 363 | switch (discov->state) { |
364 | case DISCOVERY_INQUIRY: | 364 | case DISCOVERY_FINDING: |
365 | case DISCOVERY_LE_SCAN: | ||
366 | case DISCOVERY_RESOLVING: | 365 | case DISCOVERY_RESOLVING: |
367 | return true; | 366 | return true; |
368 | 367 | ||
@@ -387,8 +386,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) | |||
387 | break; | 386 | break; |
388 | case DISCOVERY_STARTING: | 387 | case DISCOVERY_STARTING: |
389 | break; | 388 | break; |
390 | case DISCOVERY_INQUIRY: | 389 | case DISCOVERY_FINDING: |
391 | case DISCOVERY_LE_SCAN: | ||
392 | mgmt_discovering(hdev, 1); | 390 | mgmt_discovering(hdev, 1); |
393 | break; | 391 | break; |
394 | case DISCOVERY_RESOLVING: | 392 | case DISCOVERY_RESOLVING: |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 179d127601fc..9aea7b898821 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1080,7 +1080,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, | |||
1080 | 1080 | ||
1081 | hci_dev_lock(hdev); | 1081 | hci_dev_lock(hdev); |
1082 | hci_adv_entries_clear(hdev); | 1082 | hci_adv_entries_clear(hdev); |
1083 | hci_discovery_set_state(hdev, DISCOVERY_LE_SCAN); | 1083 | hci_discovery_set_state(hdev, DISCOVERY_FINDING); |
1084 | hci_dev_unlock(hdev); | 1084 | hci_dev_unlock(hdev); |
1085 | break; | 1085 | break; |
1086 | 1086 | ||
@@ -1159,7 +1159,7 @@ static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) | |||
1159 | set_bit(HCI_INQUIRY, &hdev->flags); | 1159 | set_bit(HCI_INQUIRY, &hdev->flags); |
1160 | 1160 | ||
1161 | hci_dev_lock(hdev); | 1161 | hci_dev_lock(hdev); |
1162 | hci_discovery_set_state(hdev, DISCOVERY_INQUIRY); | 1162 | hci_discovery_set_state(hdev, DISCOVERY_FINDING); |
1163 | hci_dev_unlock(hdev); | 1163 | hci_dev_unlock(hdev); |
1164 | } | 1164 | } |
1165 | 1165 | ||
@@ -1645,7 +1645,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff | |||
1645 | 1645 | ||
1646 | hci_dev_lock(hdev); | 1646 | hci_dev_lock(hdev); |
1647 | 1647 | ||
1648 | if (discov->state != DISCOVERY_INQUIRY) | 1648 | if (discov->state != DISCOVERY_FINDING) |
1649 | goto unlock; | 1649 | goto unlock; |
1650 | 1650 | ||
1651 | if (list_empty(&discov->resolve)) { | 1651 | if (list_empty(&discov->resolve)) { |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 9d98382e48c7..a9cd38dc2cab 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -2250,7 +2250,7 @@ static int stop_discovery(struct sock *sk, u16 index) | |||
2250 | goto unlock; | 2250 | goto unlock; |
2251 | } | 2251 | } |
2252 | 2252 | ||
2253 | if (hdev->discovery.state == DISCOVERY_INQUIRY) { | 2253 | if (hdev->discovery.state == DISCOVERY_FINDING) { |
2254 | err = hci_cancel_inquiry(hdev); | 2254 | err = hci_cancel_inquiry(hdev); |
2255 | if (err < 0) | 2255 | if (err < 0) |
2256 | mgmt_pending_remove(cmd); | 2256 | mgmt_pending_remove(cmd); |