From a6080e4502c74ed55c30cecced0f06a76c66e67f Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Wed, 7 Feb 2024 15:37:43 +0800 Subject: [PATCH] Revert "driver/ftl: Read the current eraseblock only" Signed-off-by: wangjianyu3 --- drivers/mtd/ftl.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index 4fdcb6fba1..5ec0a68462 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c @@ -287,7 +287,6 @@ static ssize_t ftl_mtd_bread(FAR struct ftl_struct_s *dev, off_t startblock, { off_t startphysicalblock; off_t starteraseblock; - size_t erase; size_t count; starteraseblock = startblock / dev->blkper; @@ -297,14 +296,9 @@ static ssize_t ftl_mtd_bread(FAR struct ftl_struct_s *dev, off_t startblock, break; } - erase = ftl_get_cblock(dev, starteraseblock, + count = ftl_get_cblock(dev, starteraseblock, (nblocks + mask) / dev->blkper); - count = MIN(erase * dev->blkper, nblocks); - if (erase == 1) - { - count -= startblock & mask; - } - + count = MIN(count * dev->blkper, nblocks); startphysicalblock = dev->lptable[starteraseblock] * dev->blkper + (startblock & mask); ret = MTD_BREAD(dev->mtd, startphysicalblock, count, buffer);