From 1610f70cd601ae9a9d5aded98ba746d88fdb151f Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 25 Oct 2013 15:13:48 +0300 Subject: [PATCH] android: Rename ERROR enum and command to STATUS This is more consistent with HAL interface which does name the enum as bt_status_t and does use BT_STATUS prefix. --- android/adapter.c | 8 ++++---- android/hal-ipc.c | 18 +++++++++--------- android/hal-msg.h | 30 +++++++++++++++--------------- android/hid.c | 2 +- android/ipc.c | 6 +++--- android/main.c | 8 ++++---- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/android/adapter.c b/android/adapter.c index df90db6bf..a76dc043a 100644 --- a/android/adapter.c +++ b/android/adapter.c @@ -332,7 +332,7 @@ static void send_adapter_name(void) ev = g_malloc(len); ev->num_props = 1; - ev->status = HAL_ERROR_SUCCESS; + ev->status = HAL_STATUS_SUCCESS; ev->props[0].type = HAL_PROP_ADAPTER_ADDR; ev->props[0].len = sizeof(bdaddr_t); @@ -368,12 +368,12 @@ static bool get_property(void *buf, uint16_t len) void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len) { - uint8_t status = HAL_ERROR_FAILED; + uint8_t status = HAL_STATUS_FAILED; switch (opcode) { case HAL_OP_ENABLE: if (adapter->current_settings & MGMT_SETTING_POWERED) { - status = HAL_ERROR_DONE; + status = HAL_STATUS_DONE; break; } @@ -385,7 +385,7 @@ void bt_adapter_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, break; case HAL_OP_DISABLE: if (!(adapter->current_settings & MGMT_SETTING_POWERED)) { - status = HAL_ERROR_DONE; + status = HAL_STATUS_DONE; break; } diff --git a/android/hal-ipc.c b/android/hal-ipc.c index 6566ebb96..c7764aba4 100644 --- a/android/hal-ipc.c +++ b/android/hal-ipc.c @@ -263,8 +263,8 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param, struct iovec iv[2]; struct hal_hdr cmd; char cmsgbuf[CMSG_SPACE(sizeof(int))]; - struct hal_error err; - size_t err_len = sizeof(err); + struct hal_status s; + size_t s_len = sizeof(s); if (cmd_sk < 0) { error("Invalid cmd socket passed to hal_ipc_cmd, aborting"); @@ -272,9 +272,9 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param, } if (!rsp || !rsp_len) { - memset(&err, 0, sizeof(err)); - rsp_len = &err_len; - rsp = &err; + memset(&s, 0, s_len); + rsp_len = &s_len; + rsp = &s; } memset(&msg, 0, sizeof(msg)); @@ -346,15 +346,15 @@ int hal_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, void *param, exit(EXIT_FAILURE); } - if (cmd.opcode != opcode && cmd.opcode != HAL_OP_ERROR) { + if (cmd.opcode != opcode && cmd.opcode != HAL_OP_STATUS) { error("Invalid opcode received (%u vs %u), aborting", cmd.opcode, opcode); exit(EXIT_FAILURE); } - if (cmd.opcode == HAL_OP_ERROR) { - struct hal_error *err = rsp; - return err->status; + if (cmd.opcode == HAL_OP_STATUS) { + struct hal_status *s = rsp; + return s->code; } /* Receive auxiliary data in msg */ diff --git a/android/hal-msg.h b/android/hal-msg.h index 753da4b6c..172cecbc3 100644 --- a/android/hal-msg.h +++ b/android/hal-msg.h @@ -49,21 +49,21 @@ struct hal_hdr { /* Core Service */ -#define HAL_ERROR_SUCCESS 0x00 -#define HAL_ERROR_FAILED 0x01 -#define HAL_ERROR_NOT_READY 0x02 -#define HAL_ERROR_NOMEM 0x03 -#define HAL_ERROR_BUSY 0x04 -#define HAL_ERROR_DONE 0x05 -#define HAL_ERROR_UNSUPPORTED 0x06 -#define HAL_ERROR_INVALID 0x07 -#define HAL_ERROR_UNHANDLED 0x08 -#define HAL_ERROR_AUTH_FAILURE 0x09 -#define HAL_ERROR_REMOTE_DEVICE_DOWN 0x0a - -#define HAL_OP_ERROR 0x00 -struct hal_error { - uint8_t status; +#define HAL_STATUS_SUCCESS 0x00 +#define HAL_STATUS_FAILED 0x01 +#define HAL_STATUS_NOT_READY 0x02 +#define HAL_STATUS_NOMEM 0x03 +#define HAL_STATUS_BUSY 0x04 +#define HAL_STATUS_DONE 0x05 +#define HAL_STATUS_UNSUPPORTED 0x06 +#define HAL_STATUS_INVALID 0x07 +#define HAL_STATUS_UNHANDLED 0x08 +#define HAL_STATUS_AUTH_FAILURE 0x09 +#define HAL_STATUS_REMOTE_DEVICE_DOWN 0x0a + +#define HAL_OP_STATUS 0x00 +struct hal_status { + uint8_t code; } __attribute__((packed)); #define HAL_OP_REGISTER_MODULE 0x01 diff --git a/android/hid.c b/android/hid.c index 988e319c9..6eb5a77c9 100644 --- a/android/hid.c +++ b/android/hid.c @@ -36,7 +36,7 @@ static GIOChannel *notification_io = NULL; void bt_hid_handle_cmd(GIOChannel *io, uint8_t opcode, void *buf, uint16_t len) { - uint8_t status = HAL_ERROR_FAILED; + uint8_t status = HAL_STATUS_FAILED; switch (opcode) { case HAL_OP_HID_CONNECT: diff --git a/android/ipc.c b/android/ipc.c index 17005e199..bd92c5188 100644 --- a/android/ipc.c +++ b/android/ipc.c @@ -80,9 +80,9 @@ void ipc_send(GIOChannel *io, uint8_t service_id, uint8_t opcode, uint16_t len, void ipc_send_error(GIOChannel *io, uint8_t service_id, uint8_t status) { - struct hal_error err; + struct hal_status s; - err.status = status; + s.code = status; - ipc_send(io, service_id, HAL_OP_ERROR, sizeof(err), &err, -1); + ipc_send(io, service_id, HAL_OP_STATUS, sizeof(s), &s, -1); } diff --git a/android/main.c b/android/main.c index 18dc9f773..7204d087a 100644 --- a/android/main.c +++ b/android/main.c @@ -112,7 +112,7 @@ static void service_register(void *buf, uint16_t len) info("Service ID=%u registered", m->service_id); return; error: - ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_ERROR_FAILED); + ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_STATUS_FAILED); } static void service_unregister(void *buf, uint16_t len) @@ -147,7 +147,7 @@ static void service_unregister(void *buf, uint16_t len) info("Service ID=%u unregistered", m->service_id); return; error: - ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_ERROR_FAILED); + ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, HAL_STATUS_FAILED); } static void handle_service_core(uint8_t opcode, void *buf, uint16_t len) @@ -161,7 +161,7 @@ static void handle_service_core(uint8_t opcode, void *buf, uint16_t len) break; default: ipc_send_error(hal_cmd_io, HAL_SERVICE_ID_CORE, - HAL_ERROR_FAILED); + HAL_STATUS_FAILED); break; } } @@ -214,7 +214,7 @@ static gboolean cmd_watch_cb(GIOChannel *io, GIOCondition cond, msg->len); break; default: - ipc_send_error(hal_cmd_io, msg->service_id, HAL_ERROR_FAILED); + ipc_send_error(hal_cmd_io, msg->service_id, HAL_STATUS_FAILED); break; } -- 2.47.3