mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 03:45:50 +08:00
filemtd:fix Fixed the issue of incorrect content returned when using nandflash earse
Nand_erase return result should be the number of blocks that were successfully erased in NuttX Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
+3
-10
@@ -279,19 +279,12 @@ static int filemtd_erase(FAR struct mtd_dev_s *dev, off_t startblock,
|
|||||||
nblocks = priv->nblocks - startblock;
|
nblocks = priv->nblocks - startblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the erase block to a logical block and the number of blocks
|
|
||||||
* in logical block numbers
|
|
||||||
*/
|
|
||||||
|
|
||||||
startblock *= (priv->erasesize / priv->blocksize);
|
|
||||||
nblocks *= (priv->erasesize / priv->blocksize);
|
|
||||||
|
|
||||||
/* Get the offset corresponding to the first block and the size
|
/* Get the offset corresponding to the first block and the size
|
||||||
* corresponding to the number of blocks.
|
* corresponding to the number of blocks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
offset = startblock * priv->blocksize;
|
offset = startblock * priv->erasesize;
|
||||||
nbytes = nblocks * priv->blocksize;
|
nbytes = nblocks * priv->erasesize;
|
||||||
|
|
||||||
/* Then erase the data in the file */
|
/* Then erase the data in the file */
|
||||||
|
|
||||||
@@ -303,7 +296,7 @@ static int filemtd_erase(FAR struct mtd_dev_s *dev, off_t startblock,
|
|||||||
nbytes -= MIN(nbytes, sizeof(buffer));
|
nbytes -= MIN(nbytes, sizeof(buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return nblocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user