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:
parent
52f381fdd4
commit
4fc111965d
@ -279,19 +279,12 @@ static int filemtd_erase(FAR struct mtd_dev_s *dev, off_t 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
|
||||
* corresponding to the number of blocks.
|
||||
*/
|
||||
|
||||
offset = startblock * priv->blocksize;
|
||||
nbytes = nblocks * priv->blocksize;
|
||||
offset = startblock * priv->erasesize;
|
||||
nbytes = nblocks * priv->erasesize;
|
||||
|
||||
/* 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));
|
||||
}
|
||||
|
||||
return OK;
|
||||
return nblocks;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
x
Reference in New Issue
Block a user