This is an automated email from the ASF dual-hosted git repository. fdcavalcanti pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push: new db54331479 drivers/fs:Always use register_mtddriver() to register the MTD device (patch2) db54331479 is described below commit db543314794d9c968350a557691356489a76d877 Author: jingfei <jing...@xiaomi.com> AuthorDate: Fri Jul 18 00:42:09 2025 +0800 drivers/fs:Always use register_mtddriver() to register the MTD device (patch2) This is a supplement to the patch:1936126210a56b6d1b033d6d940669413dd6e1b0 Due to the automatic wrapping of MTD devices during the open() process, the legacy registration methods ftl_initialize() and bchdev_register() are no longer required for MTD device registration for user code. So we have adjusted the registration method for MTD devices in nuttx/boards, replacing the previous approach using ftl_initialize() with register_mtddriver(). --- boards/arm/at32/at32f437-mini/src/at32_at24.c | 11 ++++++----- boards/arm/at32/at32f437-mini/src/at32_w25.c | 11 +++++++---- boards/arm/cxd56xx/common/src/cxd56_flash.c | 9 ++++++--- boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_gd25.c | 13 +++++++------ boards/arm/gd32f4/gd32f470ik-eval/src/gd32f4xx_gd25.c | 13 +++++++------ boards/arm/gd32f4/gd32f470zk-aiotbox/src/gd32f4xx_gd25.c | 13 +++++++------ boards/arm/gd32f4/gd32f470zk-eval/src/gd32f4xx_gd25.c | 13 +++++++------ boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c | 9 ++++++--- boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c | 9 ++++++--- boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c | 9 ++++++--- boards/arm/sam34/sam4e-ek/src/sam_at25.c | 12 ++++++------ boards/arm/sam34/sam4s-xplained-pro/src/sam_nandflash.c | 9 ++++++--- boards/arm/sama5/jupiter-nano/src/sam_at25.c | 10 ++++++---- boards/arm/sama5/jupiter-nano/src/sam_nandflash.c | 9 ++++++--- boards/arm/sama5/sama5d2-xult/src/sam_at25.c | 10 ++++++---- boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c | 9 ++++++--- boards/arm/sama5/sama5d3-xplained/src/sam_at25.c | 10 ++++++---- boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c | 9 ++++++--- boards/arm/sama5/sama5d3x-ek/src/sam_at24.c | 11 ++++++----- boards/arm/sama5/sama5d3x-ek/src/sam_at25.c | 11 ++++++----- boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c | 9 ++++++--- boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c | 9 ++++++--- boards/arm/samd5e5/metro-m4/src/sam_at24.c | 13 ++++++------- boards/arm/stm32/cloudctrl/src/stm32_w25.c | 9 ++++++--- boards/arm/stm32/fire-stm32v2/src/stm32_w25.c | 9 ++++++--- boards/arm/stm32/shenzhou/src/stm32_w25.c | 9 ++++++--- boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c | 11 ++++++----- boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c | 10 +++++++--- boards/arm/stm32/stm32f411-minimum/src/stm32_w25.c | 10 +++++++--- boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_boot.c | 5 +++-- boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_flash.c | 12 ++++++++---- boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c | 11 +++++++---- boards/mips/pic32mx/mirtoo/src/pic32_appinit.c | 9 ++++++--- boards/risc-v/esp32c3/common/src/esp_board_spiflash.c | 7 +++---- boards/risc-v/esp32c6/common/src/esp_board_spiflash.c | 7 +++---- boards/risc-v/esp32h2/common/src/esp_board_spiflash.c | 7 +++---- boards/xtensa/esp32/common/src/esp32_board_spiflash.c | 12 ++++++++---- boards/xtensa/esp32s2/common/src/esp32s2_board_spiflash.c | 8 ++++---- boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c | 8 ++++---- 39 files changed, 230 insertions(+), 155 deletions(-) diff --git a/boards/arm/at32/at32f437-mini/src/at32_at24.c b/boards/arm/at32/at32f437-mini/src/at32_at24.c index fab6b34d2d..3357e4bbe6 100644 --- a/boards/arm/at32/at32f437-mini/src/at32_at24.c +++ b/boards/arm/at32/at32f437-mini/src/at32_at24.c @@ -108,14 +108,15 @@ int at32_at24_automount(int minor) return ret; } #else - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - finfo("Initialize the FTL layer to create /dev/mtdblock%d\n", - AT24_MINOR); - ret = ftl_initialize(AT24_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", AT24_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } #endif diff --git a/boards/arm/at32/at32f437-mini/src/at32_w25.c b/boards/arm/at32/at32f437-mini/src/at32_w25.c index faede33a5b..7c3a696cd2 100644 --- a/boards/arm/at32/at32f437-mini/src/at32_w25.c +++ b/boards/arm/at32/at32f437-mini/src/at32_w25.c @@ -78,7 +78,7 @@ #define FLASH_PART_NAMES "w25qxx" -#define FLASH_PART 1 +#define FLASH_PART 1 #define FLASH_PART_LIST "4096, 4096, 4096" @@ -126,12 +126,15 @@ int at32_w25initialize(int minor) } #ifndef CONFIG_FS_SMARTFS - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Initialize the FTL layer\n"); + syslog(LOG_ERR, "ERROR: Failed to register the MTD driver %s ret %d\n", + path, ret); return ret; } #else diff --git a/boards/arm/cxd56xx/common/src/cxd56_flash.c b/boards/arm/cxd56xx/common/src/cxd56_flash.c index 124d134c97..650112e7d6 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_flash.c +++ b/boards/arm/cxd56xx/common/src/cxd56_flash.c @@ -64,6 +64,7 @@ int board_flash_initialize(void) { int ret; struct mtd_dev_s *mtd; + char path[32]; mtd = cxd56_sfc_initialize(); if (!mtd) @@ -72,12 +73,14 @@ int board_flash_initialize(void) return -ENODEV; } - /* use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(CONFIG_SFC_DEVNO, mtd); + snprintf(path, sizeof(path), "/dev/mtdblock%d", CONFIG_SFC_DEVNO); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Initializing the FTL layer: %d\n", ret); + ferr("ERROR: Register the MTD driver %s ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_gd25.c b/boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_gd25.c index 5c8cafb5b0..0039fd5a34 100644 --- a/boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_gd25.c +++ b/boards/arm/gd32f4/gd32f450zk-eval/src/gd32f4xx_gd25.c @@ -90,15 +90,16 @@ int gd32_gd25_automount(int minor) } #if defined(CONFIG_GD32F450ZK_EVAL_GD25_FTL) - /* And finally, use the FTL layer to wrap the MTD driver as a block - * driver at /dev/mtdblockN, where N=minor device number. - */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, + "ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/gd32f4/gd32f470ik-eval/src/gd32f4xx_gd25.c b/boards/arm/gd32f4/gd32f470ik-eval/src/gd32f4xx_gd25.c index d36d5b406c..c21594e238 100644 --- a/boards/arm/gd32f4/gd32f470ik-eval/src/gd32f4xx_gd25.c +++ b/boards/arm/gd32f4/gd32f470ik-eval/src/gd32f4xx_gd25.c @@ -90,15 +90,16 @@ int gd32_gd25_automount(int minor) } #if defined(CONFIG_GD32F470ZK_EVAL_GD25_FTL) - /* And finally, use the FTL layer to wrap the MTD driver as a block - * driver at /dev/mtdblockN, where N=minor device number. - */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, + "ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/gd32f4/gd32f470zk-aiotbox/src/gd32f4xx_gd25.c b/boards/arm/gd32f4/gd32f470zk-aiotbox/src/gd32f4xx_gd25.c index a2324427f0..ac142f60da 100644 --- a/boards/arm/gd32f4/gd32f470zk-aiotbox/src/gd32f4xx_gd25.c +++ b/boards/arm/gd32f4/gd32f470zk-aiotbox/src/gd32f4xx_gd25.c @@ -90,15 +90,16 @@ int gd32_gd25_automount(int minor) } #if defined(CONFIG_GD32F470ZK_EVAL_GD25_FTL) - /* And finally, use the FTL layer to wrap the MTD driver as a block - * driver at /dev/mtdblockN, where N=minor device number. - */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, + "ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/gd32f4/gd32f470zk-eval/src/gd32f4xx_gd25.c b/boards/arm/gd32f4/gd32f470zk-eval/src/gd32f4xx_gd25.c index 2432dca1c8..e6ba06a097 100644 --- a/boards/arm/gd32f4/gd32f470zk-eval/src/gd32f4xx_gd25.c +++ b/boards/arm/gd32f4/gd32f470zk-eval/src/gd32f4xx_gd25.c @@ -90,15 +90,16 @@ int gd32_gd25_automount(int minor) } #if defined(CONFIG_GD32F470ZK_EVAL_GD25_FTL) - /* And finally, use the FTL layer to wrap the MTD driver as a block - * driver at /dev/mtdblockN, where N=minor device number. - */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, + "ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c b/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c index 7b70e2607a..3993589e60 100644 --- a/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c +++ b/boards/arm/lpc43xx/bambino-200e/src/lpc43_appinit.c @@ -91,12 +91,15 @@ static int nsh_spifi_initialize(void) } #ifndef CONFIG_SPFI_NXFFS - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(CONFIG_SPIFI_DEVNO, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", CONFIG_SPIFI_DEVNO); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Initializing the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } #else diff --git a/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c b/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c index 283375011f..834f9497fb 100644 --- a/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c +++ b/boards/arm/lpc43xx/lpc4330-xplorer/src/lpc43_appinit.c @@ -83,12 +83,15 @@ static int nsh_spifi_initialize(void) } #ifndef CONFIG_SPFI_NXFFS - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(CONFIG_SPIFI_DEVNO, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", CONFIG_SPIFI_DEVNO); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Initializing the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } #else diff --git a/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c b/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c index bac6ab6068..552dc5a341 100644 --- a/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c +++ b/boards/arm/lpc43xx/lpc4357-evb/src/lpc43_appinit.c @@ -83,12 +83,15 @@ static int nsh_spifi_initialize(void) } #ifndef CONFIG_SPFI_NXFFS - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(CONFIG_SPIFI_DEVNO, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", CONFIG_SPIFI_DEVNO); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Initializing the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } #else diff --git a/boards/arm/sam34/sam4e-ek/src/sam_at25.c b/boards/arm/sam34/sam4e-ek/src/sam_at25.c index fbba50b650..49e359df59 100644 --- a/boards/arm/sam34/sam4e-ek/src/sam_at25.c +++ b/boards/arm/sam34/sam4e-ek/src/sam_at25.c @@ -88,17 +88,17 @@ int sam_at25_automount(int minor) } #if defined(CONFIG_SAM4EEK_AT25_FTL) - /* And finally, use the FTL layer to wrap the MTD driver as a block - * driver at /dev/mtdblockN, where N=minor device number. - */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } - #elif defined(CONFIG_SAM4EEK_AT25_NXFFS) /* Initialize to provide NXFFS on the MTD interface */ diff --git a/boards/arm/sam34/sam4s-xplained-pro/src/sam_nandflash.c b/boards/arm/sam34/sam4s-xplained-pro/src/sam_nandflash.c index b358798894..f271ccd84b 100644 --- a/boards/arm/sam34/sam4s-xplained-pro/src/sam_nandflash.c +++ b/boards/arm/sam34/sam4s-xplained-pro/src/sam_nandflash.c @@ -202,13 +202,16 @@ int sam_nand_automount(int minor) } #if defined(CONFIG_SAM34_NAND_FTL) - /* Use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ int ret = OK; - ret = ftl_initialize(NAND_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", NAND_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/sama5/jupiter-nano/src/sam_at25.c b/boards/arm/sama5/jupiter-nano/src/sam_at25.c index 2e1e593372..b3b4ef980e 100644 --- a/boards/arm/sama5/jupiter-nano/src/sam_at25.c +++ b/boards/arm/sama5/jupiter-nano/src/sam_at25.c @@ -87,13 +87,15 @@ int sam_at25_automount(int minor) } #if defined(CONFIG_SAMA5D3XPLAINED_AT25_FTL) + /* Register the MTD driver */ - /* And use the FTL layer to wrap the MTD driver as a block driver */ - - ret = ftl_initialize(AT25_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", AT25_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/sama5/jupiter-nano/src/sam_nandflash.c b/boards/arm/sama5/jupiter-nano/src/sam_nandflash.c index 5fdd3b05ef..9202ecd4c5 100644 --- a/boards/arm/sama5/jupiter-nano/src/sam_nandflash.c +++ b/boards/arm/sama5/jupiter-nano/src/sam_nandflash.c @@ -172,12 +172,15 @@ int sam_nand_automount(int minor) } #if defined(CONFIG_SAMA5D3XPLAINED_NAND_FTL) - /* Use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(NAND_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", NAND_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_at25.c b/boards/arm/sama5/sama5d2-xult/src/sam_at25.c index 04ae74a24c..84e401e449 100644 --- a/boards/arm/sama5/sama5d2-xult/src/sam_at25.c +++ b/boards/arm/sama5/sama5d2-xult/src/sam_at25.c @@ -87,13 +87,15 @@ int sam_at25_automount(int minor) } #if defined(CONFIG_SAMA5D3XPLAINED_AT25_FTL) + /* Register the MTD driver */ - /* And use the FTL layer to wrap the MTD driver as a block driver */ - - ret = ftl_initialize(AT25_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", AT25_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c b/boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c index 8045f0db72..ce780327c3 100644 --- a/boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c +++ b/boards/arm/sama5/sama5d2-xult/src/sam_nandflash.c @@ -173,12 +173,15 @@ int sam_nand_automount(int minor) } #if defined(CONFIG_SAMA5D3XPLAINED_NAND_FTL) - /* Use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(NAND_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", NAND_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c b/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c index 7b1e106e6d..ce04bd8fd0 100644 --- a/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c +++ b/boards/arm/sama5/sama5d3-xplained/src/sam_at25.c @@ -87,13 +87,15 @@ int sam_at25_automount(int minor) } #if defined(CONFIG_SAMA5D3XPLAINED_AT25_FTL) + /* Register the MTD driver */ - /* And use the FTL layer to wrap the MTD driver as a block driver */ - - ret = ftl_initialize(AT25_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", AT25_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c b/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c index 16d11b48b0..733db1d51d 100644 --- a/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c +++ b/boards/arm/sama5/sama5d3-xplained/src/sam_nandflash.c @@ -173,12 +173,15 @@ int sam_nand_automount(int minor) } #if defined(CONFIG_SAMA5D3XPLAINED_NAND_FTL) - /* Use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(NAND_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", NAND_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c b/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c index 4c7233a9bc..3af7db9313 100644 --- a/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c +++ b/boards/arm/sama5/sama5d3x-ek/src/sam_at24.c @@ -108,14 +108,15 @@ int sam_at24_automount(int minor) } #if defined(CONFIG_SAMA5D3XEK_AT24_FTL) - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - finfo("Initialize the FTL layer to create /dev/mtdblock%d\n", - AT24_MINOR); - ret = ftl_initialize(AT24_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", AT24_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_at25.c b/boards/arm/sama5/sama5d3x-ek/src/sam_at25.c index a709ed98df..84d09a4443 100644 --- a/boards/arm/sama5/sama5d3x-ek/src/sam_at25.c +++ b/boards/arm/sama5/sama5d3x-ek/src/sam_at25.c @@ -88,14 +88,15 @@ int sam_at25_automount(int minor) } #if defined(CONFIG_SAMA5D3XEK_AT25_FTL) - /* And finally, use the FTL layer to wrap the MTD driver as a block - * driver - */ + /* Register the MTD driver */ - ret = ftl_initialize(AT25_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", AT25_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c b/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c index 404a487fc2..a8644578a0 100644 --- a/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c +++ b/boards/arm/sama5/sama5d3x-ek/src/sam_nandflash.c @@ -173,12 +173,15 @@ int sam_nand_automount(int minor) } #if defined(CONFIG_SAMA5D3XEK_NAND_FTL) - /* Use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(NAND_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", NAND_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c b/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c index 4dbd82b81b..2db177c3eb 100644 --- a/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c +++ b/boards/arm/sama5/sama5d4-ek/src/sam_nandflash.c @@ -173,12 +173,15 @@ int sam_nand_automount(int minor) } #if defined(CONFIG_SAMA5D4EK_NAND_FTL) - /* Use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(NAND_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", NAND_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/samd5e5/metro-m4/src/sam_at24.c b/boards/arm/samd5e5/metro-m4/src/sam_at24.c index 67fb348216..1bbfd1a934 100644 --- a/boards/arm/samd5e5/metro-m4/src/sam_at24.c +++ b/boards/arm/samd5e5/metro-m4/src/sam_at24.c @@ -80,16 +80,15 @@ int sam_at24_automount(int minor) } #if defined(CONFIG_METRO_M4_AT24_FTL) - /* And finally, use the FTL layer - * to wrap the MTD driver as a block driver - */ + /* Register the MTD driver */ - finfo("Initialize the FTL layer to create /dev/mtdblock%d\n", - AT24_MINOR); - ret = ftl_initialize(AT24_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", AT24_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/stm32/cloudctrl/src/stm32_w25.c b/boards/arm/stm32/cloudctrl/src/stm32_w25.c index 3cd9d4d3d3..bf424c7b7c 100644 --- a/boards/arm/stm32/cloudctrl/src/stm32_w25.c +++ b/boards/arm/stm32/cloudctrl/src/stm32_w25.c @@ -107,12 +107,15 @@ int stm32_w25initialize(int minor) } #ifndef CONFIG_FS_NXFFS - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Initialize the FTL layer\n"); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } #else diff --git a/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c b/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c index 183afbf4d5..d150a12177 100644 --- a/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c +++ b/boards/arm/stm32/fire-stm32v2/src/stm32_w25.c @@ -107,12 +107,15 @@ int stm32_w25initialize(int minor) } #ifndef CONFIG_FS_NXFFS - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Initialize the FTL layer\n"); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } #else diff --git a/boards/arm/stm32/shenzhou/src/stm32_w25.c b/boards/arm/stm32/shenzhou/src/stm32_w25.c index fec173eaaf..ed03562c1f 100644 --- a/boards/arm/stm32/shenzhou/src/stm32_w25.c +++ b/boards/arm/stm32/shenzhou/src/stm32_w25.c @@ -108,12 +108,15 @@ int stm32_w25initialize(int minor) } #ifndef CONFIG_FS_NXFFS - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Initialize the FTL layer\n"); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } #else diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c b/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c index c58861ab77..1a149080cc 100644 --- a/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c +++ b/boards/arm/stm32/stm32f103-minimum/src/stm32_at24.c @@ -90,14 +90,15 @@ int stm32_at24_automount(int minor) } #if defined(CONFIG_STM32F103MINIMUM_AT24_FTL) - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - finfo("Initialize the FTL layer to create /dev/mtdblock%d\n", - AT24_MINOR); - ret = ftl_initialize(AT24_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", AT24_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c b/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c index 6bfb628594..73d430e333 100644 --- a/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c +++ b/boards/arm/stm32/stm32f103-minimum/src/stm32_w25.c @@ -120,12 +120,16 @@ int stm32_w25initialize(int minor) } #ifndef CONFIG_FS_SMARTFS - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Initialize the FTL layer\n"); + syslog(LOG_ERR, + "ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } #else diff --git a/boards/arm/stm32/stm32f411-minimum/src/stm32_w25.c b/boards/arm/stm32/stm32f411-minimum/src/stm32_w25.c index 15df1373f8..1badb2784d 100644 --- a/boards/arm/stm32/stm32f411-minimum/src/stm32_w25.c +++ b/boards/arm/stm32/stm32f411-minimum/src/stm32_w25.c @@ -121,12 +121,16 @@ int stm32_w25initialize(int minor) } #ifndef CONFIG_FS_SMARTFS - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(minor, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Initialize the FTL layer\n"); + syslog(LOG_ERR, + "ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } #else diff --git a/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_boot.c b/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_boot.c index 893f10db3d..bb19991800 100644 --- a/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_boot.c +++ b/boards/arm/stm32f7/stm32f777zit6-meadow/src/stm32_boot.c @@ -144,10 +144,11 @@ void board_late_initialize(void) syslog(LOG_ERR, "ERROR: w25qxxxjv_initialize failed\n"); } - ret = ftl_initialize(0, mtd); + ret = register_mtddriver("/dev/mtdblock0", mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Initialize the FTL layer\n"); + syslog(LOG_ERR, "ERROR: Failed to register MTD /dev/mtdblock0: %d\n", + ret); } meminfo.flags = QSPIMEM_READ | QSPIMEM_QUADIO; diff --git a/boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_flash.c b/boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_flash.c index ea9656e623..591cc9c6c9 100644 --- a/boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_flash.c +++ b/boards/arm/stm32wl5/nucleo-wl55jc/src/stm32_flash.c @@ -182,6 +182,7 @@ int stm32wl5_flash_init(void) int mtdblk_minor; int smart_minor; int nxf_minor; + char path[32]; int ret; int i; @@ -254,12 +255,15 @@ int stm32wl5_flash_init(void) if (strcmp(fs, "rawfs") == 0) { - /* for raw fs just create mtdblock using ftl */ + /* Register the MTD driver */ - if ((ret = ftl_initialize(mtdblk_minor, mtd_part))) + snprintf(path, sizeof(path), "/dev/mtdblock%d", mtdblk_minor); + ret = register_mtddriver(path, mtd, 0755, NULL); + if (ret < 0) { - ferr("[%s]ERROR: ftl_initialize failed %d\n", name, ret); - continue; + ferr("[%s]ERROR:Failed to register the MTD driver %s ret %d\n", + name, path, ret); + return ret; } mtdblk_minor++; diff --git a/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c b/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c index a5871e8021..766948fb9e 100644 --- a/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c +++ b/boards/arm/tiva/tm4c123g-launchpad/src/tm4c_at24.c @@ -104,13 +104,16 @@ int tm4c_at24_automount(int minor) } #if defined(CONFIG_TM4C123G_LAUNCHPAD_AT24_FTL) - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(AT24_MINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", AT24_MINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, + "ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } diff --git a/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c b/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c index 01dadd1a49..65af9d8f78 100644 --- a/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c +++ b/boards/mips/pic32mx/mirtoo/src/pic32_appinit.c @@ -126,12 +126,15 @@ int board_app_initialize(uintptr_t arg) } #ifndef CONFIG_FS_NXFFS - /* And use the FTL layer to wrap the MTD driver as a block driver */ + /* Register the MTD driver */ - ret = ftl_initialize(CONFIG_NSH_MMCSDMINOR, mtd); + char path[32]; + snprintf(path, sizeof(path), "/dev/mtdblock%d", CONFIG_NSH_MMCSDMINOR); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - ferr("ERROR: Initialize the FTL layer\n"); + ferr("ERROR: Failed to register the MTD driver %s, ret %d\n", + path, ret); return ret; } #else diff --git a/boards/risc-v/esp32c3/common/src/esp_board_spiflash.c b/boards/risc-v/esp32c3/common/src/esp_board_spiflash.c index a4f429375d..6c976f3bc5 100644 --- a/boards/risc-v/esp32c3/common/src/esp_board_spiflash.c +++ b/boards/risc-v/esp32c3/common/src/esp_board_spiflash.c @@ -375,15 +375,14 @@ static int init_storage_partition(void) ret = register_mtddriver("/dev/espflash", mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to register MTD: %d\n", ret); + syslog(LOG_ERR, "ERROR: Failed to register MTD espflash: %d\n", ret); return ret; } - ret = ftl_initialize(0, mtd); + ret = register_mtddriver("/dev/mtdblock0", mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, "ERROR: Failed to register MTD mtdblock0: %d\n", ret); return ret; } #endif diff --git a/boards/risc-v/esp32c6/common/src/esp_board_spiflash.c b/boards/risc-v/esp32c6/common/src/esp_board_spiflash.c index c12abc3aa8..7f81068c14 100644 --- a/boards/risc-v/esp32c6/common/src/esp_board_spiflash.c +++ b/boards/risc-v/esp32c6/common/src/esp_board_spiflash.c @@ -447,15 +447,14 @@ static int init_storage_partition(void) ret = register_mtddriver("/dev/espflash", mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to register MTD: %d\n", ret); + syslog(LOG_ERR, "ERROR: Failed to register MTD espflash: %d\n", ret); return ret; } - ret = ftl_initialize(0, mtd); + ret = register_mtddriver("/dev/mtdblock0", mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, "ERROR: Failed to register MTD mtdblock0: %d\n", ret); return ret; } #endif diff --git a/boards/risc-v/esp32h2/common/src/esp_board_spiflash.c b/boards/risc-v/esp32h2/common/src/esp_board_spiflash.c index 6174571675..4395b74dde 100644 --- a/boards/risc-v/esp32h2/common/src/esp_board_spiflash.c +++ b/boards/risc-v/esp32h2/common/src/esp_board_spiflash.c @@ -375,15 +375,14 @@ static int init_storage_partition(void) ret = register_mtddriver("/dev/espflash", mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to register MTD: %d\n", ret); + syslog(LOG_ERR, "ERROR: Failed to register MTD espflash: %d\n", ret); return ret; } - ret = ftl_initialize(0, mtd); + ret = register_mtddriver("/dev/mtdblock0", mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, "ERROR: Failed to register MTD mtdblock0: %d\n", ret); return ret; } #endif diff --git a/boards/xtensa/esp32/common/src/esp32_board_spiflash.c b/boards/xtensa/esp32/common/src/esp32_board_spiflash.c index 60b9179426..390445a7ee 100644 --- a/boards/xtensa/esp32/common/src/esp32_board_spiflash.c +++ b/boards/xtensa/esp32/common/src/esp32_board_spiflash.c @@ -406,6 +406,8 @@ static int init_storage_partition(void) } #else + int minor; + char path[32]; ret = register_mtddriver("/dev/esp32flash", mtd, 0755, NULL); if (ret < 0) @@ -415,14 +417,16 @@ static int init_storage_partition(void) } #ifdef CONFIG_ESP32_HAVE_OTA_PARTITION - ret = ftl_initialize(nitems(g_ota_partition_table), mtd); + minor = nitems(g_ota_partition_table); #else - ret = ftl_initialize(0, mtd); + minor = 0; #endif + snprintf(path, sizeof(path), "/dev/mtdblock%d", minor); + ret = register_mtddriver(path, mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, "ERROR: Failed to register the MTD driver %s, \ + ret %d\n", path, ret); return ret; } #endif diff --git a/boards/xtensa/esp32s2/common/src/esp32s2_board_spiflash.c b/boards/xtensa/esp32s2/common/src/esp32s2_board_spiflash.c index 12e5e1ff1e..80fcba4138 100644 --- a/boards/xtensa/esp32s2/common/src/esp32s2_board_spiflash.c +++ b/boards/xtensa/esp32s2/common/src/esp32s2_board_spiflash.c @@ -334,15 +334,15 @@ static int init_storage_partition(void) ret = register_mtddriver("/dev/esp32s2flash", mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to register MTD: %d\n", ret); + syslog(LOG_ERR, "ERROR: Failed to register MTD esp32s2flash: %d\n", + ret); return ret; } - ret = ftl_initialize(0, mtd); + ret = register_mtddriver("/dev/mtdblock0", mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, "ERROR: Failed to register MTD mtdblock0: %d\n", ret); return ret; } #endif diff --git a/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c b/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c index 37c15357c2..fa739f1d19 100644 --- a/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c +++ b/boards/xtensa/esp32s3/common/src/esp32s3_board_spiflash.c @@ -329,15 +329,15 @@ static int init_storage_partition(void) ret = register_mtddriver("/dev/esp32s3flash", mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to register MTD: %d\n", ret); + syslog(LOG_ERR, "ERROR: Failed to register MTD esp32s3flash: %d\n", + ret); return ret; } - ret = ftl_initialize(0, mtd); + ret = register_mtddriver("/dev/mtdblock0", mtd, 0755, NULL); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed to initialize the FTL layer: %d\n", - ret); + syslog(LOG_ERR, "ERROR: Failed to register MTD mtdblock0: %d\n", ret); return ret; }