From 29bc6e24ce51bb7b97591f5d354bc3b9b3b05602 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 4 May 2011 18:49:53 +0000 Subject: More NXFFS bugfixes git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3560 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/drivers/mtd/rammtd.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'nuttx/drivers') 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. */ -- cgit v1.2.3