Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Documentation/applications/examples/media/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,13 @@ to convert the MTD driver to a block device:

.. code-block:: C

int ret = ftl_initialize(<N>, mtd);
int ret = ftl_initialize(/dev/mtdblock<N>, mtd);
ret = bchdev_register(/dev/mtdblock<N>, <path-to-character-driver>, 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<N>, mtd);
38 changes: 3 additions & 35 deletions drivers/mtd/ftl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions fs/driver/fs_mtdproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
20 changes: 3 additions & 17 deletions include/nuttx/mtd/mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading