drivers: flash: stm32l5: use write-block-size when validating
STM32L5 have a write block size of 8, but STM32U5 and STM32H5 have a write block size of 16. Use write-block-size from the device tree instead of hardcoding this value when validating the range of write operations. Fixes #60724 Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
This commit is contained in:
parent
96768ea2d2
commit
199486546a
2 changed files with 11 additions and 3 deletions
|
@ -257,6 +257,12 @@ static inline bool flash_stm32_range_exists(const struct device *dev,
|
|||
}
|
||||
#endif /* CONFIG_FLASH_PAGE_LAYOUT */
|
||||
|
||||
static inline bool flash_stm32_valid_write(off_t offset, uint32_t len)
|
||||
{
|
||||
return ((offset % FLASH_STM32_WRITE_BLOCK_SIZE == 0) &&
|
||||
(len % FLASH_STM32_WRITE_BLOCK_SIZE == 0U));
|
||||
}
|
||||
|
||||
bool flash_stm32_valid_range(const struct device *dev, off_t offset,
|
||||
uint32_t len, bool write);
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ static int icache_wait_for_invalidate_complete(void)
|
|||
#endif /* CONFIG_SOC_SERIES_STM32H5X */
|
||||
|
||||
/*
|
||||
* offset and len must be aligned on 8 for write,
|
||||
* offset and len must be aligned on write-block-size for write,
|
||||
* positive and not beyond end of flash
|
||||
*/
|
||||
bool flash_stm32_valid_range(const struct device *dev, off_t offset,
|
||||
|
@ -149,8 +149,10 @@ bool flash_stm32_valid_range(const struct device *dev, off_t offset,
|
|||
}
|
||||
}
|
||||
|
||||
return (!write || (offset % 8 == 0 && len % 8 == 0U)) &&
|
||||
flash_stm32_range_exists(dev, offset, len);
|
||||
if (write && !flash_stm32_valid_write(offset, len)) {
|
||||
return false;
|
||||
}
|
||||
return flash_stm32_range_exists(dev, offset, len);
|
||||
}
|
||||
|
||||
static int write_dword(const struct device *dev, off_t offset, uint64_t val)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue