This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 4fc111965d1534426642f9787ebf82ff09ef5924
Author: chenrun1 <[email protected]>
AuthorDate: Sun Feb 4 17:30:23 2024 +0800

    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 <[email protected]>
---
 drivers/mtd/filemtd.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/filemtd.c b/drivers/mtd/filemtd.c
index cdb562e1ff..4857e7e414 100644
--- a/drivers/mtd/filemtd.c
+++ b/drivers/mtd/filemtd.c
@@ -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;
 }
 
 /****************************************************************************

Reply via email to