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:
parent
c337b9f80b
commit
e245a213df
1 changed files with 3 additions and 9 deletions
|
@ -287,17 +287,11 @@ int flash_stm32_block_erase_loop(const struct device *dev,
|
||||||
return rc;
|
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;
|
int64_t timeout_time = k_uptime_get() + 100;
|
||||||
struct flash_stm32_sector_t sector = get_sector(dev, offset);
|
|
||||||
|
|
||||||
if (sector.bank == 0) {
|
while (*(sector->sr) & FLASH_SR_QW) {
|
||||||
LOG_ERR("Offset %ld does not exist", (long) offset);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (*(sector.sr) & FLASH_SR_QW) {
|
|
||||||
if (k_uptime_get() > timeout_time) {
|
if (k_uptime_get() > timeout_time) {
|
||||||
LOG_ERR("Timeout! val: %d", 100);
|
LOG_ERR("Timeout! val: %d", 100);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
@ -353,7 +347,7 @@ static int write_ndwords(const struct device *dev,
|
||||||
/* Flush the data write */
|
/* Flush the data write */
|
||||||
__DSB();
|
__DSB();
|
||||||
|
|
||||||
wait_write_queue(dev, offset);
|
wait_write_queue(§or);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait until the BSY bit is cleared */
|
/* Wait until the BSY bit is cleared */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue