drivers/mtd/mtd_config: set different format versions for named and ID modes

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko 2022-03-21 21:10:09 +01:00 committed by Xiang Xiao
parent 3581668c6b
commit b7c4746b0a
1 changed files with 11 additions and 16 deletions

View File

@ -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;
}