Re: [PATCH 1/6] android: Use common exit path for commands in bt_adapter_handle_cmd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Szymon,

On Fri, Oct 25, 2013 at 6:14 PM, Szymon Janc <szymon.janc@xxxxxxxxx> wrote:
> All adapter commands return no parameters so putting error and success
> response on common exit path. This will make function easier to follow
> when more commands support will be added.
> ---
>  android/adapter.c | 34 ++++++++++++++++------------------
>  1 file changed, 16 insertions(+), 18 deletions(-)
>
> diff --git a/android/adapter.c b/android/adapter.c
> index ec90cca..685b00d 100644
> --- a/android/adapter.c
> +++ b/android/adapter.c
> @@ -374,39 +374,37 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf,
>         case HAL_OP_ENABLE:
>                 if (adapter->current_settings & MGMT_SETTING_POWERED) {
>                         status = HAL_STATUS_DONE;
> -                       break;
> +                       goto error;
>                 }
>
> -               if (set_mode(MGMT_OP_SET_POWERED, 0x01)) {
> -                       ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
> -                                                                       -1);
> -                       return;
> -               }
> +               if (!set_mode(MGMT_OP_SET_POWERED, 0x01))
> +                       goto error;
> +
>                 break;
>         case HAL_OP_DISABLE:
>                 if (!(adapter->current_settings & MGMT_SETTING_POWERED)) {
>                         status = HAL_STATUS_DONE;
> -                       break;
> +                       goto error;
>                 }
>
> -               if (set_mode(MGMT_OP_SET_POWERED, 0x00)) {
> -                       ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
> -                                                                       -1);
> -                       return;
> -               }
> +               if (!set_mode(MGMT_OP_SET_POWERED, 0x00))
> +                       goto error;
> +
>                 break;
>         case HAL_OP_GET_ADAPTER_PROP:
> -               if (get_property(buf, len)) {
> -                       ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL,
> -                                                                       -1);
> -                       return;
> -               }
> +               if (!get_property(buf, len))
> +                       goto error;
> +
>                 break;
>         default:
>                 DBG("Unhandled command, opcode 0x%x", opcode);
> -               break;
> +               goto error;
>         }
>
> +       ipc_send(io, HAL_SERVICE_ID_BLUETOOTH, opcode, 0, NULL, -1);
> +       return;
> +
> +error:
>         ipc_send_rsp(io, HAL_SERVICE_ID_BLUETOOTH, status);
>  }
>
> --
> 1.8.4.1

Pushed, thanks.


-- 
Luiz Augusto von Dentz
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux