diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-10-31 10:40:10 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-10-31 10:40:10 -0600 |
commit | 069e297bc0c07b58594efaa2eab1ded52a307f82 (patch) | |
tree | b5ef7cfc07ee6a458795f6482fbe59380f617820 /nuttx/drivers/mtd | |
parent | e9310cadab97326be44c8a8be6ca7259cec4cc80 (diff) | |
download | px4-nuttx-069e297bc0c07b58594efaa2eab1ded52a307f82.tar.gz px4-nuttx-069e297bc0c07b58594efaa2eab1ded52a307f82.tar.bz2 px4-nuttx-069e297bc0c07b58594efaa2eab1ded52a307f82.zip |
Fix erase block vs page block confusion in MTD partition logic. From Ken Pettit
Diffstat (limited to 'nuttx/drivers/mtd')
-rw-r--r-- | nuttx/drivers/mtd/mtd_partition.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/nuttx/drivers/mtd/mtd_partition.c b/nuttx/drivers/mtd/mtd_partition.c index 699a2fa5a..91ccdc74f 100644 --- a/nuttx/drivers/mtd/mtd_partition.c +++ b/nuttx/drivers/mtd/mtd_partition.c @@ -162,9 +162,9 @@ static int part_erase(FAR struct mtd_dev_s *dev, off_t startblock, /* Make sure that erase would not extend past the end of the partition */ - if (!part_blockcheck(priv, startblock + nblocks - 1)) + if (!part_blockcheck(priv, (startblock + nblocks - 1) * priv->blkpererase)) { - fdbg("ERROR: Read beyond the end of the partition\n"); + fdbg("ERROR: Erase beyond the end of the partition\n"); return -ENXIO; } @@ -379,8 +379,9 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg) { /* Erase the entire partition */ - ret = priv->parent->erase(priv->parent, priv->firstblock, - priv->neraseblocks * priv->blkpererase); + ret = priv->parent->erase(priv->parent, + priv->firstblock / priv->blkpererase, + priv->neraseblocks); } break; @@ -461,7 +462,7 @@ FAR struct mtd_dev_s *mtd_partition(FAR struct mtd_dev_s *mtd, off_t firstblock, fdbg("ERROR: sub-region too small\n"); return NULL; } - + /* Verify that the sub-region is valid for this geometry */ devblocks = blkpererase * geo.neraseblocks; @@ -477,7 +478,7 @@ FAR struct mtd_dev_s *mtd_partition(FAR struct mtd_dev_s *mtd, off_t firstblock, if (!part) { fdbg("ERROR: Failed to allocate memory for the partition device\n"); - return NULL; + return NULL; } /* Initialize the partition device structure. (unsupported methods were |