drivers: mtd: fix nxstyle errors

Fix nxstyle errors to pass the CI errors.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
Alin Jerpelea
2021-01-27 16:48:40 +01:00
committed by Xiang Xiao
parent 95adb15824
commit 2d8b193df4
24 changed files with 3804 additions and 2972 deletions
+111 -89
View File
@@ -1,7 +1,7 @@
/************************************************************************************
/****************************************************************************
* drivers/mtd/sector512.c
* MTD driver that contains another MTD driver and converts a larger sector size
* to a standard 512 byte sector size.
* MTD driver that contains another MTD driver and converts a larger sector
* size to a standard 512 byte sector size.
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -33,11 +33,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Included Files
************************************************************************************/
****************************************************************************/
#include <nuttx/config.h>
@@ -57,9 +57,9 @@
#include <nuttx/fs/ioctl.h>
#include <nuttx/mtd/mtd.h>
/************************************************************************************
/****************************************************************************
* Pre-processor Definitions
************************************************************************************/
****************************************************************************/
/* Configuration */
@@ -69,35 +69,35 @@
/* 512-byte sector constants */
#define SECTOR_512 512
#define SHIFT_512 9
#define MASK_512 511
#define SECTOR_512 512
#define SHIFT_512 9
#define MASK_512 511
/* Cache flags */
#define SST25_CACHE_VALID (1 << 0) /* 1=Cache has valid data */
#define SST25_CACHE_DIRTY (1 << 1) /* 1=Cache is dirty */
#define SST25_CACHE_ERASED (1 << 2) /* 1=Backing FLASH is erased */
#define SST25_CACHE_VALID (1 << 0) /* 1=Cache has valid data */
#define SST25_CACHE_DIRTY (1 << 1) /* 1=Cache is dirty */
#define SST25_CACHE_ERASED (1 << 2) /* 1=Backing FLASH is erased */
#define IS_VALID(p) ((((p)->flags) & SST25_CACHE_VALID) != 0)
#define IS_DIRTY(p) ((((p)->flags) & SST25_CACHE_DIRTY) != 0)
#define IS_ERASED(p) ((((p)->flags) & SST25_CACHE_DIRTY) != 0)
#define IS_VALID(p) ((((p)->flags) & SST25_CACHE_VALID) != 0)
#define IS_DIRTY(p) ((((p)->flags) & SST25_CACHE_DIRTY) != 0)
#define IS_ERASED(p) ((((p)->flags) & SST25_CACHE_DIRTY) != 0)
#define SET_VALID(p) do { (p)->flags |= SST25_CACHE_VALID; } while (0)
#define SET_DIRTY(p) do { (p)->flags |= SST25_CACHE_DIRTY; } while (0)
#define SET_ERASED(p) do { (p)->flags |= SST25_CACHE_DIRTY; } while (0)
#define SET_VALID(p) do { (p)->flags |= SST25_CACHE_VALID; } while (0)
#define SET_DIRTY(p) do { (p)->flags |= SST25_CACHE_DIRTY; } while (0)
#define SET_ERASED(p) do { (p)->flags |= SST25_CACHE_DIRTY; } while (0)
#define CLR_VALID(p) do { (p)->flags &= ~SST25_CACHE_VALID; } while (0)
#define CLR_DIRTY(p) do { (p)->flags &= ~SST25_CACHE_DIRTY; } while (0)
#define CLR_ERASED(p) do { (p)->flags &= ~SST25_CACHE_DIRTY; } while (0)
#define CLR_VALID(p) do { (p)->flags &= ~SST25_CACHE_VALID; } while (0)
#define CLR_DIRTY(p) do { (p)->flags &= ~SST25_CACHE_DIRTY; } while (0)
#define CLR_ERASED(p) do { (p)->flags &= ~SST25_CACHE_DIRTY; } while (0)
/************************************************************************************
/****************************************************************************
* Private Types
************************************************************************************/
****************************************************************************/
/* This type represents the state of the MTD device. The struct mtd_dev_s must
* appear at the beginning of the definition so that you can freely cast between
* pointers to struct mtd_dev_s and struct s512_dev_s.
/* This type represents the state of the MTD device. The struct mtd_dev_s
* must appear at the beginning of the definition so that you can freely
* cast between pointers to struct mtd_dev_s and struct s512_dev_s.
*/
struct s512_dev_s
@@ -113,9 +113,9 @@ struct s512_dev_s
FAR uint8_t *eblock; /* Allocated erase block */
};
/************************************************************************************
/****************************************************************************
* Private Function Prototypes
************************************************************************************/
****************************************************************************/
/* Helpers */
@@ -126,26 +126,36 @@ static void s512_cacheflush(struct s512_dev_s *priv);
/* MTD driver methods */
static int s512_erase(FAR struct mtd_dev_s *dev, off_t sector512, size_t nsectors);
static ssize_t s512_bread(FAR struct mtd_dev_s *dev, off_t sector512,
size_t nsectors, FAR uint8_t *buf);
static ssize_t s512_bwrite(FAR struct mtd_dev_s *dev, off_t sector512,
size_t nsectors, FAR const uint8_t *buf);
static ssize_t s512_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
FAR uint8_t *buffer);
static int s512_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
static int s512_erase(FAR struct mtd_dev_s *dev,
off_t sector512,
size_t nsectors);
static ssize_t s512_bread(FAR struct mtd_dev_s *dev,
off_t sector512,
size_t nsectors,
FAR uint8_t *buf);
static ssize_t s512_bwrite(FAR struct mtd_dev_s *dev,
off_t sector512,
size_t nsectors,
FAR const uint8_t *buf);
static ssize_t s512_read(FAR struct mtd_dev_s *dev,
off_t offset,
size_t nbytes,
FAR uint8_t *buffer);
static int s512_ioctl(FAR struct mtd_dev_s *dev,
int cmd,
unsigned long arg);
/************************************************************************************
/****************************************************************************
* Private Data
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Private Functions
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Name: s512_cacheread
************************************************************************************/
****************************************************************************/
static FAR uint8_t *s512_cacheread(struct s512_dev_s *priv, off_t sector512)
{
@@ -191,7 +201,9 @@ static FAR uint8_t *s512_cacheread(struct s512_dev_s *priv, off_t sector512)
CLR_ERASED(priv); /* The underlying FLASH has not been erased */
}
/* Get the index to the 512 sector in the erase block that holds the argument */
/* Get the index to the 512 sector in the erase block that holds the
* argument
*/
index = sector512 % priv->stdperblock;
@@ -200,9 +212,9 @@ static FAR uint8_t *s512_cacheread(struct s512_dev_s *priv, off_t sector512)
return &priv->eblock[index << SHIFT_512];
}
/************************************************************************************
/****************************************************************************
* Name: s512_cacheflush
************************************************************************************/
****************************************************************************/
#if !defined(CONFIG_MTD_SECT512_READONLY)
static void s512_cacheflush(struct s512_dev_s *priv)
@@ -239,11 +251,13 @@ static void s512_cacheflush(struct s512_dev_s *priv)
}
#endif
/************************************************************************************
/****************************************************************************
* Name: s512_erase
************************************************************************************/
****************************************************************************/
static int s512_erase(FAR struct mtd_dev_s *dev, off_t sector512, size_t nsectors)
static int s512_erase(FAR struct mtd_dev_s *dev,
off_t sector512,
size_t nsectors)
{
#ifdef CONFIG_MTD_SECT512_READONLY
return -EACESS
@@ -258,21 +272,22 @@ static int s512_erase(FAR struct mtd_dev_s *dev, off_t sector512, size_t nsector
while (sectorsleft-- > 0)
{
/* Erase each sector. First, make sure that the erase block containing the
* 512 byte sector is in the cache.
/* Erase each sector. First, make sure that the erase block containing
* the 512 byte sector is in the cache.
*/
dest = s512_cacheread(priv, sector512);
if (!dest)
{
ferr("ERROR: s512_cacheread(%lu) failed\n", (unsigned long)sector512);
ferr("ERROR: s512_cacheread(%lu) failed\n",
(unsigned long)sector512);
DEBUGPANIC();
return -EIO;
}
/* Erase the block containing this sector if it is not already erased.
* The erased indicator will be cleared when the data from the erase sector
* is read into the cache and set here when we erase the block.
* The erased indicator will be cleared when the data from the erase
* sector is read into the cache and set here when we erase the block.
*/
if (!IS_ERASED(priv))
@@ -310,9 +325,9 @@ static int s512_erase(FAR struct mtd_dev_s *dev, off_t sector512, size_t nsector
#endif
}
/************************************************************************************
/****************************************************************************
* Name: s512_bread
************************************************************************************/
****************************************************************************/
static ssize_t s512_bread(FAR struct mtd_dev_s *dev, off_t sector512,
size_t nsectors, FAR uint8_t *buffer)
@@ -333,7 +348,8 @@ static ssize_t s512_bread(FAR struct mtd_dev_s *dev, off_t sector512,
src = s512_cacheread(priv, sector512);
if (!src)
{
ferr("ERROR: s512_cacheread(%lu) failed\n", (unsigned long)sector512);
ferr("ERROR: s512_cacheread(%lu) failed\n",
(unsigned long)sector512);
DEBUGPANIC();
result = (ssize_t)nsectors - remaining;
@@ -345,7 +361,9 @@ static ssize_t s512_bread(FAR struct mtd_dev_s *dev, off_t sector512,
break;
}
/* Copy the sector data from the erase block cache into the user buffer */
/* Copy the sector data from the erase block cache into the user
* buffer
*/
memcpy(buffer, src, SECTOR_512);
@@ -356,9 +374,9 @@ static ssize_t s512_bread(FAR struct mtd_dev_s *dev, off_t sector512,
return result;
}
/************************************************************************************
/****************************************************************************
* Name: s512_bwrite
************************************************************************************/
****************************************************************************/
static ssize_t s512_bwrite(FAR struct mtd_dev_s *dev, off_t sector512,
size_t nsectors,
@@ -378,8 +396,8 @@ static ssize_t s512_bwrite(FAR struct mtd_dev_s *dev, off_t sector512,
for (remaining = nsectors; remaining > 0; remaining--)
{
/* First, make sure that the erase block containing 512 byte sector is in
* memory.
/* First, make sure that the erase block containing 512 byte sector is
* in memory.
*/
dest = s512_cacheread(priv, sector512);
@@ -395,8 +413,8 @@ static ssize_t s512_bwrite(FAR struct mtd_dev_s *dev, off_t sector512,
}
/* Erase the block containing this sector if it is not already erased.
* The erased indicated will be cleared when the data from the erase sector
* is read into the cache and set here when we erase the sector.
* The erased indicated will be cleared when the data from the erase
* sector is read into the cache and set here when we erase the sector.
*/
if (!IS_ERASED(priv))
@@ -434,11 +452,13 @@ static ssize_t s512_bwrite(FAR struct mtd_dev_s *dev, off_t sector512,
#endif
}
/************************************************************************************
/****************************************************************************
* Name: s512_read
************************************************************************************/
****************************************************************************/
static ssize_t s512_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
static ssize_t s512_read(FAR struct mtd_dev_s *dev,
off_t offset,
size_t nbytes,
FAR uint8_t *buffer)
{
FAR struct s512_dev_s *priv = (FAR struct s512_dev_s *)dev;
@@ -495,9 +515,9 @@ static ssize_t s512_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
return nbytes;
}
/************************************************************************************
/****************************************************************************
* Name: s512_ioctl
************************************************************************************/
****************************************************************************/
static int s512_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
{
@@ -514,13 +534,14 @@ static int s512_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
((uintptr_t)arg);
if (geo)
{
/* Populate the geometry structure with information need to know
* the capacity and how to access the device.
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*
* NOTE: that the device is treated as though it where just an array
* of fixed size blocks. That is most likely not true, but the client
* will expect the device logic to do whatever is necessary to make it
* appear so.
* NOTE:
* that the device is treated as though it where just an
* array of fixed size blocks. That is most likely not true,
* but the client will expect the device logic to do whatever
* is necessary to make it appear so.
*/
geo->blocksize = SECTOR_512;
@@ -559,23 +580,23 @@ static int s512_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
return ret;
}
/************************************************************************************
/****************************************************************************
* Public Functions
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Name: s512_initialize
*
* Description:
* Create an initialized MTD device instance. This MTD driver contains another
* MTD driver and converts a larger sector size to a standard 512 byte sector
* size.
* Create an initialized MTD device instance. This MTD driver contains
* another MTD driver and converts a larger sector size to a standard 512
* byte sector size.
*
* MTD devices are not registered in the file system, but are created as instances
* that can be bound to other functions (such as a block or character driver front
* end).
* MTD devices are not registered in the file system, but are created as
* instances that can be bound to other functions (such as a block or
* character driver front end).
*
************************************************************************************/
****************************************************************************/
FAR struct mtd_dev_s *s512_initialize(FAR struct mtd_dev_s *mtd)
{
@@ -595,7 +616,8 @@ FAR struct mtd_dev_s *s512_initialize(FAR struct mtd_dev_s *mtd)
if (ret < 0 || geo.erasesize <= SECTOR_512 ||
(geo.erasesize & ~MASK_512) != geo.erasesize)
{
ferr("ERROR: MTDIOC_GEOMETRY ioctl returned %d, eraseize=%" PRId32 "\n",
ferr(
"ERROR: MTDIOC_GEOMETRY ioctl returned %d, eraseize=%" PRId32 "\n",
ret, geo.erasesize);
DEBUGPANIC();
return NULL;
@@ -604,8 +626,8 @@ FAR struct mtd_dev_s *s512_initialize(FAR struct mtd_dev_s *mtd)
/* Allocate a state structure (we allocate the structure instead of using
* a fixed, static allocation so that we can handle multiple FLASH devices.
* The current implementation would handle only one FLASH part per SPI
* device (only because of the SPIDEV_FLASH(0) definition) and so would have
* to be extended to handle multiple FLASH parts on the same SPI bus.
* device (only because of the SPIDEV_FLASH(0) definition) and so would
* have to be extended to handle multiple FLASH parts on the same SPI bus.
*/
priv = (FAR struct s512_dev_s *)kmm_zalloc(sizeof(struct s512_dev_s));