drivers: flash: esp32: correct return values

The esp_flash*() functions don't return
negative errno codes, so it's return value
should not be used for the flash api functions.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
This commit is contained in:
Fin Maaß 2024-04-26 17:26:22 +02:00 committed by Alberto Escolar
parent 55154e226c
commit 6801ec0e30

View file

@ -80,7 +80,11 @@ static int flash_esp32_read(const struct device *dev, off_t address, void *buffe
ret = esp_flash_read_encrypted(NULL, address, buffer, length); ret = esp_flash_read_encrypted(NULL, address, buffer, length);
} }
flash_esp32_sem_give(dev); flash_esp32_sem_give(dev);
return ret; if (ret != 0) {
LOG_ERR("esp_flash_read failed %d", ret);
return -EIO;
}
return 0;
} }
static int flash_esp32_write(const struct device *dev, static int flash_esp32_write(const struct device *dev,
@ -97,7 +101,12 @@ static int flash_esp32_write(const struct device *dev,
ret = esp_flash_write_encrypted(NULL, address, buffer, length); ret = esp_flash_write_encrypted(NULL, address, buffer, length);
} }
flash_esp32_sem_give(dev); flash_esp32_sem_give(dev);
return ret;
if (ret != 0) {
LOG_ERR("esp_flash_write failed %d", ret);
return -EIO;
}
return 0;
} }
static int flash_esp32_erase(const struct device *dev, off_t start, size_t len) static int flash_esp32_erase(const struct device *dev, off_t start, size_t len)
@ -105,7 +114,11 @@ static int flash_esp32_erase(const struct device *dev, off_t start, size_t len)
flash_esp32_sem_take(dev); flash_esp32_sem_take(dev);
int ret = esp_flash_erase_region(NULL, start, len); int ret = esp_flash_erase_region(NULL, start, len);
flash_esp32_sem_give(dev); flash_esp32_sem_give(dev);
return ret; if (ret != 0) {
LOG_ERR("esp_flash_erase_region failed %d", ret);
return -EIO;
}
return 0;
} }
#if CONFIG_FLASH_PAGE_LAYOUT #if CONFIG_FLASH_PAGE_LAYOUT