public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] LE support for MGMT Stop Discovery
@ 2012-03-15 19:52 Andre Guedes
  2012-03-15 19:52 ` [PATCH v3 1/2] Bluetooth: Add hci_cancel_le_scan() to hci_core Andre Guedes
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andre Guedes @ 2012-03-15 19:52 UTC (permalink / raw)
  To: linux-bluetooth

>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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/2] Bluetooth: Add hci_cancel_le_scan() to hci_core
  2012-03-15 19:52 [PATCH v3 0/2] LE support for MGMT Stop Discovery Andre Guedes
@ 2012-03-15 19:52 ` Andre Guedes
  2012-03-15 21:52   ` Marcel Holtmann
  2012-03-15 19:52 ` [PATCH v3 2/2] Bluetooth: LE support for MGMT stop discovery Andre Guedes
  2012-03-16 15:59 ` [PATCH v3 0/2] LE support for MGMT Stop Discovery Johan Hedberg
  2 siblings, 1 reply; 5+ messages in thread
From: Andre Guedes @ 2012-03-15 19:52 UTC (permalink / raw)
  To: linux-bluetooth

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 <andre.guedes@openbossa.org>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/2] Bluetooth: LE support for MGMT stop discovery
  2012-03-15 19:52 [PATCH v3 0/2] LE support for MGMT Stop Discovery Andre Guedes
  2012-03-15 19:52 ` [PATCH v3 1/2] Bluetooth: Add hci_cancel_le_scan() to hci_core Andre Guedes
@ 2012-03-15 19:52 ` Andre Guedes
  2012-03-16 15:59 ` [PATCH v3 0/2] LE support for MGMT Stop Discovery Johan Hedberg
  2 siblings, 0 replies; 5+ messages in thread
From: Andre Guedes @ 2012-03-15 19:52 UTC (permalink / raw)
  To: linux-bluetooth

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 <andre.guedes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 1/2] Bluetooth: Add hci_cancel_le_scan() to hci_core
  2012-03-15 19:52 ` [PATCH v3 1/2] Bluetooth: Add hci_cancel_le_scan() to hci_core Andre Guedes
@ 2012-03-15 21:52   ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2012-03-15 21:52 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth

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 <andre.guedes@openbossa.org>
> ---
>  include/net/bluetooth/hci_core.h |    1 +
>  net/bluetooth/hci_core.c         |   18 ++++++++++++++++++
>  2 files changed, 19 insertions(+)

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 0/2] LE support for MGMT Stop Discovery
  2012-03-15 19:52 [PATCH v3 0/2] LE support for MGMT Stop Discovery Andre Guedes
  2012-03-15 19:52 ` [PATCH v3 1/2] Bluetooth: Add hci_cancel_le_scan() to hci_core Andre Guedes
  2012-03-15 19:52 ` [PATCH v3 2/2] Bluetooth: LE support for MGMT stop discovery Andre Guedes
@ 2012-03-16 15:59 ` Johan Hedberg
  2 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2012-03-16 15:59 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-03-16 15:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-15 19:52 [PATCH v3 0/2] LE support for MGMT Stop Discovery Andre Guedes
2012-03-15 19:52 ` [PATCH v3 1/2] Bluetooth: Add hci_cancel_le_scan() to hci_core Andre Guedes
2012-03-15 21:52   ` Marcel Holtmann
2012-03-15 19:52 ` [PATCH v3 2/2] Bluetooth: LE support for MGMT stop discovery Andre Guedes
2012-03-16 15:59 ` [PATCH v3 0/2] LE support for MGMT Stop Discovery Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox