Skip to content

Commit

Permalink
fixup! fixup! fixup! drivers/mtd_flashpage: implement pagewise API
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Feb 9, 2023
1 parent a6447c4 commit 6c78cc4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/include/mtd_flashpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ extern "C"
.sector_count = FLASHPAGE_NUMOF, \
.pages_per_sector = _pages_per_sector, \
.page_size = FLASHPAGE_SIZE / _pages_per_sector, \
.write_size = FLASHPAGE_WRITE_BLOCK_SIZE >= FLASHPAGE_WRITE_BLOCK_ALIGNMENT \
? FLASHPAGE_WRITE_BLOCK_SIZE \
: FLASHPAGE_WRITE_BLOCK_ALIGNMENT, \
.write_size = 1 \
}, \
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/mtd_flashpage/mtd_flashpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ static int _read_page(mtd_dev_t *dev, void *buf, uint32_t page,
mtd_flashpage_t *super = container_of(dev, mtd_flashpage_t, base);

page += super->offset;

/* mtd flashpage maps multiple pages to one virtual sector for unknown reason */
uintptr_t addr = (uintptr_t)flashpage_addr(page / dev->pages_per_sector) + offset;

DEBUG("flashpage: read %"PRIu32" bytes from %p to %p\n", size, (void *)addr, buf);
Expand Down

0 comments on commit 6c78cc4

Please sign in to comment.