mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 20:56:47 +08:00
Fix erase block vs page block confusion in MTD partition logic. From Ken Pettit
This commit is contained in:
@@ -5917,3 +5917,6 @@
|
|||||||
header file (2013-10-30).
|
header file (2013-10-30).
|
||||||
* arch/arm/src/sama5/chip/sam_pwm.h: PWM register definition
|
* arch/arm/src/sama5/chip/sam_pwm.h: PWM register definition
|
||||||
header file (2013-10-31).
|
header file (2013-10-31).
|
||||||
|
* drivers/mtd/mtd_partition.c: Fix erase block vs page block confusion.
|
||||||
|
From Ken Pettit (2013-10-31).
|
||||||
|
|
||||||
|
|||||||
@@ -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 */
|
/* 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;
|
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 */
|
/* Erase the entire partition */
|
||||||
|
|
||||||
ret = priv->parent->erase(priv->parent, priv->firstblock,
|
ret = priv->parent->erase(priv->parent,
|
||||||
priv->neraseblocks * priv->blkpererase);
|
priv->firstblock / priv->blkpererase,
|
||||||
|
priv->neraseblocks);
|
||||||
}
|
}
|
||||||
break;
|
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");
|
fdbg("ERROR: sub-region too small\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Verify that the sub-region is valid for this geometry */
|
/* Verify that the sub-region is valid for this geometry */
|
||||||
|
|
||||||
devblocks = blkpererase * geo.neraseblocks;
|
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)
|
if (!part)
|
||||||
{
|
{
|
||||||
fdbg("ERROR: Failed to allocate memory for the partition device\n");
|
fdbg("ERROR: Failed to allocate memory for the partition device\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the partition device structure. (unsupported methods were
|
/* Initialize the partition device structure. (unsupported methods were
|
||||||
|
|||||||
Reference in New Issue
Block a user