Skip to content

Commit

Permalink
Merge pull request #20173 from fabian18/pr/mtd_flashpage_improve_writ…
Browse files Browse the repository at this point in the history
…e_page

drivers/mtd_flashpage: improve _write_page
  • Loading branch information
benpicco authored Jan 2, 2024
2 parents cf3ce54 + 37c39d0 commit ece8a12
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/mtd_flashpage/mtd_flashpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ static int _write_page(mtd_dev_t *dev, const void *buf, uint32_t page, uint32_t
__attribute__ ((aligned (FLASHPAGE_WRITE_BLOCK_ALIGNMENT)));

offset = addr % FLASHPAGE_WRITE_BLOCK_ALIGNMENT;
size = MIN(size, FLASHPAGE_WRITE_BLOCK_ALIGNMENT - offset);
size = MIN(size, FLASHPAGE_WRITE_BLOCK_SIZE - offset);

DEBUG("flashpage: write %"PRIu32" unaligned bytes\n", size);
DEBUG("flashpage: write %"PRIu32" at %p - ""%"PRIu32"\n", size, (void *)addr, offset);

memcpy(&tmp[0], (uint8_t *)addr - offset, sizeof(tmp));
memcpy(&tmp[offset], buf, size);
Expand Down

0 comments on commit ece8a12

Please sign in to comment.