]> granicus.if.org Git - esp-idf/commitdiff
spi_flash: remove unnecessary src pointer alignment check in spi_flash_write
authorIvan Grokhotkov <ivan@espressif.com>
Mon, 31 Oct 2016 11:08:56 +0000 (19:08 +0800)
committerIvan Grokhotkov <ivan@espressif.com>
Mon, 31 Oct 2016 11:08:56 +0000 (19:08 +0800)
ROM SPIWrite routine can work with unaligned sources, so this check is unnecessary.
Furthermore, it breaks nvs_set_str and nvs_get_blob when data pointer is unaligned.
Also fix stray backslash in COUNTER_STOP macro

components/spi_flash/flash_ops.c
components/spi_flash/include/esp_spi_flash.h

index ae72568aa5509616ac1c488ac073b4ffd38b47b6..134e1fe65b65120b4b4027e015d9180af5e75e88 100644 (file)
@@ -39,7 +39,7 @@ static spi_flash_counters_t s_flash_stats;
 #define COUNTER_STOP(counter)  \
     do{ \
         s_flash_stats.counter.count++; \
-        s_flash_stats.counter.time += (xthal_get_ccount() - ts_begin) / (XT_CLOCK_FREQ / 1000000); \\
+        s_flash_stats.counter.time += (xthal_get_ccount() - ts_begin) / (XT_CLOCK_FREQ / 1000000); \
     } while(0)
 
 #define COUNTER_ADD_BYTES(counter, size) \
@@ -126,10 +126,6 @@ esp_err_t IRAM_ATTR spi_flash_erase_range(uint32_t start_addr, uint32_t size)
 
 esp_err_t IRAM_ATTR spi_flash_write(size_t dest_addr, const void *src, size_t size)
 {
-    // TODO: replace this check with code which deals with unaligned sources
-    if (((ptrdiff_t) src) % 4 != 0) {
-        return ESP_ERR_INVALID_ARG;
-    }
     // Destination alignment is also checked in ROM code, but we can give
     // better error code here
     // TODO: add handling of unaligned destinations
index c65eaa58368f452b15794b4779f47bf2c37269a7..840bbc49712ad79b71f06c24877134af6f978084 100644 (file)
@@ -74,7 +74,7 @@ esp_err_t spi_flash_erase_range(size_t start_addr, size_t size);
 /**
  * @brief  Write data to Flash.
  *
- * @note Both des_addr and src_addr have to be 4-byte aligned.
+ * @note Address in flash, dest, has to be 4-byte aligned.
  *       This is a temporary limitation which will be removed.
  *
  * @param  dest  destination address in Flash
@@ -88,7 +88,7 @@ esp_err_t spi_flash_write(size_t dest, const void *src, size_t size);
 /**
  * @brief  Read data from Flash.
  *
- * @note Both des_addr and src_addr have to be 4-byte aligned.
+ * @note Both src and dest have to be 4-byte aligned.
  *       This is a temporary limitation which will be removed.
  *
  * @param  src   source address of the data in Flash.