Skip to content

Commit

Permalink
drivers/mtd_mapper: Add write_size
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Feb 26, 2022
1 parent c3e08a3 commit 84c3c07
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/include/mtd_mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* .sector_count = SECTOR_COUNT / 2,
* .pages_per_sector = PAGE_PER_SECTOR,
* .page_size = PAGE_SIZE,
* .write_size = WRITE_SIZE,
* },
* .parent = &parent,
* .sector = SECTOR_COUNT / 2
Expand Down
1 change: 1 addition & 0 deletions drivers/mtd_mapper/mtd_mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static int _init(mtd_dev_t *mtd)
assert(backing_mtd->page_size == region->mtd.page_size);
assert(backing_mtd->pages_per_sector == region->mtd.pages_per_sector);
assert(backing_mtd->sector_count >= region->mtd.sector_count);
assert(backing_mtd->write_size == region->mtd.write_size);

/* offset + region size must not exceed the backing device */
assert(region->sector + region->mtd.sector_count <= backing_mtd->sector_count);
Expand Down
6 changes: 6 additions & 0 deletions tests/mtd_mapper/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#ifndef PAGE_SIZE
#define PAGE_SIZE 64
#endif
#ifndef WRITE_SIZE
#define WRITE_SIZE 4
#endif

#define MEMORY_SIZE PAGE_SIZE * PAGE_PER_SECTOR * SECTOR_COUNT

Expand Down Expand Up @@ -176,6 +179,7 @@ static mtd_dev_t dev = {
.sector_count = SECTOR_COUNT,
.pages_per_sector = PAGE_PER_SECTOR,
.page_size = PAGE_SIZE,
.write_size = WRITE_SIZE,
};

static mtd_mapper_parent_t _parent = MTD_PARENT_INIT(&dev);
Expand All @@ -186,6 +190,7 @@ static mtd_mapper_region_t _region_a = {
.sector_count = SECTOR_COUNT / 2,
.pages_per_sector = PAGE_PER_SECTOR,
.page_size = PAGE_SIZE,
.write_size = WRITE_SIZE,
},
.parent = &_parent,
.sector = 0,
Expand All @@ -197,6 +202,7 @@ static mtd_mapper_region_t _region_b = {
.sector_count = SECTOR_COUNT / 2,
.pages_per_sector = PAGE_PER_SECTOR,
.page_size = PAGE_SIZE,
.write_size = WRITE_SIZE,
},
.parent = &_parent,
.sector = SECTOR_COUNT / 2,
Expand Down

0 comments on commit 84c3c07

Please sign in to comment.