Skip to content

Commit

Permalink
drivers/mtd: move write_size assertion after init call
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian18 committed May 23, 2022
1 parent bbf0b3a commit 477a860
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/mtd/mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ int mtd_init(mtd_dev_t *mtd)

int res = -ENOTSUP;

if (mtd->driver->init) {
res = mtd->driver->init(mtd);
}

/* Drivers preceding the introduction of write_size need to set it. While
* this assert breaks applications that previously worked, it is likely
* that these applications silently assumed a certain write size and would
Expand All @@ -45,10 +49,6 @@ int mtd_init(mtd_dev_t *mtd)
* writes. */
assert(mtd->write_size != 0);

if (mtd->driver->init) {
res = mtd->driver->init(mtd);
}

#ifdef MODULE_MTD_WRITE_PAGE
if ((mtd->driver->flags & MTD_DRIVER_FLAG_DIRECT_WRITE) == 0) {
mtd->work_area = malloc(mtd->pages_per_sector * mtd->page_size);
Expand Down

0 comments on commit 477a860

Please sign in to comment.