From de7e62fdfec13c844c0d224cd908efca16b2b7df Mon Sep 17 00:00:00 2001 From: zwl Date: Fri, 2 Dec 2022 14:28:33 +0800 Subject: [PATCH] Unify controller internal error code on ESP32-C2 --- components/bt/controller/esp32c2/bt.c | 18 ++++++++++-------- .../bt/controller/lib_esp32c2/esp32c2-bt-lib | 2 +- .../bt/porting/nimble/src/os_msys_init.c | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 38421cdd65..032628aec9 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -597,18 +597,20 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "invalid controller state"); - return ESP_FAIL; + return ESP_ERR_INVALID_STATE; } - if (cfg == NULL) { + + if (!cfg) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "cfg is NULL"); return ESP_ERR_INVALID_ARG; } ble_rtc_clk_init(); - if (esp_register_ext_funcs(&ext_funcs_ro) != 0) { + ret = esp_register_ext_funcs(&ext_funcs_ro); + if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "register extend functions failed"); - return ESP_ERR_INVALID_ARG; + return ret; } /* Initialize the function pointers for OS porting */ @@ -619,9 +621,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ESP_ERR_INVALID_ARG; } - if (esp_register_npl_funcs(p_npl_funcs) != 0) { + ret = esp_register_npl_funcs(p_npl_funcs); + if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "npl functions register failed"); - ret = ESP_ERR_INVALID_ARG; goto free_mem; } @@ -632,9 +634,9 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) } /* Initialize the global memory pool */ - if (os_msys_buf_alloc() != 0) { + ret = os_msys_buf_alloc(); + if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "os msys alloc failed"); - ret = ESP_ERR_INVALID_ARG; goto free_mem; } diff --git a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib index db13654151..9d28544633 160000 --- a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib +++ b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib @@ -1 +1 @@ -Subproject commit db13654151c6669edb13c24046c6439620e8cb97 +Subproject commit 9d28544633f0e0beee2f20e6c1cd28c54ce6ab9b diff --git a/components/bt/porting/nimble/src/os_msys_init.c b/components/bt/porting/nimble/src/os_msys_init.c index b5d3efc8e2..b23e18de3b 100644 --- a/components/bt/porting/nimble/src/os_msys_init.c +++ b/components/bt/porting/nimble/src/os_msys_init.c @@ -141,7 +141,7 @@ os_msys_buf_alloc(void) #if OS_MSYS_1_BLOCK_COUNT > 0 os_msys_init_1_data = (os_membuf_t *)bt_osi_mem_calloc(1, (sizeof(os_membuf_t) * SYSINIT_MSYS_1_MEMPOOL_SIZE)); if (!os_msys_init_1_data) { - return ESP_FAIL; + return ESP_ERR_NO_MEM; } #endif @@ -152,7 +152,7 @@ os_msys_buf_alloc(void) bt_osi_mem_free(os_msys_init_1_data); os_msys_init_1_data = NULL; #endif - return ESP_FAIL; + return ESP_ERR_NO_MEM; } #endif