static void service_register(const void *buf, uint16_t len)
{
const struct hal_cmd_register_module *m = buf;
+ uint8_t status;
- if (m->service_id > HAL_SERVICE_ID_MAX || services[m->service_id])
+ if (m->service_id > HAL_SERVICE_ID_MAX || services[m->service_id]) {
+ status = HAL_STATUS_FAILED;
goto failed;
+ }
switch (m->service_id) {
case HAL_SERVICE_ID_BLUETOOTH:
break;
case HAL_SERVICE_ID_HIDHOST:
- if (!bt_hid_register(&adapter_bdaddr))
+ if (!bt_hid_register(&adapter_bdaddr)) {
+ status = HAL_STATUS_FAILED;
goto failed;
+ }
break;
case HAL_SERVICE_ID_A2DP:
- if (!bt_a2dp_register(&adapter_bdaddr))
+ if (!bt_a2dp_register(&adapter_bdaddr)) {
+ status = HAL_STATUS_FAILED;
goto failed;
+ }
break;
case HAL_SERVICE_ID_PAN:
- if (!bt_pan_register(&adapter_bdaddr))
+ if (!bt_pan_register(&adapter_bdaddr)) {
+ status = HAL_STATUS_FAILED;
goto failed;
+ }
break;
default:
DBG("service %u not supported", m->service_id);
+ status = HAL_STATUS_FAILED;
goto failed;
}
services[m->service_id] = true;
- ipc_send_rsp(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
- HAL_STATUS_SUCCESS);
+ status = HAL_STATUS_SUCCESS;
info("Service ID=%u registered", m->service_id);
- return;
+
failed:
- ipc_send_rsp(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
- HAL_STATUS_FAILED);
+ ipc_send_rsp(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, status);
}
static void service_unregister(const void *buf, uint16_t len)
{
const struct hal_cmd_unregister_module *m = buf;
+ uint8_t status;
- if (m->service_id > HAL_SERVICE_ID_MAX || !services[m->service_id])
+ if (m->service_id > HAL_SERVICE_ID_MAX || !services[m->service_id]) {
+ status = HAL_STATUS_FAILED;
goto failed;
+ }
switch (m->service_id) {
case HAL_SERVICE_ID_BLUETOOTH:
/* This would indicate bug in HAL, as unregister should not be
* called in init failed */
DBG("service %u not supported", m->service_id);
+ status = HAL_STATUS_FAILED;
goto failed;
}
services[m->service_id] = false;
- ipc_send_rsp(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
- HAL_STATUS_SUCCESS);
+ status = HAL_STATUS_SUCCESS;
info("Service ID=%u unregistered", m->service_id);
- return;
+
failed:
- ipc_send_rsp(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
- HAL_STATUS_FAILED);
+ ipc_send_rsp(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE, status);
}
static const struct ipc_handler cmd_handlers[] = {