target_flash: swap while for forloop in buffered flush

This commit is contained in:
Rafael Silva 2022-08-24 12:58:10 +01:00 committed by Rachel Mant
parent 1a1f4b76ff
commit deb6198921
1 changed files with 2 additions and 7 deletions

View File

@ -266,13 +266,8 @@ static bool flash_buffered_flush(target_flash_s *f)
const uint8_t *src = f->buf + (aligned_addr - f->buf_addr_base); const uint8_t *src = f->buf + (aligned_addr - f->buf_addr_base);
uint32_t len = f->buf_addr_high - aligned_addr; uint32_t len = f->buf_addr_high - aligned_addr;
while (len) { for (size_t offset = 0; offset < len; offset += f->writesize)
ret &= f->write(f, aligned_addr, src, f->writesize) == 0; ret &= f->write(f, aligned_addr + offset, src + offset, f->writesize) == 0;
aligned_addr += f->writesize;
src += f->writesize;
len -= MIN(len, f->writesize);
}
f->buf_addr_base = UINT32_MAX; f->buf_addr_base = UINT32_MAX;
f->buf_addr_low = UINT32_MAX; f->buf_addr_low = UINT32_MAX;