Skip to content

Commit 4c6b097

Browse files
niedzwiecki-dawidkartben
authored andcommitted
drivers: flash: stm32h7: change place of memory barrier
Move the memory barrier to a function that commits option bytes. This way the barrier doesn't have to be added before every call of the commit_optb function. Signed-off-by: Dawid Niedzwiecki <[email protected]>
1 parent 52f45b9 commit 4c6b097

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/flash/flash_stm32h7x.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ static __unused int commit_optb(const struct device *dev)
6969
FLASH_TypeDef *regs = FLASH_STM32_REGS(dev);
7070
int64_t timeout_time = k_uptime_get() + STM32H7_FLASH_OPT_TIMEOUT_MS;
7171

72+
/* Make sure previous write is completed before committing option bytes. */
73+
barrier_dsync_fence_full();
7274
regs->OPTCR |= FLASH_OPTCR_OPTSTART;
7375
barrier_dsync_fence_full();
7476
while (regs->OPTSR_CUR & FLASH_OPTSR_OPT_BUSY) {
@@ -109,8 +111,6 @@ static __unused int write_opt(const struct device *dev, uint32_t mask, uint32_t
109111
sys_write32((sys_read32(cur) & ~mask) | value, prg);
110112

111113
if (commit) {
112-
/* Make sure previous write is completed before committing option bytes. */
113-
barrier_dsync_fence_full();
114114
rc = commit_optb(dev);
115115
if (rc < 0) {
116116
return rc;

0 commit comments

Comments
 (0)