summaryrefslogtreecommitdiff
path: root/nuttx/drivers/mtd
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-29 20:59:40 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-29 20:59:40 +0000
commit8698f6ddcaebf63f5324b3c28d95dcb315a16897 (patch)
tree45065cb6115a2b4b0f957ea0347a396add2f01a4 /nuttx/drivers/mtd
parent97093036cbd89e0992306554d0d6b8f9f796a2db (diff)
downloadpx4-nuttx-8698f6ddcaebf63f5324b3c28d95dcb315a16897.tar.gz
px4-nuttx-8698f6ddcaebf63f5324b3c28d95dcb315a16897.tar.bz2
px4-nuttx-8698f6ddcaebf63f5324b3c28d95dcb315a16897.zip
Add beginning of a test for NXFFS
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3540 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/mtd')
-rw-r--r--nuttx/drivers/mtd/rammtd.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/nuttx/drivers/mtd/rammtd.c b/nuttx/drivers/mtd/rammtd.c
index 5bdfa5017..6a2e1f4c2 100644
--- a/nuttx/drivers/mtd/rammtd.c
+++ b/nuttx/drivers/mtd/rammtd.c
@@ -168,20 +168,22 @@ static ssize_t ram_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nbl
{
FAR struct ram_dev_s *priv = (FAR struct ram_dev_s *)dev;
off_t offset;
+ off_t maxblock;
size_t nbytes;
DEBUGASSERT(dev && buf);
/* Don't let the read exceed the size of the ram buffer */
- if (startblock >= priv->nblocks)
+ maxblock = priv->nblocks * CONFIG_RAMMTD_BLKPER;
+ if (startblock >= maxblock)
{
return 0;
}
- if (startblock + nblocks >= priv->nblocks)
+ if (startblock + nblocks > maxblock)
{
- nblocks = priv->nblocks - nblocks;
+ nblocks = maxblock - startblock;
}
/* Get the offset corresponding to the first block and the size
@@ -201,25 +203,27 @@ static ssize_t ram_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nbl
* Name: ram_bwrite
****************************************************************************/
-static ssize_t ram_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
- FAR const uint8_t *buf)
+static ssize_t ram_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
+ size_t nblocks, FAR const uint8_t *buf)
{
FAR struct ram_dev_s *priv = (FAR struct ram_dev_s *)dev;
off_t offset;
+ off_t maxblock;
size_t nbytes;
DEBUGASSERT(dev && buf);
/* Don't let the write exceed the size of the ram buffer */
- if (startblock >= priv->nblocks)
+ maxblock = priv->nblocks * CONFIG_RAMMTD_BLKPER;
+ if (startblock >= maxblock)
{
return 0;
}
- if (startblock + nblocks >= priv->nblocks)
+ if (startblock + nblocks > maxblock)
{
- nblocks = priv->nblocks - nblocks;
+ nblocks = maxblock - startblock;
}
/* Get the offset corresponding to the first block and the size