drivers: flash: stm32 ospi driver align erase on sector size

When erasing the flash, the size to erase must be
compared to a multiple of SECTOR_SIZE.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
Francois Ramu 2022-06-28 15:34:10 +02:00 committed by Carles Cufí
commit 80dd57a49d

View file

@ -723,7 +723,7 @@ static int flash_stm32_ospi_erase(const struct device *dev, off_t addr,
return -EINVAL; return -EINVAL;
} }
if ((size != SPI_NOR_SECTOR_SIZE) && (size < dev_cfg->flash_size)) { if (((size % SPI_NOR_SECTOR_SIZE) != 0) && (size < dev_cfg->flash_size)) {
LOG_ERR("Error: wrong sector size 0x%x", size); LOG_ERR("Error: wrong sector size 0x%x", size);
return -ENOTSUP; return -ENOTSUP;
} }