From 06ec032c0caf0f09d61845691f9de1dacbda1427 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 17 Dec 2020 10:28:03 +1100 Subject: [PATCH] spi_flash: Simplify init-time size check --- components/spi_flash/esp_flash_spi_init.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/spi_flash/esp_flash_spi_init.c b/components/spi_flash/esp_flash_spi_init.c index 64cef8c75e..d362b7b354 100644 --- a/components/spi_flash/esp_flash_spi_init.c +++ b/components/spi_flash/esp_flash_spi_init.c @@ -261,13 +261,13 @@ esp_err_t esp_flash_init_default_chip(void) if (default_chip.size < legacy_chip->chip_size) { ESP_EARLY_LOGE(TAG, "Detected size(%dk) smaller than the size in the binary image header(%dk). Probe failed.", default_chip.size/1024, legacy_chip->chip_size/1024); return ESP_ERR_FLASH_SIZE_NOT_MATCH; - } else if (default_chip.size > legacy_chip->chip_size) { - ESP_EARLY_LOGW(TAG, "Detected size(%dk) larger than the size in the binary image header(%dk). Using the size in the binary image header.", default_chip.size/1024, legacy_chip->chip_size/1024); - default_chip.size = legacy_chip->chip_size; - } else { - default_chip.size = legacy_chip->chip_size; } + if (default_chip.size > legacy_chip->chip_size) { + ESP_EARLY_LOGW(TAG, "Detected size(%dk) larger than the size in the binary image header(%dk). Using the size in the binary image header.", default_chip.size/1024, legacy_chip->chip_size/1024); + } + default_chip.size = legacy_chip->chip_size; + esp_flash_default_chip = &default_chip; return ESP_OK; }