/* 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, uint32_t len, bool 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, uint32_t len, bool write)
{
	if (stm32_flash_has_2_banks(dev) &&
			(CONFIG_FLASH_SIZE < STM32_SERIES_MAX_FLASH)) {
		if ((offset < BANK2_OFFSET) &&
					(offset + len > FLASH_SIZE / 2)) {
			return 0;
		}
	}
	if (write && !flash_stm32_valid_write(offset, len)) {
		return false;
	}
	return flash_stm32_range_exists(dev, offset, len);
}