From 52ea93ef03f949c184fa155db986734779af22af Mon Sep 17 00:00:00 2001 From: chrysn Date: Sat, 26 Feb 2022 23:58:25 +0100 Subject: [PATCH] drivers/mtd_mapper: Add write_size --- drivers/include/mtd_mapper.h | 1 + drivers/mtd_mapper/mtd_mapper.c | 1 + tests/mtd_mapper/main.c | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/drivers/include/mtd_mapper.h b/drivers/include/mtd_mapper.h index 9f2ddbc32d..025ea95dc8 100644 --- a/drivers/include/mtd_mapper.h +++ b/drivers/include/mtd_mapper.h @@ -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 diff --git a/drivers/mtd_mapper/mtd_mapper.c b/drivers/mtd_mapper/mtd_mapper.c index 8f392d222f..593a74edaa 100644 --- a/drivers/mtd_mapper/mtd_mapper.c +++ b/drivers/mtd_mapper/mtd_mapper.c @@ -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); diff --git a/tests/mtd_mapper/main.c b/tests/mtd_mapper/main.c index 00b8ee71ed..a07c15b78e 100644 --- a/tests/mtd_mapper/main.c +++ b/tests/mtd_mapper/main.c @@ -37,6 +37,9 @@ #ifndef PAGE_SIZE #define PAGE_SIZE 64 #endif +#ifndef WRITE_SIZE +#define WRITE_SIZE 4 +#endif #define MEMORY_PAGE_COUNT PAGE_PER_SECTOR * SECTOR_COUNT @@ -180,6 +183,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); @@ -190,6 +194,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, @@ -201,6 +206,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,