Skip to content
Merged
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
109 changes: 56 additions & 53 deletions drivers/mtd/filemtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ static int filemtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
{
FAR struct partition_info_s *info =
(FAR struct partition_info_s *)arg;

if (info != NULL)
{
info->numsectors = priv->nblocks *
Expand All @@ -530,6 +531,7 @@ static int filemtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
case MTDIOC_ERASESTATE:
{
FAR uint8_t *result = (FAR uint8_t *)arg;

*result = CONFIG_FILEMTD_ERASESTATE;

ret = OK;
Expand Down Expand Up @@ -580,6 +582,7 @@ static int mtd_loop_setup(FAR const char *devname, FAR const char *filename,
/* Try to erase the entire device, before register */

FAR struct file_dev_s *fdev = (FAR struct file_dev_s *)mtd;

mtd->erase(mtd, offset / erasesize, fdev->nblocks);
}

Expand Down Expand Up @@ -698,61 +701,61 @@ static int mtd_loop_ioctl(FAR struct file *filep, int cmd,

switch (cmd)
{
/* Command: LOOPIOC_SETUP
* Description: Setup the loop device
* Argument: A pointer to a read-only instance of struct losetup_s.
* Dependencies: The loop device must be enabled (CONFIG_MTD_LOOP=y)
*/

case MTD_LOOPIOC_SETUP:
{
FAR struct mtd_losetup_s *setup =
(FAR struct mtd_losetup_s *)((uintptr_t)arg);

if (setup == NULL)
{
ret = -EINVAL;
}
else
{
/* Command: LOOPIOC_SETUP
* Description: Setup the loop device
* Argument: A pointer to a read-only instance of struct losetup_s.
* Dependencies: The loop device must be enabled (CONFIG_MTD_LOOP=y)
*/

case MTD_LOOPIOC_SETUP:
{
FAR struct mtd_losetup_s *setup =
(FAR struct mtd_losetup_s *)((uintptr_t)arg);

if (setup == NULL)
{
ret = -EINVAL;
}
else
{
# ifndef CONFIG_MTD_CONFIG_NONE
ret = mtd_loop_setup(setup->devname, setup->filename,
setup->sectsize, setup->erasesize,
setup->offset, setup->configdata);
ret = mtd_loop_setup(setup->devname, setup->filename,
setup->sectsize, setup->erasesize,
setup->offset, setup->configdata);
# else
ret = mtd_loop_setup(setup->devname, setup->filename,
setup->sectsize, setup->erasesize,
setup->offset);
ret = mtd_loop_setup(setup->devname, setup->filename,
setup->sectsize, setup->erasesize,
setup->offset);
# endif
}
}
break;

/* Command: LOOPIOC_TEARDOWN
* Description: Teardown a loop device previously setup via
* LOOPIOC_SETUP
* Argument: A read-able pointer to the path of the device to be
* torn down
* Dependencies: The loop device must be enabled (CONFIG_MTD_LOOP=y)
*/

case MTD_LOOPIOC_TEARDOWN:
{
FAR const char *devname = (FAR const char *)((uintptr_t)arg);

if (devname == NULL)
{
ret = -EINVAL;
}
else
{
ret = mtd_loop_teardown(devname);
}
}
break;

default:
ret = -ENOTTY;
}
}
break;

/* Command: LOOPIOC_TEARDOWN
* Description: Teardown a loop device previously setup via
* LOOPIOC_SETUP
* Argument: A read-able pointer to the path of the device to be
* torn down
* Dependencies: The loop device must be enabled (CONFIG_MTD_LOOP=y)
*/

case MTD_LOOPIOC_TEARDOWN:
{
FAR const char *devname = (FAR const char *)((uintptr_t)arg);

if (devname == NULL)
{
ret = -EINVAL;
}
else
{
ret = mtd_loop_teardown(devname);
}
}
break;

default:
ret = -ENOTTY;
}

return ret;
Expand Down Expand Up @@ -813,7 +816,7 @@ FAR struct mtd_dev_s *filemtd_initialize(FAR const char *path, off_t offset,

/* Set the file open mode. */

mode = O_RDONLY | O_WRONLY | O_CLOEXEC;
mode = O_RDWR | O_CLOEXEC;

/* Try to open the file. NOTE that block devices will use a character
* driver proxy.
Expand Down
Loading