summaryrefslogtreecommitdiff
path: root/nuttx/drivers
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-05-04 18:49:53 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-05-04 18:49:53 +0000
commit29bc6e24ce51bb7b97591f5d354bc3b9b3b05602 (patch)
treeb812c7578cc5369898dc14d49913d490cd75d0de /nuttx/drivers
parent90b3f2e71415c4cb55bd40ac25b863fa4ed63818 (diff)
downloadpx4-nuttx-29bc6e24ce51bb7b97591f5d354bc3b9b3b05602.tar.gz
px4-nuttx-29bc6e24ce51bb7b97591f5d354bc3b9b3b05602.tar.bz2
px4-nuttx-29bc6e24ce51bb7b97591f5d354bc3b9b3b05602.zip
More NXFFS bugfixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3560 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers')
-rw-r--r--nuttx/drivers/mtd/rammtd.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/nuttx/drivers/mtd/rammtd.c b/nuttx/drivers/mtd/rammtd.c
index 6a2e1f4c2..a7adf4b99 100644
--- a/nuttx/drivers/mtd/rammtd.c
+++ b/nuttx/drivers/mtd/rammtd.c
@@ -127,13 +127,6 @@ static int ram_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks
DEBUGASSERT(dev);
- /* Convert the erase block to a logical block and the number of blocks
- * in logical block numbers
- */
-
- startblock *= CONFIG_RAMMTD_BLKPER;
- nblocks *= CONFIG_RAMMTD_BLKPER;
-
/* Don't let the erase exceed the size of the ram buffer */
if (startblock >= priv->nblocks)
@@ -141,11 +134,18 @@ static int ram_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks
return 0;
}
- if (startblock + nblocks >= priv->nblocks)
+ if (startblock + nblocks > priv->nblocks)
{
- nblocks = priv->nblocks - nblocks;
+ nblocks = priv->nblocks - startblock;
}
+ /* Convert the erase block to a logical block and the number of blocks
+ * in logical block numbers
+ */
+
+ startblock *= CONFIG_RAMMTD_BLKPER;
+ nblocks *= CONFIG_RAMMTD_BLKPER;
+
/* Get the offset corresponding to the first block and the size
* corresponding to the number of blocks.
*/