Minor changes from code review

This commit is contained in:
Gregory Nutt 2015-11-25 14:57:25 -06:00
parent d4a58af380
commit 6ff67d3061

View File

@ -105,28 +105,28 @@ struct file_dev_s
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
static ssize_t filemtd_read(FAR struct file_dev_s *priv, unsigned char *buffer, static ssize_t filemtd_read(FAR struct file_dev_s *priv,
size_t offsetbytes, unsigned int nbytes); FAR unsigned char *buffer, size_t offsetbytes,
static ssize_t filemtd_write(FAR struct file_dev_s *priv, size_t offset, FAR const void *src, size_t len); unsigned int nbytes);
static ssize_t filemtd_write(FAR struct file_dev_s *priv, size_t offset,
FAR const void *src, size_t len);
/* MTD driver methods */ /* MTD driver methods */
static int file_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks); static int file_erase(FAR struct mtd_dev_s *dev, off_t startblock,
static ssize_t file_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, size_t nblocks);
FAR uint8_t *buf); static ssize_t file_bread(FAR struct mtd_dev_s *dev, off_t startblock,
static ssize_t file_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, size_t nblocks, FAR uint8_t *buf);
FAR const uint8_t *buf); static ssize_t file_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
size_t nblocks, FAR const uint8_t *buf);
static ssize_t file_byteread(FAR struct mtd_dev_s *dev, off_t offset, static ssize_t file_byteread(FAR struct mtd_dev_s *dev, off_t offset,
size_t nbytes, FAR uint8_t *buf); size_t nbytes, FAR uint8_t *buf);
#ifdef CONFIG_MTD_BYTE_WRITE #ifdef CONFIG_MTD_BYTE_WRITE
static ssize_t file_bytewrite(FAR struct mtd_dev_s *dev, off_t offset, static ssize_t file_bytewrite(FAR struct mtd_dev_s *dev, off_t offset,
size_t nbytes, FAR const uint8_t *buf); size_t nbytes, FAR const uint8_t *buf);
#endif #endif
static int file_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg); static int file_ioctl(FAR struct mtd_dev_s *dev, int cmd,
unsigned long arg);
/****************************************************************************
* Private Data
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@ -137,7 +137,7 @@ static int file_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
****************************************************************************/ ****************************************************************************/
static ssize_t filemtd_write(FAR struct file_dev_s *priv, size_t offset, static ssize_t filemtd_write(FAR struct file_dev_s *priv, size_t offset,
FAR const void *src, size_t len) FAR const void *src, size_t len)
{ {
FAR const uint8_t *pin = (FAR const uint8_t *)src; FAR const uint8_t *pin = (FAR const uint8_t *)src;
FAR uint8_t *pout; FAR uint8_t *pout;
@ -222,8 +222,9 @@ static ssize_t filemtd_write(FAR struct file_dev_s *priv, size_t offset,
* Name: filemtd_read * Name: filemtd_read
****************************************************************************/ ****************************************************************************/
static ssize_t filemtd_read(FAR struct file_dev_s *priv, unsigned char *buffer, static ssize_t filemtd_read(FAR struct file_dev_s *priv,
size_t offsetbytes, unsigned int nbytes) FAR unsigned char *buffer, size_t offsetbytes,
unsigned int nbytes)
{ {
/* Set the starting location in the file */ /* Set the starting location in the file */
@ -236,7 +237,8 @@ static ssize_t filemtd_read(FAR struct file_dev_s *priv, unsigned char *buffer,
* Name: file_erase * Name: file_erase
****************************************************************************/ ****************************************************************************/
static int file_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks) static int file_erase(FAR struct mtd_dev_s *dev, off_t startblock,
size_t nblocks)
{ {
FAR struct file_dev_s *priv = (FAR struct file_dev_s *)dev; FAR struct file_dev_s *priv = (FAR struct file_dev_s *)dev;
size_t nbytes; size_t nbytes;
@ -288,8 +290,8 @@ static int file_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblock
* Name: file_bread * Name: file_bread
****************************************************************************/ ****************************************************************************/
static ssize_t file_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, static ssize_t file_bread(FAR struct mtd_dev_s *dev, off_t startblock,
FAR uint8_t *buf) size_t nblocks, FAR uint8_t *buf)
{ {
FAR struct file_dev_s *priv = (FAR struct file_dev_s *)dev; FAR struct file_dev_s *priv = (FAR struct file_dev_s *)dev;
off_t offset; off_t offset;
@ -427,7 +429,9 @@ static int file_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
{ {
case MTDIOC_GEOMETRY: case MTDIOC_GEOMETRY:
{ {
FAR struct mtd_geometry_s *geo = (FAR struct mtd_geometry_s *)((uintptr_t)arg); FAR struct mtd_geometry_s *geo =
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo) if (geo)
{ {
/* Populate the geometry structure with information need to know /* Populate the geometry structure with information need to know
@ -438,7 +442,7 @@ static int file_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
geo->erasesize = CONFIG_FILEMTD_ERASESIZE; geo->erasesize = CONFIG_FILEMTD_ERASESIZE;
geo->neraseblocks = priv->nblocks; geo->neraseblocks = priv->nblocks;
ret = OK; ret = OK;
} }
} }
break; break;
@ -448,10 +452,10 @@ static int file_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
case MTDIOC_BULKERASE: case MTDIOC_BULKERASE:
{ {
/* Erase the entire device */ /* Erase the entire device */
file_erase(dev, 0, priv->nblocks); file_erase(dev, 0, priv->nblocks);
ret = OK; ret = OK;
} }
break; break;
@ -587,4 +591,3 @@ void filemtd_teardown(FAR struct mtd_dev_s *dev)
kmm_free(priv); kmm_free(priv);
} }