diff --git a/drivers/mtd/mtd_config.c b/drivers/mtd/mtd_config.c index 1f5bf6d8d0..7a597dc9ec 100644 --- a/drivers/mtd/mtd_config.c +++ b/drivers/mtd/mtd_config.c @@ -55,14 +55,12 @@ /* Define the current format version */ -#define CONFIGDATA_FORMAT_VERSION 1 -#define CONFIGDATA_BLOCK_HDR_SIZE 3 - -/* Define the erased state of the MTD device, if not already defined */ - -#ifndef CONFIG_MTD_CONFIG_ERASEDVALUE -# define CONFIG_MTD_CONFIG_ERASEDVALUE 0xff +#ifdef CONFIG_MTD_CONFIG_NAMED +# define CONFIGDATA_FORMAT_VERSION 1 +#else +# define CONFIGDATA_FORMAT_VERSION 2 #endif +#define CONFIGDATA_BLOCK_HDR_SIZE 3 #define MTD_ERASED_ID ((CONFIG_MTD_CONFIG_ERASEDVALUE << 8) | \ CONFIG_MTD_CONFIG_ERASEDVALUE) @@ -104,11 +102,11 @@ begin_packed_struct struct mtdconfig_header_s static int mtdconfig_open(FAR struct file *filep); static int mtdconfig_close(FAR struct file *filep); static ssize_t mtdconfig_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); + size_t buflen); static int mtdconfig_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); static int mtdconfig_poll(FAR struct file *filep, FAR struct pollfd *fds, - bool setup); + bool setup); /**************************************************************************** * Private Data @@ -266,7 +264,7 @@ static int mtdconfig_writebytes(FAR struct mtdconfig_struct_s *dev, off_t bytes_this_block; off_t bytes_written = 0; - while (writelen) + while (writelen > 0) { /* Read existing data from the block into the buffer */ @@ -1167,7 +1165,7 @@ static int mtdconfig_setconfig(FAR struct mtdconfig_struct_s *dev, /* Allocate a temp block buffer */ - dev->buffer = (FAR uint8_t *) kmm_malloc(dev->blocksize); + dev->buffer = (FAR uint8_t *)kmm_malloc(dev->blocksize); if (dev->buffer == NULL) { return -ENOMEM; @@ -1646,10 +1644,7 @@ static int mtdconfig_ioctl(FAR struct file *filep, int cmd, /* Call the MTD's ioctl for this */ - if (dev->mtd->ioctl) - { - dev->mtd->ioctl(dev->mtd, cmd, arg); - } + ret = MTD_IOCTL(dev->mtd, cmd, arg); break; }