From: Marcel Holtmann <marcel@holtmann.org>
To: Jaganath Kanakkassery <jaganath.k@samsung.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v3 3/3] Bluetooth: Fix stop discovery while in STARTING state
Date: Tue, 15 Jan 2013 08:17:51 -0800 [thread overview]
Message-ID: <1358266671.2445.1.camel@aeonflux> (raw)
In-Reply-To: <1358254892-11303-3-git-send-email-jaganath.k@samsung.com>
Hi Jaganath,
> If stop_discovery() is called when discovery state is STARTING, it
> will be failed currently. This patch fixes this.
>
> Signed-off-by: Jaganath Kanakkassery <jaganath.k@samsung.com>
> ---
> include/net/bluetooth/hci_core.h | 1 +
> net/bluetooth/hci_event.c | 14 ++++++++++++--
> net/bluetooth/mgmt.c | 12 +++++++++++-
> 3 files changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index d8f68c7..01c723a 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -64,6 +64,7 @@ struct discovery_state {
> DISCOVERY_RESOLVING,
> DISCOVERY_STOPPING,
> } state;
> + u8 discovering;
what is this double spaces for? And why not a bool. Or a better name.
> struct list_head all; /* All devices found during inquiry */
> struct list_head unknown; /* Name state not known */
> struct list_head resolve; /* Name needs to be resolved */
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 97b4828..c616cbf 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -1259,7 +1259,12 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
> set_bit(HCI_LE_SCAN, &hdev->dev_flags);
>
> hci_dev_lock(hdev);
> - hci_discovery_set_state(hdev, DISCOVERY_FINDING);
> + if (hdev->discovery.state == DISCOVERY_STOPPING) {
> + hci_cancel_le_scan(hdev);
> + mgmt_start_discovery_cancelled(hdev);
> + } else {
> + hci_discovery_set_state(hdev, DISCOVERY_FINDING);
> + }
> hci_dev_unlock(hdev);
> break;
>
> @@ -1375,7 +1380,12 @@ static void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
> set_bit(HCI_INQUIRY, &hdev->flags);
>
> hci_dev_lock(hdev);
> - hci_discovery_set_state(hdev, DISCOVERY_FINDING);
> + if (hdev->discovery.state == DISCOVERY_STOPPING) {
> + hci_cancel_inquiry(hdev);
> + mgmt_start_discovery_cancelled(hdev);
> + } else {
> + hci_discovery_set_state(hdev, DISCOVERY_FINDING);
> + }
> hci_dev_unlock(hdev);
> }
>
> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> index 0db9d66..6dc275f 100644
> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -2394,7 +2394,8 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
>
> hci_dev_lock(hdev);
>
> - if (!hci_discovery_active(hdev)) {
> + if (hdev->discovery.state != DISCOVERY_STARTING &&
> + !hci_discovery_active(hdev)) {
> err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY,
> MGMT_STATUS_REJECTED, &mgmt_cp->type,
> sizeof(mgmt_cp->type));
> @@ -2442,6 +2443,10 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data,
>
> break;
>
> + case DISCOVERY_STARTING:
> + err = 0;
> + break;
> +
> default:
> BT_DBG("unknown discovery state %u", hdev->discovery.state);
> err = -EFAULT;
> @@ -3720,6 +3725,11 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering)
> mgmt_pending_remove(cmd);
> }
>
> + if (hdev->discovery.discovering == discovering)
> + return 0;
> +
> + hdev->discovery.discovering = discovering;
> +
> memset(&ev, 0, sizeof(ev));
> ev.type = hdev->discovery.type;
> ev.discovering = discovering;
Regards
Marcel
next prev parent reply other threads:[~2013-01-15 16:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-15 13:01 [PATCH v3 1/3] Bluetooth: Move discovery state check inside hci_dev_lock() Jaganath Kanakkassery
2013-01-15 13:01 ` [PATCH v3 2/3] Bluetooth: Add mgmt_start_discovery_cancelled() Jaganath Kanakkassery
2013-01-15 13:01 ` [PATCH v3 3/3] Bluetooth: Fix stop discovery while in STARTING state Jaganath Kanakkassery
2013-01-15 16:17 ` Marcel Holtmann [this message]
2013-01-16 6:03 ` Jaganath Kanakkassery
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=1358266671.2445.1.camel@aeonflux \
--to=marcel@holtmann.org \
--cc=jaganath.k@samsung.com \
--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