From ab7ae96a1e60d83ef95f32164a1893d9edd31bb3 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 25 Nov 2020 16:52:26 +0900 Subject: [PATCH] drivers/mtd/m25px.c: Appease nxstyle --- drivers/mtd/m25px.c | 121 ++++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 55 deletions(-) diff --git a/drivers/mtd/m25px.c b/drivers/mtd/m25px.c index 42ffeeaf4c..a2f96edced 100644 --- a/drivers/mtd/m25px.c +++ b/drivers/mtd/m25px.c @@ -58,7 +58,9 @@ /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ + /* Configuration ********************************************************************/ + /* Per the data sheet, M25P10 parts can be driven with either SPI mode 0 (CPOL=0 and * CPHA=0) or mode 3 (CPOL=1 and CPHA=1). But I have heard that other devices can * operated in mode 0 or 1. So you may need to specify CONFIG_M25P_SPIMODE to @@ -92,6 +94,7 @@ #endif /* M25P Registers *******************************************************************/ + /* Identification register values */ #define M25P_MANUFACTURER CONFIG_M25P_MANUFACTURER @@ -182,6 +185,7 @@ #define M25P_MT25Q128_SUBSECT_SHIFT 12 /* Sub-Sector size 1 << 12 = 4,096 */ /* Instructions */ + /* Command Value N Description Addr Dummy Data */ #define M25P_WREN 0x06 /* 1 Write Enable 0 0 0 */ #define M25P_WRDI 0x04 /* 1 Write Disable 0 0 0 */ @@ -255,7 +259,8 @@ static inline void m25p_unlock(FAR struct spi_dev_s *dev); static inline int m25p_readid(struct m25p_dev_s *priv); static void m25p_waitwritecomplete(struct m25p_dev_s *priv); static void m25p_writeenable(struct m25p_dev_s *priv); -static inline void m25p_sectorerase(struct m25p_dev_s *priv, off_t offset, uint8_t type); +static inline void m25p_sectorerase(struct m25p_dev_s *priv, off_t offset, + uint8_t type); static inline int m25p_bulkerase(struct m25p_dev_s *priv); static inline void m25p_pagewrite(struct m25p_dev_s *priv, FAR const uint8_t *buffer, off_t offset); @@ -364,72 +369,72 @@ static inline int m25p_readid(struct m25p_dev_s *priv) if (capacity == M25P_M25P1_CAPACITY) { - /* Save the FLASH geometry */ + /* Save the FLASH geometry */ - priv->sectorshift = M25P_M25P1_SECTOR_SHIFT; - priv->nsectors = M25P_M25P1_NSECTORS; - priv->pageshift = M25P_M25P1_PAGE_SHIFT; - priv->npages = M25P_M25P1_NPAGES; - return OK; + priv->sectorshift = M25P_M25P1_SECTOR_SHIFT; + priv->nsectors = M25P_M25P1_NSECTORS; + priv->pageshift = M25P_M25P1_PAGE_SHIFT; + priv->npages = M25P_M25P1_NPAGES; + return OK; } else if (capacity == M25P_EN25F80_CAPACITY) { - /* Save the FLASH geometry */ + /* Save the FLASH geometry */ - priv->pageshift = M25P_EN25F80_PAGE_SHIFT; - priv->npages = M25P_EN25F80_NPAGES; - priv->sectorshift = M25P_EN25F80_SECTOR_SHIFT; - priv->nsectors = M25P_EN25F80_NSECTORS; + priv->pageshift = M25P_EN25F80_PAGE_SHIFT; + priv->npages = M25P_EN25F80_NPAGES; + priv->sectorshift = M25P_EN25F80_SECTOR_SHIFT; + priv->nsectors = M25P_EN25F80_NSECTORS; #ifdef CONFIG_M25P_SUBSECTOR_ERASE - priv->subsectorshift = M25P_EN25F80_SUBSECT_SHIFT; + priv->subsectorshift = M25P_EN25F80_SUBSECT_SHIFT; #endif - return OK; + return OK; } else if (capacity == M25P_M25P16_CAPACITY) { - /* Save the FLASH geometry */ + /* Save the FLASH geometry */ - priv->sectorshift = M25P_M25P16_SECTOR_SHIFT; - priv->nsectors = M25P_M25P16_NSECTORS; - priv->pageshift = M25P_M25P16_PAGE_SHIFT; - priv->npages = M25P_M25P16_NPAGES; + priv->sectorshift = M25P_M25P16_SECTOR_SHIFT; + priv->nsectors = M25P_M25P16_NSECTORS; + priv->pageshift = M25P_M25P16_PAGE_SHIFT; + priv->npages = M25P_M25P16_NPAGES; #ifdef CONFIG_M25P_SUBSECTOR_ERASE - priv->subsectorshift = M25P_M25PX16_SUBSECT_SHIFT; + priv->subsectorshift = M25P_M25PX16_SUBSECT_SHIFT; #endif - return OK; + return OK; } else if (capacity == M25P_M25P32_CAPACITY) { - /* Save the FLASH geometry */ + /* Save the FLASH geometry */ - priv->sectorshift = M25P_M25P32_SECTOR_SHIFT; - priv->nsectors = M25P_M25P32_NSECTORS; - priv->pageshift = M25P_M25P32_PAGE_SHIFT; - priv->npages = M25P_M25P32_NPAGES; + priv->sectorshift = M25P_M25P32_SECTOR_SHIFT; + priv->nsectors = M25P_M25P32_NSECTORS; + priv->pageshift = M25P_M25P32_PAGE_SHIFT; + priv->npages = M25P_M25P32_NPAGES; #ifdef CONFIG_M25P_SUBSECTOR_ERASE - priv->subsectorshift = M25P_M25PX32_SUBSECT_SHIFT; + priv->subsectorshift = M25P_M25PX32_SUBSECT_SHIFT; #endif - return OK; + return OK; } else if (capacity == M25P_M25P64_CAPACITY) { - /* Save the FLASH geometry */ + /* Save the FLASH geometry */ - priv->sectorshift = M25P_M25P64_SECTOR_SHIFT; - priv->nsectors = M25P_M25P64_NSECTORS; - priv->pageshift = M25P_M25P64_PAGE_SHIFT; - priv->npages = M25P_M25P64_NPAGES; - return OK; + priv->sectorshift = M25P_M25P64_SECTOR_SHIFT; + priv->nsectors = M25P_M25P64_NSECTORS; + priv->pageshift = M25P_M25P64_PAGE_SHIFT; + priv->npages = M25P_M25P64_NPAGES; + return OK; } else if (capacity == M25P_M25P128_CAPACITY) { - /* Save the FLASH geometry */ + /* Save the FLASH geometry */ - priv->sectorshift = M25P_M25P128_SECTOR_SHIFT; - priv->nsectors = M25P_M25P128_NSECTORS; - priv->pageshift = M25P_M25P128_PAGE_SHIFT; - priv->npages = M25P_M25P128_NPAGES; - return OK; + priv->sectorshift = M25P_M25P128_SECTOR_SHIFT; + priv->nsectors = M25P_M25P128_NSECTORS; + priv->pageshift = M25P_M25P128_PAGE_SHIFT; + priv->npages = M25P_M25P128_NPAGES; + return OK; } } else if (manufacturer == M25P_MANUFACTURER && memory == MT25Q_MEMORY_TYPE) @@ -441,16 +446,16 @@ static inline int m25p_readid(struct m25p_dev_s *priv) #endif if (capacity == M25P_MT25Q128_CAPACITY) { - /* Save the FLASH geometry */ + /* Save the FLASH geometry */ - priv->sectorshift = M25P_MT25Q128_SECTOR_SHIFT; - priv->nsectors = M25P_MT25Q128_NSECTORS; - priv->pageshift = M25P_MT25Q128_PAGE_SHIFT; - priv->npages = M25P_MT25Q128_NPAGES; + priv->sectorshift = M25P_MT25Q128_SECTOR_SHIFT; + priv->nsectors = M25P_MT25Q128_NSECTORS; + priv->pageshift = M25P_MT25Q128_PAGE_SHIFT; + priv->npages = M25P_MT25Q128_NPAGES; #ifdef CONFIG_M25P_SUBSECTOR_ERASE - priv->subsectorshift = M25P_MT25Q128_SUBSECT_SHIFT; + priv->subsectorshift = M25P_MT25Q128_SUBSECT_SHIFT; #endif - return OK; + return OK; } } @@ -780,7 +785,8 @@ static int m25p_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblock * Name: m25p_bread ************************************************************************************/ -static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, +static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, + size_t nblocks, FAR uint8_t *buffer) { FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev; @@ -788,12 +794,15 @@ static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nb finfo("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); - /* On this device, we can handle the block read just like the byte-oriented read */ + /* On this device, we can handle the block read just like the byte-oriented + * read + */ - nbytes = m25p_read(dev, startblock << priv->pageshift, nblocks << priv->pageshift, buffer); + nbytes = m25p_read(dev, startblock << priv->pageshift, + nblocks << priv->pageshift, buffer); if (nbytes > 0) { - return nbytes >> priv->pageshift; + return nbytes >> priv->pageshift; } return (int)nbytes; @@ -803,7 +812,8 @@ static ssize_t m25p_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nb * Name: m25p_bwrite ************************************************************************************/ -static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks, +static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, + size_t nblocks, FAR const uint8_t *buffer) { FAR struct m25p_dev_s *priv = (FAR struct m25p_dev_s *)dev; @@ -820,7 +830,7 @@ static ssize_t m25p_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t n m25p_pagewrite(priv, buffer, startblock); buffer += pagesize; startblock++; - } + } m25p_unlock(priv->dev); return nblocks; @@ -917,7 +927,7 @@ static ssize_t m25p_write(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes count = nbytes; pagesize = (1 << priv->pageshift); - bytestowrite = pagesize - (offset & (pagesize-1)); + bytestowrite = pagesize - (offset & (pagesize - 1)); m25p_bytewrite(priv, buffer, offset, bytestowrite); /* Update offset and count */ @@ -967,7 +977,8 @@ static int m25p_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) { 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) { /* Populate the geometry structure with information need to know