Use calculations on constants to (slightly) reduce code size
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4077 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
2cb6ea3f2f
commit
7c1d6619fa
@ -2190,5 +2190,5 @@
|
||||
has no value inodes on it.
|
||||
* drivers/mtd/at24xx.c: Now supports a configurable block size that
|
||||
supports using "clusters" of AT24 pages as blocks. This allows bigger
|
||||
block sizes and more efficient use of FLASH when the AT24 is used to
|
||||
support a file system (such as NXFFS).
|
||||
block sizes and more efficient use of EEPROM when the AT24 is used to
|
||||
support a file system (such as NXFFS). (Contributed by Hal Glenn).
|
||||
|
@ -204,8 +204,8 @@ static ssize_t at24c_bread(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||
size_t blocksleft;
|
||||
|
||||
#if CONFIG_AT24XX_MTD_BLOCKSIZE > AT24XX_PAGESIZE
|
||||
startblock *= CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE;
|
||||
nblocks *= CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE;
|
||||
startblock *= (CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE);
|
||||
nblocks *= (CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE);
|
||||
#endif
|
||||
blocksleft = nblocks;
|
||||
|
||||
@ -264,8 +264,8 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t
|
||||
uint8_t buf[AT24XX_PAGESIZE+2];
|
||||
|
||||
#if CONFIG_AT24XX_MTD_BLOCKSIZE > AT24XX_PAGESIZE
|
||||
startblock *= CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE;
|
||||
nblocks *= CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE;
|
||||
startblock *= (CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE);
|
||||
nblocks *= (CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE);
|
||||
#endif
|
||||
blocksleft = nblocks;
|
||||
|
||||
@ -302,7 +302,7 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t
|
||||
}
|
||||
|
||||
#if CONFIG_AT24XX_MTD_BLOCKSIZE > AT24XX_PAGESIZE
|
||||
return nblocks /(CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE);
|
||||
return nblocks / (CONFIG_AT24XX_MTD_BLOCKSIZE / AT24XX_PAGESIZE);
|
||||
#else
|
||||
return nblocks;
|
||||
#endif
|
||||
@ -343,13 +343,14 @@ static int at24c_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
|
||||
* It has to be at least as big as the blocksize, bigger serves no
|
||||
* purpose.
|
||||
* neraseblocks
|
||||
* Note that the device size is in kb, so * 1024 / 8 for bytes
|
||||
* Note that the device size is in kilobits and must be scaled by
|
||||
* 1024 / 8
|
||||
*/
|
||||
|
||||
#if CONFIG_AT24XX_MTD_BLOCKSIZE > AT24XX_PAGESIZE
|
||||
geo->blocksize = CONFIG_AT24XX_MTD_BLOCKSIZE;
|
||||
geo->erasesize = geo->blocksize;
|
||||
geo->neraseblocks = CONFIG_AT24XX_SIZE * (1024/8) / geo->erasesize;
|
||||
geo->erasesize = CONFIG_AT24XX_MTD_BLOCKSIZE;
|
||||
geo->neraseblocks = (CONFIG_AT24XX_SIZE * 1024 / 8) / CONFIG_AT24XX_MTD_BLOCKSIZE;
|
||||
#else
|
||||
geo->blocksize = priv->pagesize;
|
||||
geo->erasesize = priv->pagesize;
|
||||
|
Loading…
Reference in New Issue
Block a user