drivers: flash: stm32h7x: simplify wait_write_queue()

wait_write_queue() get passed a device and an offset to compute the
sector number and verify it is valid. However both operations are
already done by the caller, so let's pass directly the
flash_stm32_sector_t value instead.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
Aurelien Jarno 2022-06-17 22:19:16 +02:00 committed by Anas Nashif
commit e245a213df

View file

@ -287,17 +287,11 @@ int flash_stm32_block_erase_loop(const struct device *dev,
return rc;
}
static int wait_write_queue(const struct device *dev, off_t offset)
static int wait_write_queue(const struct flash_stm32_sector_t *sector)
{
int64_t timeout_time = k_uptime_get() + 100;
struct flash_stm32_sector_t sector = get_sector(dev, offset);
if (sector.bank == 0) {
LOG_ERR("Offset %ld does not exist", (long) offset);
return -EINVAL;
}
while (*(sector.sr) & FLASH_SR_QW) {
while (*(sector->sr) & FLASH_SR_QW) {
if (k_uptime_get() > timeout_time) {
LOG_ERR("Timeout! val: %d", 100);
return -EIO;
@ -353,7 +347,7 @@ static int write_ndwords(const struct device *dev,
/* Flush the data write */
__DSB();
wait_write_queue(dev, offset);
wait_write_queue(&sector);
}
/* Wait until the BSY bit is cleared */