drivers: flash: stm32: fix flash write error handling

The stm32 flash driver returns success even though
writing failed when instruction cache was enabled.
Fix by not overriding error code when re-enabling
instruction cache.

Signed-off-by: Riku Karjalainen <riku.karjalainen@vaisala.com>
This commit is contained in:
Riku Karjalainen 2024-06-11 16:14:49 +03:00 committed by Alberto Escolar
parent d45605e6a3
commit ff0635d700
2 changed files with 14 additions and 2 deletions

View file

@ -367,10 +367,16 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset,
}
if (icache_enabled) {
int rc2;
/* Since i-cache was disabled, this would start the
* invalidation procedure, so wait for completion.
*/
rc = icache_wait_for_invalidate_complete();
rc2 = icache_wait_for_invalidate_complete();
if (!rc) {
rc = rc2;
}
/* I-cache should be enabled only after the
* invalidation is complete.

View file

@ -262,10 +262,16 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset,
}
if (icache_enabled) {
int rc2;
/* Since i-cache was disabled, this would start the
* invalidation procedure, so wait for completion.
*/
rc = icache_wait_for_invalidate_complete();
rc2 = icache_wait_for_invalidate_complete();
if (!rc) {
rc = rc2;
}
/* I-cache should be enabled only after the
* invalidation is complete.