2012-03-15 19:52:06

by Andre Guedes

[permalink] [raw]
Subject: [PATCH v3 0/2] LE support for MGMT Stop Discovery

>From the previous cover letter:

This small patch series adds LE support for Stop Discovery MGMT command.
Now, we are able to stop LE discovery procedues (LE-only and interleaved).

A brief word about patch 1/2: due to discovery state machine, we don't need
to worry about canceling hdev->le_scan work since it is never pending or
running when hci_cancel_le_scan is called.

Andre Guedes (2):
Bluetooth: Add hci_cancel_le_scan() to hci_core
Bluetooth: LE support for MGMT stop discovery

include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_core.c | 18 ++++++++++++++++++
net/bluetooth/hci_event.c | 6 +++++-
net/bluetooth/mgmt.c | 6 +++++-
4 files changed, 29 insertions(+), 2 deletions(-)

--
1.7.9.4



2012-03-16 15:59:39

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH v3 0/2] LE support for MGMT Stop Discovery

Hi Andre,

On Thu, Mar 15, 2012, Andre Guedes wrote:
> From the previous cover letter:
>
> This small patch series adds LE support for Stop Discovery MGMT command.
> Now, we are able to stop LE discovery procedues (LE-only and interleaved).
>
> A brief word about patch 1/2: due to discovery state machine, we don't need
> to worry about canceling hdev->le_scan work since it is never pending or
> running when hci_cancel_le_scan is called.
>
> Andre Guedes (2):
> Bluetooth: Add hci_cancel_le_scan() to hci_core
> Bluetooth: LE support for MGMT stop discovery
>
> include/net/bluetooth/hci_core.h | 1 +
> net/bluetooth/hci_core.c | 18 ++++++++++++++++++
> net/bluetooth/hci_event.c | 6 +++++-
> net/bluetooth/mgmt.c | 6 +++++-
> 4 files changed, 29 insertions(+), 2 deletions(-)

Both patches have been applied to my bluetooth-next tree. Thanks.

Johan

2012-03-15 21:52:15

by Marcel Holtmann

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

Hi Andre,

> 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(+)

Acked-by: Marcel Holtmann <[email protected]>

Regards

Marcel



2012-03-15 19:52:08

by Andre Guedes

[permalink] [raw]
Subject: [PATCH v3 2/2] Bluetooth: LE support for MGMT stop discovery

This patch adds LE support to MGMT stop discovery command. So,
now we are able to cancel LE discovery procedures (LE-only and
interleaved).

Signed-off-by: Andre Guedes <[email protected]>
Acked-by: Marcel Holtmann <[email protected]>
---
net/bluetooth/hci_event.c | 6 +++++-
net/bluetooth/mgmt.c | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 66ffe45..3efb033 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1092,8 +1092,12 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
break;

case LE_SCANNING_DISABLED:
- if (status)
+ if (status) {
+ hci_dev_lock(hdev);
+ mgmt_stop_discovery_failed(hdev, status);
+ hci_dev_unlock(hdev);
return;
+ }

clear_bit(HCI_LE_SCAN, &hdev->dev_flags);

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 97b5b6c..eeb656d 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2382,7 +2382,11 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
}

if (hdev->discovery.state == DISCOVERY_FINDING) {
- err = hci_cancel_inquiry(hdev);
+ if (test_bit(HCI_INQUIRY, &hdev->flags))
+ err = hci_cancel_inquiry(hdev);
+ else
+ err = hci_cancel_le_scan(hdev);
+
if (err < 0)
mgmt_pending_remove(cmd);
else
--
1.7.9.4


2012-03-15 19:52:07

by Andre Guedes

[permalink] [raw]
Subject: [PATCH v3 1/2] 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(+)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 74dfefa..484e83d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -1071,5 +1071,6 @@ int hci_do_inquiry(struct hci_dev *hdev, u8 length);
int hci_cancel_inquiry(struct hci_dev *hdev);
int hci_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 2f3e1bb..3228183 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1667,6 +1667,24 @@ static int hci_do_le_scan(struct hci_dev *hdev, u8 type, u16 interval,
return 0;
}

+int hci_cancel_le_scan(struct hci_dev *hdev)
+{
+ BT_DBG("%s", hdev->name);
+
+ if (!test_bit(HCI_LE_SCAN, &hdev->dev_flags))
+ return -EALREADY;
+
+ if (cancel_delayed_work(&hdev->le_scan_disable)) {
+ struct hci_cp_le_set_scan_enable cp;
+
+ /* Send HCI command to disable LE Scan */
+ memset(&cp, 0, sizeof(cp));
+ hci_send_cmd(hdev, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
+ }
+
+ return 0;
+}
+
static void le_scan_disable_work(struct work_struct *work)
{
struct hci_dev *hdev = container_of(work, struct hci_dev,
--
1.7.9.4