From eb0d8d9914981ae4d2dadf611efac37a2e94d04f Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 22 Jul 2025 14:14:43 +0800 Subject: [PATCH] mtd/ftl: Rename ftl_initialize_by_path to ftl_initialize since ftl_initialize isn't used anymore after: https://github.com/apache/nuttx/pull/16642 https://github.com/apache/nuttx/pull/16738 Signed-off-by: Xiang Xiao --- .../applications/examples/media/index.rst | 10 ++++- drivers/mtd/ftl.c | 38 ++----------------- fs/driver/fs_mtdproxy.c | 4 +- include/nuttx/mtd/mtd.h | 20 ++-------- 4 files changed, 17 insertions(+), 55 deletions(-) diff --git a/Documentation/applications/examples/media/index.rst b/Documentation/applications/examples/media/index.rst index 01cc82841c33e..5a9c91752a2bd 100644 --- a/Documentation/applications/examples/media/index.rst +++ b/Documentation/applications/examples/media/index.rst @@ -22,5 +22,13 @@ to convert the MTD driver to a block device: .. code-block:: C - int ret = ftl_initialize(, mtd); + int ret = ftl_initialize(/dev/mtdblock, mtd); ret = bchdev_register(/dev/mtdblock, , false); + +But since mtd driver could expose to the userspace through register_mtddriver, +it's better to register mtd driver directly and let fs layer add FTL/BCH wrapper +automatically: + +.. code-block:: C + + int ret = register_mtddriver(/dev/mtdblock, mtd); diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index ace0eeb2c539b..b190008ff5ff9 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c @@ -872,7 +872,7 @@ static int ftl_unlink(FAR struct inode *inode) ****************************************************************************/ /**************************************************************************** - * Name: ftl_initialize_by_path + * Name: ftl_initialize * * Description: * Initialize to provide a block driver wrapper around an MTD interface @@ -883,8 +883,8 @@ static int ftl_unlink(FAR struct inode *inode) * ****************************************************************************/ -int ftl_initialize_by_path(FAR const char *path, FAR struct mtd_dev_s *mtd, - int oflags) +int ftl_initialize(FAR const char *path, FAR struct mtd_dev_s *mtd, + int oflags) { struct ftl_struct_s *dev; int ret = -ENOMEM; @@ -980,35 +980,3 @@ int ftl_initialize_by_path(FAR const char *path, FAR struct mtd_dev_s *mtd, return ret; } - -/**************************************************************************** - * Name: ftl_initialize - * - * Description: - * Initialize to provide a block driver wrapper around an MTD interface - * - * Input Parameters: - * minor - The minor device number. The MTD block device will be - * registered as as /dev/mtdblockN where N is the minor number. - * mtd - The MTD device that supports the FLASH interface. - * - ****************************************************************************/ - -int ftl_initialize(int minor, FAR struct mtd_dev_s *mtd) -{ - char path[DEV_NAME_MAX]; - -#ifdef CONFIG_DEBUG_FEATURES - /* Sanity check */ - - if (minor < 0 || minor > 255) - { - return -EINVAL; - } -#endif - - /* Do the real work by ftl_initialize_by_path */ - - snprintf(path, DEV_NAME_MAX, "/dev/mtdblock%d", minor); - return ftl_initialize_by_path(path, mtd, O_RDWR); -} diff --git a/fs/driver/fs_mtdproxy.c b/fs/driver/fs_mtdproxy.c index 44f9bc84e5137..123a54e358fa7 100644 --- a/fs/driver/fs_mtdproxy.c +++ b/fs/driver/fs_mtdproxy.c @@ -165,11 +165,11 @@ int mtd_proxy(FAR const char *mtddev, int mountflags, goto out_with_blkdev; } - ret = ftl_initialize_by_path(blkdev, mtd->u.i_mtd, mountflags); + ret = ftl_initialize(blkdev, mtd->u.i_mtd, mountflags); inode_release(mtd); if (ret < 0) { - ferr("ERROR: ftl_initialize_by_path(%s, %s) failed: %d\n", + ferr("ERROR: ftl_initialize(%s, %s) failed: %d\n", mtddev, blkdev, ret); goto out_with_blkdev; } diff --git a/include/nuttx/mtd/mtd.h b/include/nuttx/mtd/mtd.h index a1c791dbf5059..1482790e6d97a 100644 --- a/include/nuttx/mtd/mtd.h +++ b/include/nuttx/mtd/mtd.h @@ -290,7 +290,7 @@ FAR struct mtd_dev_s *mtd_rwb_initialize(FAR struct mtd_dev_s *mtd); #endif /**************************************************************************** - * Name: ftl_initialize_by_path + * Name: ftl_initialize * * Description: * Initialize to provide a block driver wrapper around an MTD interface @@ -315,22 +315,8 @@ FAR struct mtd_dev_s *mtd_rwb_initialize(FAR struct mtd_dev_s *mtd); * ****************************************************************************/ -int ftl_initialize_by_path(FAR const char *path, FAR struct mtd_dev_s *mtd, - int oflags); - -/**************************************************************************** - * Name: ftl_initialize - * - * Description: - * Initialize to provide a block driver wrapper around an MTD interface - * - * Input Parameters: - * minor - The minor device number. The MTD block device will be - * registered as as /dev/mtdblockN where N is the minor number. - * mtd - The MTD device that supports the FLASH interface. - ****************************************************************************/ - -int ftl_initialize(int minor, FAR struct mtd_dev_s *mtd); +int ftl_initialize(FAR const char *path, FAR struct mtd_dev_s *mtd, + int oflags); /**************************************************************************** * Name: smart_initialize