All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Hemant Gupta <hemant.gupta@stericsson.com>
Cc: linux-bluetooth@vger.kernel.org,
	Hemant Gupta <hemantgupta.ste@gmail.com>
Subject: Re: [PATCH] Bluetooth: Send Discovery Stopped event when discovery fails
Date: Thu, 5 Apr 2012 13:58:24 +0300	[thread overview]
Message-ID: <20120405105824.GH32212@x220> (raw)
In-Reply-To: <1333603129-18813-1-git-send-email-hemant.gupta@stericsson.com>

Hi Hemant,

On Thu, Apr 05, 2012, Hemant Gupta wrote:
> This patch sends MGMT_EV_DISCOVERING event to manamgement interface of
> BlueZ to indicate that discovery is stopped in case of discovery failure.
> Without this patch discovery session of BlueZ was not getting freed.
> This event was not sent from kernel in case discovery state is still
> DISCOVERY_STARTING.
> 
> Signed-off-by: Hemant Gupta <hemant.gupta@stericsson.com>
> ---
>  net/bluetooth/hci_core.c |    2 +-
>  net/bluetooth/mgmt.c     |   16 +---------------
>  2 files changed, 2 insertions(+), 16 deletions(-)

This patch in general doesn't make much sense to me.

> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 9629645..b97a7dc 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -384,7 +384,7 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state)
>  
>  	switch (state) {
>  	case DISCOVERY_STOPPED:
> -		if (hdev->discovery.state != DISCOVERY_STARTING)
> +		if (hdev->discovery.state != DISCOVERY_STOPPED)
>  			mgmt_discovering(hdev, 0);
>  		break;

This is wrong in several different ways. Firstly it's wrong since we
only do mgmt_discovering(hdev, 1) when going to DISCOVERY_FINDING state
so mgmt_discovering(hdev, 0) should not be called before that. Secondly
it's wrong because the function will return if hdev->discovery.state ==
state, i.e. your if statement would always evaluate to true and
therefore be redundant.

> --- a/net/bluetooth/mgmt.c
> +++ b/net/bluetooth/mgmt.c
> @@ -3572,23 +3572,9 @@ int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
>  
>  int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status)
>  {
> -	struct pending_cmd *cmd;
> -	u8 type;
> -	int err;
> -
>  	hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
>  
> -	cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev);
> -	if (!cmd)
> -		return -ENOENT;
> -
> -	type = hdev->discovery.type;
> -
> -	err = cmd_complete(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status),
> -			   &type, sizeof(type));
> -	mgmt_pending_remove(cmd);
> -
> -	return err;
> +	return 0;
>  }

So who sends the appropriate command complete event to start_discovery
now? I don't see any other place that would do it.

Johan

  reply	other threads:[~2012-04-05 10:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-05  5:18 [PATCH] Bluetooth: Send Discovery Stopped event when discovery fails Hemant Gupta
2012-04-05 10:58 ` Johan Hedberg [this message]
2012-04-05 11:29   ` Hemant Gupta
2012-04-05 15:41     ` Johan Hedberg
2012-04-05 15:45       ` Hemant Gupta

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=20120405105824.GH32212@x220 \
    --to=johan.hedberg@gmail.com \
    --cc=hemant.gupta@stericsson.com \
    --cc=hemantgupta.ste@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.