/* For more information, see the application note below on Read-While-Write  */
static int flash_mcux_erase(const struct device *dev, off_t offset, size_t len)
/* For more information, see the application note below on Read-While-Write  */
static int flash_mcux_erase(const struct device *dev, off_t offset, size_t len)
{
	struct flash_priv *priv = dev->data;
	uint32_t addr;
	status_t rc;
	unsigned int key;
	if (k_sem_take(&priv->write_lock, K_FOREVER)) {
		return -EACCES;
	}
	addr = offset + priv->pflash_block_base;
	key = irq_lock();
	rc = FLASH_Erase(&priv->config, addr, len, kFLASH_ApiEraseKey);
	irq_unlock(key);
	k_sem_give(&priv->write_lock);
	return (rc == kStatus_Success) ? 0 : -EINVAL;
}