2012-01-13 21:03:49

by Andre Guedes

[permalink] [raw]
Subject: [PATCH 0/3] MGMT Stop Discovery command LE-Only support

Hi all,

This patch series adds LE-only support to Stop Discovery MGMT
command.

This series depends on the last series sent "MGMT Start Discovery
command LE-Only Support"

BR,

Andre

Andre Guedes (3):
Bluetooth: Add hci_cancel_le_scan() to hci_core
Bluetooth: Consider DISCOVERY_LE_SCAN state in hci_discovery_active
Bluetooth: MGMT stop discovery LE support

include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_core.c | 19 +++++++++++++++++++
net/bluetooth/mgmt.c | 9 +++++++++
3 files changed, 29 insertions(+), 0 deletions(-)

--
1.7.8.3



2012-01-13 21:03:52

by Andre Guedes

[permalink] [raw]
Subject: [PATCH 3/3] Bluetooth: MGMT stop discovery LE support

This patch adds support to MGMT stop discovery command so now we are
able to cancel LE-based discovery procedures.

Signed-off-by: Andre Guedes <[email protected]>
---
net/bluetooth/mgmt.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 05e6c1f..a8b60dc 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2000,6 +2000,15 @@ static int stop_discovery(struct sock *sk, u16 index)
goto unlock;
}

+ if (hdev->discovery.state == DISCOVERY_LE_SCAN) {
+ err = hci_cancel_le_scan(hdev);
+ if (err < 0)
+ mgmt_pending_remove(cmd);
+ else
+ hci_discovery_set_state(hdev, DISCOVERY_STOPPING);
+ goto unlock;
+ }
+
e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_PENDING);
if (!e) {
mgmt_pending_remove(cmd);
--
1.7.8.3


2012-01-13 21:03:51

by Andre Guedes

[permalink] [raw]
Subject: [PATCH 2/3] Bluetooth: Consider DISCOVERY_LE_SCAN state in hci_discovery_active

Signed-off-by: Andre Guedes <[email protected]>
---
net/bluetooth/hci_core.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index ae765c4..6d6d3db 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -384,6 +384,7 @@ bool hci_discovery_active(struct hci_dev *hdev)
struct discovery_state *discov = &hdev->discovery;

if (discov->state == DISCOVERY_INQUIRY ||
+ discov->state == DISCOVERY_LE_SCAN ||
discov->state == DISCOVERY_RESOLVING)
return true;

--
1.7.8.3


2012-01-13 21:03:50

by Andre Guedes

[permalink] [raw]
Subject: [PATCH 1/3] Bluetooth: Add hci_cancel_le_scan() to hci_core

This patch adds to hci_core the hci_cancel_le_scan function which
should be used to cancel an ongoing LE scan.

Signed-off-by: Andre Guedes <[email protected]>
---
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_core.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 114d1a5..a29ecaa 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -992,5 +992,6 @@ int hci_do_inquiry(struct hci_dev *hdev, u8 length);
int hci_cancel_inquiry(struct hci_dev *hdev);
int hci_do_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window,
int timeout);
+int hci_cancel_le_scan(struct hci_dev *hdev);

#endif /* __HCI_CORE_H */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index ca0fffb..ae765c4 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2819,5 +2819,23 @@ int hci_do_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window,
return 0;
}

+int hci_cancel_le_scan(struct hci_dev *hdev)
+{
+ int pending;
+
+ BT_DBG("%s", hdev->name);
+
+ pending = cancel_work_sync(&hdev->le_scan_enable);
+ if (pending)
+ return 0;
+
+ if (!test_bit(HCI_LE_SCAN, &hdev->dev_flags))
+ return -EPERM;
+
+ flush_delayed_work_sync(&hdev->le_scan_disable);
+
+ return 0;
+}
+
module_param(enable_hs, bool, 0644);
MODULE_PARM_DESC(enable_hs, "Enable High Speed");
--
1.7.8.3