Procházet zdrojové kódy

esp_partition_erase_range(): rename parameter "start_addr" to "offset"

The name "start_addr" (which goes straight into the docs) implies
it's an absolute address while in fact it's an offset into the
partition like what's used in all the other esp_partition_*
functions.

So in order to avoid confusion make the name consistent with the
parameter names used for the other partition functions and call it
"offset".

Merges https://github.com/espressif/esp-idf/pull/3750
Martin Thierer před 6 roky
rodič
revize
d6c2dad101

+ 3 - 3
components/spi_flash/include/esp_partition.h

@@ -249,8 +249,8 @@ esp_err_t esp_partition_write(const esp_partition_t* partition,
  * @param partition Pointer to partition structure obtained using
  *                  esp_partition_find_first or esp_partition_get.
  *                  Must be non-NULL.
- * @param start_addr Address where erase operation should start. Must be aligned
- *                   to 4 kilobytes.
+ * @param offset Offset from the beginning of partition where erase operation
+ *               should start. Must be aligned to 4 kilobytes.
  * @param size Size of the range which should be erased, in bytes.
  *                   Must be divisible by 4 kilobytes.
  *
@@ -260,7 +260,7 @@ esp_err_t esp_partition_write(const esp_partition_t* partition,
  *         or one of error codes from lower-level flash driver.
  */
 esp_err_t esp_partition_erase_range(const esp_partition_t* partition,
-                                    size_t start_addr, size_t size);
+                                    size_t offset, size_t size);
 
 /**
  * @brief Configure MMU to map partition into data memory

+ 6 - 7
components/spi_flash/partition.c

@@ -387,27 +387,26 @@ esp_err_t esp_partition_write(const esp_partition_t* partition,
 }
 
 esp_err_t esp_partition_erase_range(const esp_partition_t* partition,
-                                    size_t start_addr, size_t size)
+                                    size_t offset, size_t size)
 {
     assert(partition != NULL);
-    if (start_addr > partition->size) {
+    if (offset > partition->size) {
         return ESP_ERR_INVALID_ARG;
     }
-    if (start_addr + size > partition->size) {
+    if (offset + size > partition->size) {
         return ESP_ERR_INVALID_SIZE;
     }
     if (size % SPI_FLASH_SEC_SIZE != 0) {
         return ESP_ERR_INVALID_SIZE;
     }
-    if (start_addr % SPI_FLASH_SEC_SIZE != 0) {
+    if (offset % SPI_FLASH_SEC_SIZE != 0) {
         return ESP_ERR_INVALID_ARG;
     }
 #ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
-    return esp_flash_erase_region(partition->flash_chip, partition->address + start_addr, size);
+    return esp_flash_erase_region(partition->flash_chip, partition->address + offset, size);
 #else
-    return spi_flash_erase_range(partition->address + start_addr, size);
+    return spi_flash_erase_range(partition->address + offset, size);
 #endif // CONFIG_SPI_FLASH_USE_LEGACY_IMPL
-
 }
 
 /*