drivers/mtd/ftl.c: Change ftl_initialize_by_name to ftl_initialize_by_path

This commit is contained in:
Xiang Xiao 2018-11-09 08:15:57 -06:00 committed by Gregory Nutt
parent 6ee09e8888
commit 65177b3344
2 changed files with 11 additions and 20 deletions

View File

@ -520,32 +520,28 @@ static int ftl_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: ftl_initialize_by_name * Name: ftl_initialize_by_path
* *
* Description: * Description:
* Initialize to provide a block driver wrapper around an MTD interface * Initialize to provide a block driver wrapper around an MTD interface
* *
* Input Parameters: * Input Parameters:
* name - The device name. The MTD block device will be * path - The block device path.
* registered as as /dev/mtdNAME where NAME is the device name.
* mtd - The MTD device that supports the FLASH interface. * mtd - The MTD device that supports the FLASH interface.
* *
****************************************************************************/ ****************************************************************************/
int ftl_initialize_by_name(FAR const char *name, FAR struct mtd_dev_s *mtd) int ftl_initialize_by_path(FAR const char *path, FAR struct mtd_dev_s *mtd)
{ {
struct ftl_struct_s *dev; struct ftl_struct_s *dev;
char devname[DEV_NAME_MAX];
int ret = -ENOMEM; int ret = -ENOMEM;
#ifdef CONFIG_DEBUG_FEATURES
/* Sanity check */ /* Sanity check */
if (name == NULL || mtd == NULL) if (path == NULL || mtd == NULL)
{ {
return -EINVAL; return -EINVAL;
} }
#endif
/* Allocate a FTL device structure */ /* Allocate a FTL device structure */
@ -615,13 +611,9 @@ int ftl_initialize_by_name(FAR const char *name, FAR struct mtd_dev_s *mtd)
} }
#endif #endif
/* Create a MTD block device name */
snprintf(devname, DEV_NAME_MAX, "/dev/mtd%s", name);
/* Inode private data is a reference to the FTL device structure */ /* Inode private data is a reference to the FTL device structure */
ret = register_blockdriver(devname, &g_bops, 0, dev); ret = register_blockdriver(path, &g_bops, 0, dev);
if (ret < 0) if (ret < 0)
{ {
ferr("ERROR: register_blockdriver failed: %d\n", -ret); ferr("ERROR: register_blockdriver failed: %d\n", -ret);
@ -650,7 +642,7 @@ int ftl_initialize_by_name(FAR const char *name, FAR struct mtd_dev_s *mtd)
int ftl_initialize(int minor, FAR struct mtd_dev_s *mtd) int ftl_initialize(int minor, FAR struct mtd_dev_s *mtd)
{ {
char name[16]; char path[DEV_NAME_MAX];
#ifdef CONFIG_DEBUG_FEATURES #ifdef CONFIG_DEBUG_FEATURES
/* Sanity check */ /* Sanity check */
@ -661,8 +653,8 @@ int ftl_initialize(int minor, FAR struct mtd_dev_s *mtd)
} }
#endif #endif
/* Do the real work by ftl_initialize_by_name */ /* Do the real work by ftl_initialize_by_path */
snprintf(name, 16, "block%d", minor); snprintf(path, DEV_NAME_MAX, "/dev/mtdblock%d", minor);
return ftl_initialize_by_name(name, mtd); return ftl_initialize_by_path(path, mtd);
} }

View File

@ -280,13 +280,12 @@ FAR struct mtd_dev_s *mtd_rwb_initialize(FAR struct mtd_dev_s *mtd);
* Initialize to provide a block driver wrapper around an MTD interface * Initialize to provide a block driver wrapper around an MTD interface
* *
* Input Parameters: * Input Parameters:
* name - The device name. The MTD block device will be * path - The block device path.
* registered as as /dev/mtdNAME where NAME is the device name.
* mtd - The MTD device that supports the FLASH interface. * mtd - The MTD device that supports the FLASH interface.
* *
****************************************************************************/ ****************************************************************************/
int ftl_initialize_by_name(FAR const char *name, FAR struct mtd_dev_s *mtd); int ftl_initialize_by_path(FAR const char *path, FAR struct mtd_dev_s *mtd);
/**************************************************************************** /****************************************************************************
* Name: ftl_initialize * Name: ftl_initialize