mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
drivers/: Fixes to spacing and alignement
This commit is contained in:
@@ -251,12 +251,18 @@ static int at45db_ioctl(FAR struct mtd_dev_s *mtd, int cmd, unsigned long arg);
|
||||
/* Chip erase sequence */
|
||||
|
||||
#define CHIP_ERASE_SIZE 4
|
||||
static const uint8_t g_chiperase[CHIP_ERASE_SIZE] = {0xc7, 0x94, 0x80, 0x9a};
|
||||
static const uint8_t g_chiperase[CHIP_ERASE_SIZE] =
|
||||
{
|
||||
0xc7, 0x94, 0x80, 0x9a
|
||||
};
|
||||
|
||||
/* Sequence to program the device to binary page sizes{256, 512, 1024} */
|
||||
|
||||
#define BINPGSIZE_SIZE 4
|
||||
static const uint8_t g_binpgsize[BINPGSIZE_SIZE] = {0x3d, 0x2a, 0x80, 0xa6};
|
||||
static const uint8_t g_binpgsize[BINPGSIZE_SIZE] =
|
||||
{
|
||||
0x3d, 0x2a, 0x80, 0xa6
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
@@ -270,7 +276,7 @@ static void at45db_lock(FAR struct at45db_dev_s *priv)
|
||||
{
|
||||
/* On SPI buses where there are multiple devices, it will be necessary to lock SPI
|
||||
* to have exclusive access to the buses for a sequence of transfers. The bus
|
||||
& should be locked before the chip is selected.
|
||||
* should be locked before the chip is selected.
|
||||
*
|
||||
* This is a blocking call and will not return until we have exclusive access to
|
||||
* the SPI bus. We will retain that exclusive access until the bus is unlocked.
|
||||
|
||||
@@ -87,7 +87,7 @@ int flash_eraseall(FAR const char *driver)
|
||||
|
||||
/* Open the block driver */
|
||||
|
||||
ret = open_blockdriver(driver ,0, &inode);
|
||||
ret = open_blockdriver(driver, 0, &inode);
|
||||
if (ret < 0)
|
||||
{
|
||||
fdbg("ERROR: Failed to open '%s': %d\n", driver, ret);
|
||||
|
||||
@@ -115,11 +115,13 @@ 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 *, FAR char *, size_t);
|
||||
static ssize_t mtdconfig_ioctl(FAR struct file *, int, unsigned long);
|
||||
static ssize_t mtdconfig_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static ssize_t mtdconfig_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
#ifndef CONFIG_DISABLE_POLL
|
||||
static int mtdconfig_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
bool setup);
|
||||
bool setup);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@@ -645,8 +647,6 @@ static off_t mtdconfig_ramconsolidate(FAR struct mtdconfig_struct_s *dev)
|
||||
|
||||
/* Now Write the item to the current dst_offset location */
|
||||
|
||||
//printf("REL HDR: ID=%04X,%02X Len=%4d Off=%5d Src off=%4d\n",
|
||||
// phdr->id, phdr->instance, phdr->len, dst_offset, src_offset);
|
||||
ret = mtdconfig_writebytes(dev, dst_offset, (uint8_t *) phdr,
|
||||
sizeof(hdr));
|
||||
if (ret < 0)
|
||||
@@ -815,8 +815,6 @@ retry_relocate:
|
||||
|
||||
/* Copy this entry to the destination */
|
||||
|
||||
//printf("REL HDR: ID=%04X,%02X Len=%4d Off=%5d Src off=%4d\n",
|
||||
// hdr.id, hdr.instance, hdr.len, dst_offset, src_offset);
|
||||
mtdconfig_writebytes(dev, dst_offset, (uint8_t *) &hdr, sizeof(hdr));
|
||||
src_offset += sizeof(hdr);
|
||||
dst_offset += sizeof(hdr);
|
||||
@@ -850,7 +848,7 @@ retry_relocate:
|
||||
|
||||
src_offset += sizeof(hdr) + hdr.len;
|
||||
if (src_offset + sizeof(hdr) >= (src_block + 1) * dev->erasesize ||
|
||||
src_offset == (src_block +1 ) * dev->erasesize)
|
||||
src_offset == (src_block + 1) * dev->erasesize)
|
||||
{
|
||||
/* No room left at end of source block */
|
||||
|
||||
@@ -1181,8 +1179,7 @@ retry_find:
|
||||
hdr.instance = pdata->instance;
|
||||
hdr.len = pdata->len;
|
||||
hdr.flags = MTD_ERASED_FLAGS;
|
||||
//printf("SAV HDR: ID=%04X,%02X Len=%4d Off=%5d\n",
|
||||
// hdr.id, hdr.instance, hdr.len, offset);
|
||||
|
||||
mtdconfig_writebytes(dev, offset, (uint8_t *)&hdr, sizeof(hdr));
|
||||
bytes = mtdconfig_writebytes(dev, offset + sizeof(hdr), pdata->configdata,
|
||||
pdata->len);
|
||||
@@ -1311,7 +1308,7 @@ static int mtdconfig_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
{
|
||||
if (setup)
|
||||
{
|
||||
fds->revents |= (fds->events & (POLLIN|POLLOUT));
|
||||
fds->revents |= (fds->events & (POLLIN | POLLOUT));
|
||||
if (fds->revents != 0)
|
||||
{
|
||||
sem_post(fds->sem);
|
||||
|
||||
@@ -250,8 +250,8 @@ static int nand_checkblock(FAR struct nand_dev_s *nand, off_t block)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
//#ifdef CONFIG_MTD_NAND_BLOCKCHECK
|
||||
#if defined(CONFIG_MTD_NAND_BLOCKCHECK) && defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_DEBUG_FS)
|
||||
#if defined(CONFIG_MTD_NAND_BLOCKCHECK) && defined(CONFIG_DEBUG_VERBOSE) && \
|
||||
defined(CONFIG_DEBUG_FS)
|
||||
static int nand_devscan(FAR struct nand_dev_s *nand)
|
||||
{
|
||||
FAR struct nand_raw_s *raw;
|
||||
@@ -329,7 +329,7 @@ static int nand_devscan(FAR struct nand_dev_s *nand)
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_MTD_NAND_BLOCKCHECK */
|
||||
#endif /* CONFIG_MTD_NAND_BLOCKCHECK && CONFIG_DEBUG_VERBOSE && CONFIG_DEBUG_FS */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nand_chipid
|
||||
|
||||
@@ -327,12 +327,12 @@ void nandscheme_writeextra(FAR const struct nand_scheme_s *scheme,
|
||||
FAR uint8_t *spare, FAR const void *extra,
|
||||
unsigned int size, unsigned int offset)
|
||||
{
|
||||
DEBUGASSERT((size + offset) < scheme->nxbytes);
|
||||
DEBUGASSERT((size + offset) < scheme->nxbytes);
|
||||
|
||||
uint32_t i;
|
||||
for (i = 0; i < size; i++) {
|
||||
|
||||
spare[scheme->xbytepos[i+offset]] = ((uint8_t *) extra)[i];
|
||||
uint32_t i;
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
spare[scheme->xbytepos[i+offset]] = ((uint8_t *) extra)[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -328,39 +328,39 @@ int onfi_read(uintptr_t cmdaddr, uintptr_t addraddr, uintptr_t dataaddr,
|
||||
|
||||
/* JEDEC manufacturer ID */
|
||||
|
||||
onfi->manufacturer = *(uint8_t *)(parmtab + 64);
|
||||
onfi->manufacturer = *(FAR uint8_t *)(parmtab + 64);
|
||||
|
||||
/* Bus width */
|
||||
|
||||
onfi->buswidth = (*(uint8_t *)(parmtab + 6)) & 0x01;
|
||||
onfi->buswidth = (*(FAR uint8_t *)(parmtab + 6)) & 0x01;
|
||||
|
||||
/* Get number of data bytes per page (bytes 80-83 in the param table) */
|
||||
|
||||
onfi->pagesize = *(uint32_t *)(void*)(parmtab + 80);
|
||||
onfi->pagesize = *(FAR uint32_t *)(FAR void *)(parmtab + 80);
|
||||
|
||||
/* Get number of spare bytes per page (bytes 84-85 in the param table) */
|
||||
|
||||
onfi->sparesize = *(uint16_t *)(void*)(parmtab + 84);
|
||||
onfi->sparesize = *(FAR uint16_t *)(FAR voidFAR *)(parmtab + 84);
|
||||
|
||||
/* Number of pages per block. */
|
||||
|
||||
onfi->pagesperblock = *(uint32_t *)(void*)(parmtab + 92);
|
||||
onfi->pagesperblock = *(FAR uint32_t *)(FAR void *)(parmtab + 92);
|
||||
|
||||
/* Number of blocks per logical unit (LUN). */
|
||||
|
||||
onfi->blocksperlun = *(uint32_t *)(void*)(parmtab + 96);
|
||||
onfi->blocksperlun = *(FAR uint32_t *)(FAR void *)(parmtab + 96);
|
||||
|
||||
/* Number of logical units. */
|
||||
|
||||
onfi->luns = *(uint8_t *)(parmtab + 100);
|
||||
onfi->luns = *(FAR uint8_t *)(parmtab + 100);
|
||||
|
||||
/* Number of bits of ECC correction */
|
||||
|
||||
onfi->eccsize = *(uint8_t *)(parmtab + 112);
|
||||
onfi->eccsize = *(FAR uint8_t *)(parmtab + 112);
|
||||
|
||||
/* Device model */
|
||||
|
||||
onfi->model= *(uint8_t *)(parmtab + 49);
|
||||
onfi->model = *(FAR uint8_t *)(parmtab + 49);
|
||||
|
||||
fvdbg("Returning:\n");
|
||||
fvdbg(" manufacturer: 0x%02x\n", onfi->manufacturer);
|
||||
@@ -483,7 +483,7 @@ bool onfi_ebidetect(uintptr_t cmdaddr, uintptr_t addraddr,
|
||||
ids[2] = READ_NAND(dataaddr);
|
||||
ids[3] = READ_NAND(dataaddr);
|
||||
|
||||
for (i = 0; i< NAND_NMODELS ; i++)
|
||||
for (i = 0; i < NAND_NMODELS ; i++)
|
||||
{
|
||||
if (g_nandmodels[i].devid == ids[1])
|
||||
{
|
||||
|
||||
@@ -739,7 +739,7 @@ static int part_procfs_stat(const char *relpath, struct stat *buf)
|
||||
{
|
||||
/* File/directory size, access block size */
|
||||
|
||||
buf->st_mode = S_IFREG|S_IROTH|S_IRGRP|S_IRUSR;
|
||||
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
|
||||
buf->st_size = 0;
|
||||
buf->st_blksize = 0;
|
||||
buf->st_blocks = 0;
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
//#include <sys/statfs.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -304,7 +303,7 @@ static int mtd_stat(const char *relpath, struct stat *buf)
|
||||
{
|
||||
/* File/directory size, access block size */
|
||||
|
||||
buf->st_mode = S_IFREG|S_IROTH|S_IRGRP|S_IRUSR;
|
||||
buf->st_mode = S_IFREG | S_IROTH | S_IRGRP | S_IRUSR;
|
||||
buf->st_size = 0;
|
||||
buf->st_blksize = 0;
|
||||
buf->st_blocks = 0;
|
||||
|
||||
@@ -295,7 +295,7 @@ static int mtd_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
|
||||
/* Then invalidate in cached data */
|
||||
|
||||
ret = rwb_invalidate(&priv->rwb,0, priv->rwb.nblocks);
|
||||
ret = rwb_invalidate(&priv->rwb, 0, priv->rwb.nblocks);
|
||||
if (ret < 0)
|
||||
{
|
||||
fdbg("ERROR: rwb_invalidate failed: %d\n", ret);
|
||||
|
||||
@@ -395,7 +395,7 @@ static int ram_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
{
|
||||
/* Return (void*) base address of device memory */
|
||||
|
||||
*ppv = (FAR void*)priv->start;
|
||||
*ppv = (FAR void *)priv->start;
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ struct s512_dev_s
|
||||
size_t sectperblock; /* Number of read/write sectors per erase block */
|
||||
uint16_t stdperblock; /* Number of 512 byte sectors in one erase block */
|
||||
uint8_t flags; /* Buffered sector flags */
|
||||
uint32_t eblockno; /* Erase sector number in the cache*/
|
||||
uint32_t eblockno; /* Erase sector number in the cache */
|
||||
FAR uint8_t *eblock; /* Allocated erase block */
|
||||
};
|
||||
|
||||
@@ -269,9 +269,9 @@ static int s512_erase(FAR struct mtd_dev_s *dev, off_t sector512, size_t nsector
|
||||
}
|
||||
|
||||
/* 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))
|
||||
{
|
||||
@@ -538,7 +538,7 @@ static int s512_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
if (ret >= 0)
|
||||
{
|
||||
priv->flags = 0; /* Buffered sector flags */
|
||||
priv->eblockno = 0; /* Erase sector number in the cache*/
|
||||
priv->eblockno = 0; /* Erase sector number in the cache */
|
||||
priv->eblock = NULL; /* Allocated erase block */
|
||||
}
|
||||
}
|
||||
@@ -588,7 +588,7 @@ FAR struct mtd_dev_s *s512_initialize(FAR struct mtd_dev_s *mtd)
|
||||
/* We expect that the block size will be >512 and an even multiple of 512 */
|
||||
|
||||
if (ret < 0 || geo.erasesize <= SECTOR_512 ||
|
||||
(geo.erasesize & ~MASK_512) != geo.erasesize )
|
||||
(geo.erasesize & ~MASK_512) != geo.erasesize)
|
||||
{
|
||||
fdbg("ERROR: MTDIOC_GEOMETRY ioctl returned %d, eraseize=%d\n",
|
||||
ret, geo.erasesize);
|
||||
|
||||
+56
-54
@@ -277,8 +277,8 @@ struct smart_struct_s
|
||||
#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS
|
||||
struct smart_multiroot_device_s
|
||||
{
|
||||
FAR struct smart_struct_s* dev;
|
||||
uint8_t rootdirnum;
|
||||
FAR struct smart_struct_s *dev;
|
||||
uint8_t rootdirnum;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -440,10 +440,10 @@ static int smart_close(FAR struct inode *inode)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_MTD_SMART_ALLOC_DEBUG
|
||||
FAR static void* smart_malloc(FAR struct smart_struct_s *dev,
|
||||
FAR static void *smart_malloc(FAR struct smart_struct_s *dev,
|
||||
size_t bytes, const char *name)
|
||||
{
|
||||
void* ret = kmm_malloc(bytes);
|
||||
FAR void *ret = kmm_malloc(bytes);
|
||||
uint8_t x;
|
||||
|
||||
/* Keep track of the total allocation */
|
||||
@@ -479,7 +479,7 @@ FAR static void* smart_malloc(FAR struct smart_struct_s *dev,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_MTD_SMART_ALLOC_DEBUG
|
||||
static void smart_free(FAR struct smart_struct_s *dev, FAR void* ptr)
|
||||
static void smart_free(FAR struct smart_struct_s *dev, FAR void *ptr)
|
||||
{
|
||||
uint8_t x;
|
||||
|
||||
@@ -505,7 +505,7 @@ static void smart_free(FAR struct smart_struct_s *dev, FAR void* ptr)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_MTD_SMART_PACK_COUNTS
|
||||
static void smart_set_count(FAR struct smart_struct_s *dev, FAR uint8_t* pCount,
|
||||
static void smart_set_count(FAR struct smart_struct_s *dev, FAR uint8_t *pCount,
|
||||
uint16_t block, uint8_t count)
|
||||
{
|
||||
if (dev->sectorsPerBlk > 16)
|
||||
@@ -533,11 +533,11 @@ static void smart_set_count(FAR struct smart_struct_s *dev, FAR uint8_t* pCount,
|
||||
{
|
||||
if (count == 16)
|
||||
{
|
||||
pCount[(dev->geo.neraseblocks >> 1) + (block>>3)] |= 1 << (block & 0x07);
|
||||
pCount[(dev->geo.neraseblocks >> 1) + (block >> 3)] |= 1 << (block & 0x07);
|
||||
}
|
||||
else
|
||||
{
|
||||
pCount[(dev->geo.neraseblocks >> 1) + (block>>3)] &= ~(1 << (block & 0x07));
|
||||
pCount[(dev->geo.neraseblocks >> 1) + (block >> 3)] &= ~(1 << (block & 0x07));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -554,7 +554,7 @@ static void smart_set_count(FAR struct smart_struct_s *dev, FAR uint8_t* pCount,
|
||||
|
||||
#ifdef CONFIG_MTD_SMART_PACK_COUNTS
|
||||
static uint8_t smart_get_count(FAR struct smart_struct_s *dev,
|
||||
FAR uint8_t* pCount, uint16_t block)
|
||||
FAR uint8_t *pCount, uint16_t block)
|
||||
{
|
||||
uint8_t count;
|
||||
|
||||
@@ -581,7 +581,7 @@ static uint8_t smart_get_count(FAR struct smart_struct_s *dev,
|
||||
|
||||
if (dev->sectorsPerBlk == 16)
|
||||
{
|
||||
if (pCount[(dev->geo.neraseblocks >> 1) + (block>>3)] & (1 << (block & 0x07)))
|
||||
if (pCount[(dev->geo.neraseblocks >> 1) + (block >> 3)] & (1 << (block & 0x07)))
|
||||
{
|
||||
count |= 0x10;
|
||||
}
|
||||
@@ -600,7 +600,7 @@ static uint8_t smart_get_count(FAR struct smart_struct_s *dev,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_MTD_SMART_PACK_COUNTS
|
||||
static void smart_add_count(struct smart_struct_s *dev, uint8_t* pCount,
|
||||
static void smart_add_count(struct smart_struct_s *dev, uint8_t *pCount,
|
||||
uint16_t block, int adder)
|
||||
{
|
||||
int16_t value;
|
||||
@@ -675,7 +675,7 @@ int smart_checkfree(FAR struct smart_struct_s *dev, int lineno)
|
||||
}
|
||||
|
||||
/* Modifiy the freesector count to reflect the actual calculated freecount
|
||||
to get us back in line.
|
||||
* to get us back in line.
|
||||
*/
|
||||
|
||||
dev->freesectors = freecount;
|
||||
@@ -761,13 +761,13 @@ static ssize_t smart_reload(struct smart_struct_s *dev, FAR uint8_t *buffer,
|
||||
static ssize_t smart_read(FAR struct inode *inode, unsigned char *buffer,
|
||||
size_t start_sector, unsigned int nsectors)
|
||||
{
|
||||
struct smart_struct_s *dev;
|
||||
FAR struct smart_struct_s *dev;
|
||||
|
||||
fvdbg("SMART: sector: %d nsectors: %d\n", start_sector, nsectors);
|
||||
|
||||
DEBUGASSERT(inode && inode->i_private);
|
||||
#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS
|
||||
dev = ((struct smart_multiroot_device_s*) inode->i_private)->dev;
|
||||
dev = ((FAR struct smart_multiroot_device_s *)inode->i_private)->dev;
|
||||
#else
|
||||
dev = (struct smart_struct_s *)inode->i_private;
|
||||
#endif
|
||||
@@ -803,7 +803,7 @@ static ssize_t smart_write(FAR struct inode *inode,
|
||||
|
||||
DEBUGASSERT(inode && inode->i_private);
|
||||
#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS
|
||||
dev = ((FAR struct smart_multiroot_device_s*) inode->i_private)->dev;
|
||||
dev = ((FAR struct smart_multiroot_device_s *)inode->i_private)->dev;
|
||||
#else
|
||||
dev = (FAR struct smart_struct_s *)inode->i_private;
|
||||
#endif
|
||||
@@ -912,7 +912,7 @@ static int smart_geometry(FAR struct inode *inode, struct geometry *geometry)
|
||||
if (geometry)
|
||||
{
|
||||
#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS
|
||||
dev = ((FAR struct smart_multiroot_device_s*) inode->i_private)->dev;
|
||||
dev = ((FAR struct smart_multiroot_device_s *)inode->i_private)->dev;
|
||||
#else
|
||||
dev = (FAR struct smart_struct_s *)inode->i_private;
|
||||
#endif
|
||||
@@ -1500,7 +1500,7 @@ static uint16_t smart_cache_lookup(FAR struct smart_struct_s *dev, uint16_t logi
|
||||
/* This is the sector we are looking for! Add it to the cache */
|
||||
|
||||
physical = block * dev->sectorsPerBlk + sector;
|
||||
smart_add_sector_to_cache(dev, logical, physical, __LINE__ );
|
||||
smart_add_sector_to_cache(dev, logical, physical, __LINE__);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1543,7 +1543,7 @@ static void smart_update_cache(FAR struct smart_struct_s *dev, uint16_t
|
||||
dev->sCache[x].physical = physical;
|
||||
|
||||
/* If we are freeing a sector, then remove the logical entry from
|
||||
the cache.
|
||||
* the cache.
|
||||
*/
|
||||
|
||||
if (physical == 0xFFFF)
|
||||
@@ -1739,7 +1739,8 @@ static int smart_set_wear_level(FAR struct smart_struct_s *dev, uint16_t block,
|
||||
}
|
||||
|
||||
/* Test if this was the min level. If it was, then
|
||||
we need to rescan for min. */
|
||||
* we need to rescan for min.
|
||||
*/
|
||||
|
||||
if (oldlevel == dev->minwearlevel)
|
||||
{
|
||||
@@ -1973,7 +1974,7 @@ static int smart_scan(FAR struct smart_struct_s *dev)
|
||||
/* Read the sector data */
|
||||
|
||||
ret = MTD_READ(dev->mtd, readaddress, 32,
|
||||
(FAR uint8_t*) dev->rwbuffer);
|
||||
(FAR uint8_t *)dev->rwbuffer);
|
||||
if (ret != 32)
|
||||
{
|
||||
fdbg("Error reading physical sector %d.\n", sector);
|
||||
@@ -1986,12 +1987,13 @@ static int smart_scan(FAR struct smart_struct_s *dev)
|
||||
dev->rwbuffer[SMART_FMT_POS2] != SMART_FMT_SIG2 ||
|
||||
dev->rwbuffer[SMART_FMT_POS3] != SMART_FMT_SIG3 ||
|
||||
dev->rwbuffer[SMART_FMT_POS4] != SMART_FMT_SIG4)
|
||||
{
|
||||
/* Invalid signature on a sector claiming to be sector 0!
|
||||
* What should we do? Release it?*/
|
||||
{
|
||||
/* Invalid signature on a sector claiming to be sector 0!
|
||||
* What should we do? Release it?
|
||||
*/
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Mark the volume as formatted and set the sector size */
|
||||
|
||||
@@ -2023,8 +2025,8 @@ static int smart_scan(FAR struct smart_struct_s *dev)
|
||||
* the SMART device structure and the root directory number.
|
||||
*/
|
||||
|
||||
rootdirdev = (struct smart_multiroot_device_s*) smart_malloc(dev,
|
||||
sizeof(*rootdirdev), "Root Dir");
|
||||
rootdirdev = (struct smart_multiroot_device_s *)
|
||||
smart_malloc(dev, sizeof(*rootdirdev), "Root Dir");
|
||||
if (rootdirdev == NULL)
|
||||
{
|
||||
fdbg("Memory alloc failed\n");
|
||||
@@ -2210,7 +2212,7 @@ static int smart_scan(FAR struct smart_struct_s *dev)
|
||||
|
||||
if (logicalsector < SMART_FIRST_ALLOC_SECTOR)
|
||||
{
|
||||
smart_add_sector_to_cache(dev, logicalsector, sector, __LINE__ );
|
||||
smart_add_sector_to_cache(dev, logicalsector, sector, __LINE__);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2927,7 +2929,7 @@ static inline int smart_llformat(FAR struct smart_struct_s *dev, unsigned long a
|
||||
for (x = 0; x < dev->neraseblocks; x++)
|
||||
{
|
||||
/* Test for a geometry with 65536 sectors. We allow this, though
|
||||
we never use the last two sectors in this mode.
|
||||
* we never use the last two sectors in this mode.
|
||||
*/
|
||||
|
||||
if (x == dev->neraseblocks && dev->totalsectors == 65534)
|
||||
@@ -3304,7 +3306,7 @@ static int smart_relocate_block(FAR struct smart_struct_s *dev, uint16_t block)
|
||||
if (x == dev->neraseblocks && dev->totalsectors == 65534)
|
||||
{
|
||||
/* We can't use the last two sectors on a 65536 sector device,
|
||||
so "pre-release" them so they never get allocated.
|
||||
* so "pre-release" them so they never get allocated.
|
||||
*/
|
||||
|
||||
prerelease = 2;
|
||||
@@ -3531,7 +3533,7 @@ retry:
|
||||
#ifdef CONFIG_MTD_SMART_ENABLE_CRC
|
||||
/* First check if there is a temporary alloc in place */
|
||||
|
||||
FAR struct smart_allocsector_s* allocsect;
|
||||
FAR struct smart_allocsector_s *allocsect;
|
||||
allocsect = dev->allocsector;
|
||||
|
||||
while (allocsect)
|
||||
@@ -3758,7 +3760,7 @@ static int smart_write_wearstatus(struct smart_struct_s *dev)
|
||||
}
|
||||
|
||||
/* Test if we need to write either total block erase count or
|
||||
uneven wearcount (or both)
|
||||
* uneven wearcount (or both)
|
||||
*/
|
||||
|
||||
if (write_buffer)
|
||||
@@ -4223,9 +4225,9 @@ static int smart_writesector(FAR struct smart_struct_s *dev,
|
||||
#endif /* CONFIG_MTD_SMART_ENABLE_CRC */
|
||||
|
||||
/* If we are not using CRC and on a device that supports re-writing
|
||||
bits from 1 to 0 without neededing a block erase, such as NOR
|
||||
FLASH, then we can simply update the data in place and don't need
|
||||
to relocate the sector. Test if we need to relocate or not.
|
||||
* bits from 1 to 0 without neededing a block erase, such as NOR
|
||||
* FLASH, then we can simply update the data in place and don't need
|
||||
* to relocate the sector. Test if we need to relocate or not.
|
||||
*/
|
||||
|
||||
if (needsrelocate)
|
||||
@@ -4532,20 +4534,20 @@ static int smart_readsector(FAR struct smart_struct_s *dev,
|
||||
|
||||
#ifdef CONFIG_MTD_SMART_ENABLE_CRC
|
||||
|
||||
/* When CRC is enabled, we read the entire sector into RAM so we can
|
||||
* validate the CRC.
|
||||
*/
|
||||
/* When CRC is enabled, we read the entire sector into RAM so we can
|
||||
* validate the CRC.
|
||||
*/
|
||||
|
||||
ret = MTD_BREAD(dev->mtd, physsector * dev->mtdBlksPerSector,
|
||||
dev->mtdBlksPerSector, (FAR uint8_t *) dev->rwbuffer);
|
||||
if (ret != dev->mtdBlksPerSector)
|
||||
{
|
||||
/* TODO: Mark the block bad */
|
||||
ret = MTD_BREAD(dev->mtd, physsector * dev->mtdBlksPerSector,
|
||||
dev->mtdBlksPerSector, (FAR uint8_t *) dev->rwbuffer);
|
||||
if (ret != dev->mtdBlksPerSector)
|
||||
{
|
||||
/* TODO: Mark the block bad */
|
||||
|
||||
fdbg("Error reading phys sector %d\n", physsector);
|
||||
ret = -EIO;
|
||||
goto errout;
|
||||
}
|
||||
fdbg("Error reading phys sector %d\n", physsector);
|
||||
ret = -EIO;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
#if SMART_STATUS_VERSION == 1
|
||||
/* Test if this sector has CRC enabled or not */
|
||||
@@ -4610,7 +4612,7 @@ static int smart_readsector(FAR struct smart_struct_s *dev,
|
||||
/* Read the sector data into the buffer */
|
||||
|
||||
readaddr = (uint32_t) physsector * dev->mtdBlksPerSector * dev->geo.blocksize +
|
||||
req->offset + sizeof(struct smart_sect_header_s);;
|
||||
req->offset + sizeof(struct smart_sect_header_s);
|
||||
|
||||
ret = MTD_READ(dev->mtd, readaddr, req->count, (FAR uint8_t *)
|
||||
req->buffer);
|
||||
@@ -4844,7 +4846,7 @@ static inline int smart_allocsector(FAR struct smart_struct_s *dev,
|
||||
dev->sMap[logsector] = physicalsector;
|
||||
#else
|
||||
dev->sBitMap[logsector >> 3] |= (1 << (logsector & 0x07));
|
||||
smart_add_sector_to_cache(dev, logsector, physicalsector, __LINE__ );
|
||||
smart_add_sector_to_cache(dev, logsector, physicalsector, __LINE__);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MTD_SMART_PACK_COUNTS
|
||||
@@ -4991,7 +4993,7 @@ static int smart_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
|
||||
DEBUGASSERT(inode && inode->i_private);
|
||||
|
||||
#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS
|
||||
dev = ((FAR struct smart_multiroot_device_s*) inode->i_private)->dev;
|
||||
dev = ((FAR struct smart_multiroot_device_s *)inode->i_private)->dev;
|
||||
#else
|
||||
dev = (FAR struct smart_struct_s *)inode->i_private;
|
||||
#endif
|
||||
@@ -5027,7 +5029,7 @@ static int smart_ioctl(FAR struct inode *inode, int cmd, unsigned long arg)
|
||||
|
||||
#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS
|
||||
ret = smart_getformat(dev, (FAR struct smart_format_s *) arg,
|
||||
((FAR struct smart_multiroot_device_s*) inode->i_private)->rootdirnum);
|
||||
((FAR struct smart_multiroot_device_s *)inode->i_private)->rootdirnum);
|
||||
#else
|
||||
ret = smart_getformat(dev, (FAR struct smart_format_s *) arg);
|
||||
#endif
|
||||
@@ -5292,8 +5294,8 @@ int smart_initialize(int minor, FAR struct mtd_dev_s *mtd, FAR const char *partn
|
||||
* the SMART device structure and the root directory number.
|
||||
*/
|
||||
|
||||
rootdirdev = (FAR struct smart_multiroot_device_s*) smart_malloc(dev,
|
||||
sizeof(*rootdirdev), "Root Dir");
|
||||
rootdirdev = (FAR struct smart_multiroot_device_s *)
|
||||
smart_malloc(dev, sizeof(*rootdirdev), "Root Dir");
|
||||
if (rootdirdev == NULL)
|
||||
{
|
||||
fdbg("register_blockdriver failed: %d\n", -ret);
|
||||
@@ -5352,7 +5354,7 @@ errout:
|
||||
#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS
|
||||
if (rootdirdev)
|
||||
{
|
||||
smart_free(dev,rootdirdev);
|
||||
smart_free(dev, rootdirdev);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+10
-8
@@ -139,8 +139,8 @@
|
||||
#define SST25_DUMMY 0xa5
|
||||
|
||||
/* Chip Geometries ******************************************************************/
|
||||
/* SST25VF512 capacity is 512Kbit (64Kbit x 8) = 64Kb (8Kb x 8)*/
|
||||
/* SST25VF010 capacity is 1Mbit (128Kbit x 8) = 128Kb (16Kb x 8*/
|
||||
/* SST25VF512 capacity is 512Kbit (64Kbit x 8) = 64Kb (8Kb x 8) */
|
||||
/* SST25VF010 capacity is 1Mbit (128Kbit x 8) = 128Kb (16Kb x 8 */
|
||||
/* SST25VF520 capacity is 2Mbit (256Kbit x 8) = 256Kb (32Kb x 8) */
|
||||
/* SST25VF540 capacity is 4Mbit (512Kbit x 8) = 512Kb (64Kb x 8) */
|
||||
/* SST25VF080 capacity is 8Mbit (1024Kbit x 8) = 1Mb (128Kb x 8) */
|
||||
@@ -199,7 +199,7 @@ struct sst25_dev_s
|
||||
|
||||
#if defined(CONFIG_SST25_SECTOR512) && !defined(CONFIG_SST25_READONLY)
|
||||
uint8_t flags; /* Buffered sector flags */
|
||||
uint16_t esectno; /* Erase sector number in the cache*/
|
||||
uint16_t esectno; /* Erase sector number in the cache */
|
||||
FAR uint8_t *sector; /* Allocated sector data */
|
||||
#endif
|
||||
};
|
||||
@@ -583,7 +583,7 @@ static void sst25_byteread(FAR struct sst25_dev_s *priv, FAR uint8_t *buffer,
|
||||
/* Wait for any preceding write or erase operation to complete. */
|
||||
|
||||
status = sst25_waitwritecomplete(priv);
|
||||
DEBUGASSERT((status & (SST25_SR_WEL|SST25_SR_BP_MASK|SST25_SR_AAI)) == 0);
|
||||
DEBUGASSERT((status & (SST25_SR_WEL | SST25_SR_BP_MASK | SST25_SR_AAI)) == 0);
|
||||
UNUSED(status);
|
||||
|
||||
/* Select this FLASH part */
|
||||
@@ -643,7 +643,7 @@ static void sst25_bytewrite(struct sst25_dev_s *priv, FAR const uint8_t *buffer,
|
||||
/* Wait for any preceding write or erase operation to complete. */
|
||||
|
||||
status = sst25_waitwritecomplete(priv);
|
||||
DEBUGASSERT((status & (SST25_SR_WEL|SST25_SR_BP_MASK|SST25_SR_AAI)) == 0);
|
||||
DEBUGASSERT((status & (SST25_SR_WEL | SST25_SR_BP_MASK | SST25_SR_AAI)) == 0);
|
||||
|
||||
/* Enable write access to the FLASH */
|
||||
|
||||
@@ -723,7 +723,7 @@ static void sst25_wordwrite(struct sst25_dev_s *priv, FAR const uint8_t *buffer,
|
||||
/* Wait for any preceding write or erase operation to complete. */
|
||||
|
||||
status = sst25_waitwritecomplete(priv);
|
||||
DEBUGASSERT((status & (SST25_SR_WEL|SST25_SR_BP_MASK|SST25_SR_AAI)) == 0);
|
||||
DEBUGASSERT((status & (SST25_SR_WEL | SST25_SR_BP_MASK | SST25_SR_AAI)) == 0);
|
||||
UNUSED(status);
|
||||
|
||||
/* Enable write access to the FLASH */
|
||||
@@ -755,7 +755,8 @@ static void sst25_wordwrite(struct sst25_dev_s *priv, FAR const uint8_t *buffer,
|
||||
/* Wait for the preceding write to complete. */
|
||||
|
||||
status = sst25_waitwritecomplete(priv);
|
||||
DEBUGASSERT((status & (SST25_SR_WEL|SST25_SR_BP_MASK|SST25_SR_AAI)) == (SST25_SR_WEL|SST25_SR_AAI));
|
||||
DEBUGASSERT((status & (SST25_SR_WEL | SST25_SR_BP_MASK | SST25_SR_AAI)) ==
|
||||
(SST25_SR_WEL | SST25_SR_AAI));
|
||||
UNUSED(status);
|
||||
|
||||
/* Decrement the word count and advance the write position */
|
||||
@@ -793,7 +794,8 @@ static void sst25_wordwrite(struct sst25_dev_s *priv, FAR const uint8_t *buffer,
|
||||
/* Wait for the preceding write to complete. */
|
||||
|
||||
status = sst25_waitwritecomplete(priv);
|
||||
DEBUGASSERT((status & (SST25_SR_WEL|SST25_SR_BP_MASK|SST25_SR_AAI)) == (SST25_SR_WEL|SST25_SR_AAI));
|
||||
DEBUGASSERT((status & (SST25_SR_WEL | SST25_SR_BP_MASK | SST25_SR_AAI)) ==
|
||||
(SST25_SR_WEL | SST25_SR_AAI));
|
||||
UNUSED(status);
|
||||
|
||||
/* Decrement the word count and advance the write position */
|
||||
|
||||
@@ -322,7 +322,7 @@ struct st25fl1_dev_s
|
||||
|
||||
#ifdef CONFIG_ST25FL1_SECTOR512
|
||||
uint8_t flags; /* Buffered sector flags */
|
||||
uint16_t esectno; /* Erase sector number in the cache*/
|
||||
uint16_t esectno; /* Erase sector number in the cache */
|
||||
FAR uint8_t *sector; /* Allocated sector data */
|
||||
#endif
|
||||
};
|
||||
|
||||
+2
-2
@@ -657,7 +657,7 @@ static void w25_byteread(FAR struct w25_dev_s *priv, FAR uint8_t *buffer,
|
||||
/* Wait for any preceding write or erase operation to complete. */
|
||||
|
||||
status = w25_waitwritecomplete(priv);
|
||||
DEBUGASSERT((status & (W25_SR_WEL|W25_SR_BP_MASK)) == 0);
|
||||
DEBUGASSERT((status & (W25_SR_WEL | W25_SR_BP_MASK)) == 0);
|
||||
|
||||
/* Make sure that writing is disabled */
|
||||
|
||||
@@ -715,7 +715,7 @@ static void w25_pagewrite(struct w25_dev_s *priv, FAR const uint8_t *buffer,
|
||||
/* Wait for any preceding write or erase operation to complete. */
|
||||
|
||||
status = w25_waitwritecomplete(priv);
|
||||
DEBUGASSERT((status & (W25_SR_WEL|W25_SR_BP_MASK)) == 0);
|
||||
DEBUGASSERT((status & (W25_SR_WEL | W25_SR_BP_MASK)) == 0);
|
||||
|
||||
/* Enable write access to the FLASH */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user