diff --git a/components/esp_hw_support/port/regdma_link.c b/components/esp_hw_support/port/regdma_link.c index d941b87540..a51fb03d43 100644 --- a/components/esp_hw_support/port/regdma_link.c +++ b/components/esp_hw_support/port/regdma_link.c @@ -631,13 +631,13 @@ void * regdma_find_module_link_head(void *link, void *tail, int entry, uint32_t void *next = link; if (link) { do { - if (next == tail) { - break; - } if (regdma_link_get_stats(next)->module & module) { find_link = next; break; } + if (next == tail) { + break; + } } while ((next = regdma_link_get_next(next, entry)) != NULL); } return find_link; @@ -686,12 +686,12 @@ void * regdma_find_prev_module_link_tail(void *link, void *tail, int entry, uint void *next = link; if (find_head && find_head != link) { do { - if (next == tail) { - break; - } if (regdma_link_get_next(next, entry) == find_head) { return next; } + if (next == tail) { + break; + } } while ((next = regdma_link_get_next(next, entry)) != NULL); } return NULL; diff --git a/components/esp_hw_support/sleep_retention.c b/components/esp_hw_support/sleep_retention.c index c78f8c20a4..de6110dae7 100644 --- a/components/esp_hw_support/sleep_retention.c +++ b/components/esp_hw_support/sleep_retention.c @@ -326,13 +326,21 @@ static void sleep_retention_entries_all_destroy_wrapper(uint32_t module) _lock_release_recursive(&s_retention.lock); } -void sleep_retention_entries_destroy(int module) +static void sleep_retention_entries_do_destroy(int module) { assert(module != 0); _lock_acquire_recursive(&s_retention.lock); sleep_retention_entries_join(); sleep_retention_entries_stats(); sleep_retention_entries_all_destroy_wrapper(module); + _lock_release_recursive(&s_retention.lock); +} + +void sleep_retention_entries_destroy(int module) +{ + assert(module != 0); + _lock_acquire_recursive(&s_retention.lock); + sleep_retention_entries_do_destroy(module); if (s_retention.modules == 0) { sleep_retention_entries_check_and_distroy_final_default(); pmu_sleep_disable_regdma_backup(); @@ -353,7 +361,7 @@ static esp_err_t sleep_retention_entries_create_impl(const sleep_retention_entri void *link = sleep_retention_entries_try_create(&retent[i].config, retent[i].owner, priority, module); if (link == NULL) { _lock_release_recursive(&s_retention.lock); - sleep_retention_entries_destroy(module); + sleep_retention_entries_do_destroy(module); return ESP_ERR_NO_MEM; } sleep_retention_entries_update(retent[i].owner, link, priority); @@ -370,7 +378,7 @@ static esp_err_t sleep_retention_entries_create_bonding(regdma_link_priority_t p void *link = sleep_retention_entries_try_create_bonding(&bonding_dummy.config, bonding_dummy.owner, priority, module); if (link == NULL) { _lock_release_recursive(&s_retention.lock); - sleep_retention_entries_destroy(module); + sleep_retention_entries_do_destroy(module); return ESP_ERR_NO_MEM; } sleep_retention_entries_update(bonding_dummy.owner, link, priority);