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
+11 -16
View File
@@ -55,14 +55,12 @@
/* Define the current format version */ /* Define the current format version */
#define CONFIGDATA_FORMAT_VERSION 1 #ifdef CONFIG_MTD_CONFIG_NAMED
#define CONFIGDATA_BLOCK_HDR_SIZE 3 # define CONFIGDATA_FORMAT_VERSION 1
#else
/* Define the erased state of the MTD device, if not already defined */ # define CONFIGDATA_FORMAT_VERSION 2
#ifndef CONFIG_MTD_CONFIG_ERASEDVALUE
# define CONFIG_MTD_CONFIG_ERASEDVALUE 0xff
#endif #endif
#define CONFIGDATA_BLOCK_HDR_SIZE 3
#define MTD_ERASED_ID ((CONFIG_MTD_CONFIG_ERASEDVALUE << 8) | \ #define MTD_ERASED_ID ((CONFIG_MTD_CONFIG_ERASEDVALUE << 8) | \
CONFIG_MTD_CONFIG_ERASEDVALUE) 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_open(FAR struct file *filep);
static int mtdconfig_close(FAR struct file *filep); static int mtdconfig_close(FAR struct file *filep);
static ssize_t mtdconfig_read(FAR struct file *filep, FAR char *buffer, 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, 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, static int mtdconfig_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup); bool setup);
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@@ -266,7 +264,7 @@ static int mtdconfig_writebytes(FAR struct mtdconfig_struct_s *dev,
off_t bytes_this_block; off_t bytes_this_block;
off_t bytes_written = 0; off_t bytes_written = 0;
while (writelen) while (writelen > 0)
{ {
/* Read existing data from the block into the buffer */ /* 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 */ /* 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) if (dev->buffer == NULL)
{ {
return -ENOMEM; return -ENOMEM;
@@ -1646,10 +1644,7 @@ static int mtdconfig_ioctl(FAR struct file *filep, int cmd,
/* Call the MTD's ioctl for this */ /* Call the MTD's ioctl for this */
if (dev->mtd->ioctl) ret = MTD_IOCTL(dev->mtd, cmd, arg);
{
dev->mtd->ioctl(dev->mtd, cmd, arg);
}
break; break;
} }