From 477a86022f6b58acaaca6884e6c80a77bdc2e7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20H=C3=BC=C3=9Fler?= Date: Mon, 23 May 2022 19:46:46 +0200 Subject: [PATCH] drivers/mtd: move write_size assertion after init call --- drivers/mtd/mtd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/mtd.c b/drivers/mtd/mtd.c index 53c0f897e219..8d0d599d5a46 100644 --- a/drivers/mtd/mtd.c +++ b/drivers/mtd/mtd.c @@ -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 @@ -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);