1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-22 13:03:54 +01:00

Merge pull request #18128 from fabian18/drivers_mtd_assert_write_size_after_init

drivers/mtd: move write_size assertion after init call
This commit is contained in:
benpicco 2022-05-24 10:25:55 +02:00 committed by GitHub
commit c1b152ab39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,6 +36,10 @@ int mtd_init(mtd_dev_t *mtd)
int res = -ENOTSUP; int res = -ENOTSUP;
if (mtd->driver->init) {
res = mtd->driver->init(mtd);
}
/* Drivers preceding the introduction of write_size need to set it. While /* Drivers preceding the introduction of write_size need to set it. While
* this assert breaks applications that previously worked, it is likely * this assert breaks applications that previously worked, it is likely
* that these applications silently assumed a certain write size and would * that these applications silently assumed a certain write size and would
@ -45,10 +49,6 @@ int mtd_init(mtd_dev_t *mtd)
* writes. */ * writes. */
assert(mtd->write_size != 0); assert(mtd->write_size != 0);
if (mtd->driver->init) {
res = mtd->driver->init(mtd);
}
#ifdef MODULE_MTD_WRITE_PAGE #ifdef MODULE_MTD_WRITE_PAGE
if ((mtd->driver->flags & MTD_DRIVER_FLAG_DIRECT_WRITE) == 0) { if ((mtd->driver->flags & MTD_DRIVER_FLAG_DIRECT_WRITE) == 0) {
mtd->work_area = malloc(mtd->pages_per_sector * mtd->page_size); mtd->work_area = malloc(mtd->pages_per_sector * mtd->page_size);