Linux bluetooth development
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Andre Guedes <andre.guedes@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v4 06/14] Bluetooth: Create hci_cancel_inquiry()
Date: Tue, 20 Sep 2011 14:33:03 +0200	[thread overview]
Message-ID: <1316521985.1937.78.camel@aeonflux> (raw)
In-Reply-To: <1316468136-12472-7-git-send-email-andre.guedes@openbossa.org>

Hi Andre,

> This patch adds a function to hci_core to cancel an ongoing inquiry.
> 
> According to the Bluetooth spec, the inquiry cancel command should
> only be issued after the inquiry command has been issued, a command
> status event has been received for the inquiry command, and before
> the inquiry complete event occurs.
> 
> As HCI_INQUIRY flag is only set just after an inquiry command status
> event occurs and it is cleared just after an inquiry complete event
> occurs, the inquiry cancel command should be issued only if HCI_INQUIRY
> flag is set.
> 
> Additionally, cancel inquiry related code from stop_discovery() were
> replaced by a hci_cancel_inquiry() call.
> 
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
>  include/net/bluetooth/hci_core.h |    1 +
>  net/bluetooth/hci_core.c         |   10 ++++++++++
>  net/bluetooth/mgmt.c             |    2 +-
>  3 files changed, 12 insertions(+), 1 deletions(-)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index b7c070b..4a79a50 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -915,5 +915,6 @@ void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]);
>  void hci_le_ltk_neg_reply(struct hci_conn *conn);
>  
>  int hci_do_inquiry(struct hci_dev *hdev, u8 length);
> +int hci_cancel_inquiry(struct hci_dev *hdev);
>  
>  #endif /* __HCI_CORE_H */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index ebfd963..f62b465 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -2422,3 +2422,13 @@ int hci_do_inquiry(struct hci_dev *hdev, u8 length)
>  
>  	return hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp);
>  }
> +
> +int hci_cancel_inquiry(struct hci_dev *hdev)
> +{
> +	BT_DBG("%s", hdev->name);
> +
> +	if (!test_bit(HCI_INQUIRY, &hdev->flags))
> +		return -EPERM;
> +
> +	return hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL);
> +}
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 4f77468..d84f242 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -1674,7 +1674,7 @@ static int stop_discovery(struct sock *sk, u16 index)
>  		goto failed;
>  	}
>  
> -	err = hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL);
> +	err = hci_cancel_inquiry(hdev);
>  	if (err < 0)
>  		mgmt_pending_remove(cmd);
>  

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

Regards

Marcel



  reply	other threads:[~2011-09-20 12:33 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-19 21:35 [PATCH v4 00/14] Discovery support Andre Guedes
2011-09-19 21:35 ` [PATCH v4 01/14] Bluetooth: Periodic Inquiry and mgmt discovering event Andre Guedes
2011-09-20 12:23   ` Marcel Holtmann
2011-09-23 19:12     ` Andre Guedes
2012-03-19 12:40     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 02/14] Bluetooth: Add mgmt_discovery_complete() Andre Guedes
2011-09-20 12:29   ` Marcel Holtmann
2011-09-23 19:13     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 03/14] Bluetooth: Check pending command in start_discovery() Andre Guedes
2011-09-20 12:26   ` Marcel Holtmann
2011-09-23 19:13     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 04/14] Bluetooth: Check pending commands in stop_discovery() Andre Guedes
2011-09-19 21:35 ` [PATCH v4 05/14] Bluetooth: Create hci_do_inquiry() Andre Guedes
2011-09-20 12:31   ` Marcel Holtmann
2011-09-23 19:13     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 06/14] Bluetooth: Create hci_cancel_inquiry() Andre Guedes
2011-09-20 12:33   ` Marcel Holtmann [this message]
2011-09-19 21:35 ` [PATCH v4 07/14] Bluetooth: Handle race condition in Discovery Andre Guedes
2011-09-20 12:37   ` Marcel Holtmann
2011-09-23 19:13     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 08/14] Bluetooth: Prepare for full support discovery procedures Andre Guedes
2011-09-20 12:43   ` Marcel Holtmann
2011-09-23 19:14     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 09/14] Bluetooth: Send mgmt_discovering events Andre Guedes
2011-09-20 12:45   ` Marcel Holtmann
2011-09-23 19:15     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 10/14] Bluetooth: Add 'eir_len' param to mgmt_device_found() Andre Guedes
2011-09-20 12:47   ` Marcel Holtmann
2011-09-19 21:35 ` [PATCH v4 11/14] Bluetooth: Report LE devices Andre Guedes
2011-09-20 12:49   ` Marcel Holtmann
2011-09-23 19:15     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 12/14] Bluetooth: LE scan infra-structure Andre Guedes
2011-09-20 12:53   ` Marcel Holtmann
2011-09-23 19:15     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 13/14] Bluetooth: Support LE-Only discovery procedure Andre Guedes
2011-09-20 13:00   ` Marcel Holtmann
2011-09-23 19:16     ` Andre Guedes
2011-09-19 21:35 ` [PATCH v4 14/14] Bluetooth: Support BR/EDR/LE " Andre Guedes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1316521985.1937.78.camel@aeonflux \
    --to=marcel@holtmann.org \
    --cc=andre.guedes@openbossa.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox