From 5e140f4228574c3454e22e7d8548e6545d77d230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20M=C3=BAdry?= Date: Wed, 22 Nov 2023 11:11:04 +0100 Subject: [PATCH] refactor(esp_partition): Expose function for unloading partitions Closes https://github.com/espressif/esp-idf/issues/12625 --- components/esp_partition/include/esp_partition.h | 7 ++++++- .../esp_partition/include/esp_private/partition_linux.h | 4 ---- components/esp_partition/partition.c | 2 +- components/esp_partition/partition_linux.c | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/esp_partition/include/esp_partition.h b/components/esp_partition/include/esp_partition.h index 0b75dd5f1a9..497688c4eba 100644 --- a/components/esp_partition/include/esp_partition.h +++ b/components/esp_partition/include/esp_partition.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -454,6 +454,11 @@ esp_err_t esp_partition_register_external(esp_flash_t* flash_chip, size_t offset */ esp_err_t esp_partition_deregister_external(const esp_partition_t* partition); +/** + * @brief Unload partitions and free space allocated by them + */ +void esp_partition_unload_all(void); + #ifdef __cplusplus } #endif diff --git a/components/esp_partition/include/esp_private/partition_linux.h b/components/esp_partition/include/esp_private/partition_linux.h index 673155dd53b..4cbde8d3bba 100644 --- a/components/esp_partition/include/esp_private/partition_linux.h +++ b/components/esp_partition/include/esp_private/partition_linux.h @@ -236,10 +236,6 @@ esp_partition_file_mmap_ctrl_t* esp_partition_get_file_mmap_ctrl_input(void); */ esp_partition_file_mmap_ctrl_t* esp_partition_get_file_mmap_ctrl_act(void); -// private function in partition.c to unload partitions and free space allocated by them -void unload_partitions(void); - - #ifdef __cplusplus } #endif diff --git a/components/esp_partition/partition.c b/components/esp_partition/partition.c index 640718a6b1b..0844579e16d 100644 --- a/components/esp_partition/partition.c +++ b/components/esp_partition/partition.c @@ -233,7 +233,7 @@ static esp_err_t load_partitions(void) return err; } -void unload_partitions(void) +void esp_partition_unload_all(void) { _lock_acquire(&s_partition_list_lock); partition_list_item_t *it; diff --git a/components/esp_partition/partition_linux.c b/components/esp_partition/partition_linux.c index 4c55e5e579f..0cce3526f90 100644 --- a/components/esp_partition/partition_linux.c +++ b/components/esp_partition/partition_linux.c @@ -329,7 +329,7 @@ esp_err_t esp_partition_file_munmap(void) return ESP_ERR_NOT_FOUND; } - unload_partitions(); + esp_partition_unload_all(); #ifdef CONFIG_ESP_PARTITION_ENABLE_STATS free(s_esp_partition_stat_sector_erase_count);