Smart MTD: fix some outdated logic: geometray erase size is now 32-bits

This commit is contained in:
Gregory Nutt 2015-11-09 09:35:14 -06:00
parent 95562f8a86
commit 2ab0832c26
2 changed files with 14 additions and 28 deletions

@ -1 +1 @@
Subproject commit f475b05030ef74cea1941774716b2ba0af1c97ae
Subproject commit 8c8d6ec2de52b4a8e10abc0d36f6ac4391a1f202

View File

@ -220,7 +220,8 @@ struct smart_struct_s
uint32_t unusedsectors; /* Count of unused sectors (i.e. free when erased) */
uint32_t blockerases; /* Count of unused sectors (i.e. free when erased) */
#endif
uint16_t neraseblocks; /* Number of erase blocks or sub-sectors */
uint32_t neraseblocks; /* Number of erase blocks or sub-sectors */
uint32_t erasesize; /* Size of an erase block */
uint16_t lastallocblock; /* Last block we allocated a sector from */
uint16_t freesectors; /* Total number of free sectors */
uint16_t releasesectors; /* Total number of released sectors */
@ -228,7 +229,6 @@ struct smart_struct_s
uint16_t sectorsPerBlk; /* Number of sectors per erase block */
uint16_t sectorsize; /* Sector size on device */
uint16_t totalsectors; /* Total number of sectors on device */
uint32_t erasesize; /* Size of an erase block */
FAR uint8_t *releasecount; /* Count of released sectors per erase block */
FAR uint8_t *freecount; /* Count of free sectors per erase block */
FAR char *rwbuffer; /* Our sector read/write buffer */
@ -925,11 +925,6 @@ static int smart_geometry(FAR struct inode *inode, struct geometry *geometry)
#endif
erasesize = dev->geo.erasesize;
if (erasesize == 0)
{
erasesize = 262144;
}
geometry->geo_nsectors = dev->geo.neraseblocks * erasesize /
dev->sectorsize;
geometry->geo_sectorsize = dev->sectorsize;
@ -973,19 +968,10 @@ static int smart_setsectorsize(FAR struct smart_struct_s *dev, uint16_t size)
erasesize = dev->geo.erasesize;
dev->neraseblocks = dev->geo.neraseblocks;
/* Most FLASH devices have erase size of 64K, but geo.erasesize is only
* 16 bits, so it will be zero
*/
if (erasesize == 0)
{
erasesize = 262144;
}
dev->erasesize = erasesize;
dev->sectorsize = size;
dev->mtdBlksPerSector = dev->sectorsize / dev->geo.blocksize;
if (erasesize / dev->sectorsize > 256)
{
/* We can't throw a dbg message here becasue it is too early.