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:
chenrun1
2024-02-04 17:30:23 +08:00
committed by Xiang Xiao
parent 52f381fdd4
commit 4fc111965d
+3 -10
View File
@@ -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;
} }
/**************************************************************************** /****************************************************************************