Unify controller internal error code on ESP32-C2

This commit is contained in:
zwl
2022-12-02 14:28:33 +08:00
committed by cjin
parent 5c481c5a08
commit de7e62fdfe
3 changed files with 13 additions and 11 deletions

View File

@ -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;
}

View File

@ -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