Skip to content

Commit e245a21

Browse files
aurel32nashif
authored andcommitted
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>
1 parent c337b9f commit e245a21

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

drivers/flash/flash_stm32h7x.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,11 @@ int flash_stm32_block_erase_loop(const struct device *dev,
287287
return rc;
288288
}
289289

290-
static int wait_write_queue(const struct device *dev, off_t offset)
290+
static int wait_write_queue(const struct flash_stm32_sector_t *sector)
291291
{
292292
int64_t timeout_time = k_uptime_get() + 100;
293-
struct flash_stm32_sector_t sector = get_sector(dev, offset);
294-
295-
if (sector.bank == 0) {
296-
LOG_ERR("Offset %ld does not exist", (long) offset);
297-
return -EINVAL;
298-
}
299293

300-
while (*(sector.sr) & FLASH_SR_QW) {
294+
while (*(sector->sr) & FLASH_SR_QW) {
301295
if (k_uptime_get() > timeout_time) {
302296
LOG_ERR("Timeout! val: %d", 100);
303297
return -EIO;
@@ -353,7 +347,7 @@ static int write_ndwords(const struct device *dev,
353347
/* Flush the data write */
354348
__DSB();
355349

356-
wait_write_queue(dev, offset);
350+
wait_write_queue(&sector);
357351
}
358352

359353
/* Wait until the BSY bit is cleared */

0 commit comments

Comments
 (0)