Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v2 1/8] android/bluetooth: Refactor handle_start_discovery_cmd
Date: Tue, 06 May 2014 14:35:13 +0200	[thread overview]
Message-ID: <2865075.siZ0ujU7hl@uw000953> (raw)
In-Reply-To: <1398610498-1112-1-git-send-email-szymon.janc@tieto.com>

On Sunday 27 of April 2014 16:54:51 Szymon Janc wrote:
> This makes function flow easier to follow. Also fix usage of
> adapter.exp_discovery_type which should be used only when stopping
> currently running discovery session to restart it with new type.
> ---
>  android/bluetooth.c | 43 +++++++++++++++++++++----------------------
>  1 file changed, 21 insertions(+), 22 deletions(-)
> 
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 7d82aba..3931618 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -3704,39 +3704,38 @@ static void handle_start_discovery_cmd(const void *buf, uint16_t len)
>  {
>  	uint8_t status;
>  
> -	/* Check if there is discovery with BREDR type */
> -	if (adapter.cur_discovery_type & SCAN_TYPE_BREDR) {
> -		status = HAL_STATUS_SUCCESS;
> -		goto reply;
> -	}
> -
>  	if (!(adapter.current_settings & MGMT_SETTING_POWERED)) {
>  		status = HAL_STATUS_NOT_READY;
> -		goto reply;
> +		goto failed;
>  	}
>  
> -	adapter.exp_discovery_type |= SCAN_TYPE_DUAL;
> -
> -	/* If there is no discovery ongoing, try to start discovery */
> -	if (!adapter.cur_discovery_type) {
> -		if (!start_discovery(adapter.exp_discovery_type))
> +	switch (adapter.cur_discovery_type) {
> +	case SCAN_TYPE_DUAL:
> +	case SCAN_TYPE_BREDR:
> +		break;
> +	case SCAN_TYPE_NONE:
> +		if (!start_discovery(SCAN_TYPE_DUAL)) {
>  			status = HAL_STATUS_FAILED;
> -		else
> -			status = HAL_STATUS_SUCCESS;
> +			goto failed;
> +		}
>  
> -		goto reply;
> -	}
> +		break;
> +	case SCAN_TYPE_LE:
> +		if (get_adapter_discovering_type() == SCAN_TYPE_LE)
> +			break;
>  
> -	/* Stop discovery here. Once it is stop we will restart it
> -	 * with exp_discovery_settings */
> -	if (!stop_discovery(adapter.cur_discovery_type)) {
> -		status = HAL_STATUS_FAILED;
> -		goto reply;
> +		if (!stop_discovery(SCAN_TYPE_LE)) {
> +			status = HAL_STATUS_FAILED;
> +			goto failed;
> +		}
> +
> +		adapter.exp_discovery_type = SCAN_TYPE_DUAL;
> +		break;
>  	}
>  
>  	status = HAL_STATUS_SUCCESS;
>  
> -reply:
> +failed:
>  	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_BLUETOOTH, HAL_OP_START_DISCOVERY,
>  									status);
>  }
> 

Rebased and pushed.

-- 
Best regards, 
Szymon Janc

      parent reply	other threads:[~2014-05-06 12:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-27 14:54 [PATCH v2 1/8] android/bluetooth: Refactor handle_start_discovery_cmd Szymon Janc
2014-04-27 14:54 ` [PATCH v2 2/8] android/bluetooth: Refactor handle_cancel_discovery_cmd Szymon Janc
2014-04-27 14:54 ` [PATCH v2 3/8] android/bluetooth: Fix bt_le_discovery_start Szymon Janc
2014-04-27 14:54 ` [PATCH v2 4/8] android/bluetooth: Fix bt_le_discovery_stop Szymon Janc
2014-04-27 14:54 ` [PATCH v2 5/8] android/bluetooth: Refactor mgmt_discovering_event Szymon Janc
2014-04-27 14:54 ` [PATCH v2 6/8] android/bluetooth: Avoid starting/stopping discovery with no type Szymon Janc
2014-04-27 14:54 ` [PATCH v2 7/8] android/bluetooth: Fix sending discovery state changed events Szymon Janc
2014-04-27 14:54 ` [PATCH v2 8/8] android/bluetooth: Rename get_adapter_discovering_type function Szymon Janc
2014-05-06 12:35 ` Szymon Janc [this message]

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=2865075.siZ0ujU7hl@uw000953 \
    --to=szymon.janc@tieto.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