mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 22:20:01 +08:00
ftl:optimize ftl's MTD_ERASE return value check
the MTD ERASE interface has inconsistent return values. Some implementations return the number of erased sectors, while others return OK (0). It is currently recommended to uniformly treat ERASE success as OK. Therefore, the logic for judging the return value of MTD_ERASE in the FTL erase interface should be changed to check if it is greater than 0. Signed-off-by: jingfei <jingfei@xiaomi.com>
This commit is contained in:
+4
-4
@@ -392,14 +392,14 @@ static ssize_t ftl_mtd_erase(FAR struct ftl_struct_s *dev, off_t startblock)
|
||||
if (dev->lptable == NULL)
|
||||
{
|
||||
ret = MTD_ERASE(dev->mtd, startblock, 1);
|
||||
if (ret != 1 && ret != -ENOSYS)
|
||||
if (ret < 0 && ret != -ENOSYS)
|
||||
{
|
||||
ferr("ERROR: Erase block %" PRIdOFF " failed: %zd\n",
|
||||
startblock, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
while (1)
|
||||
@@ -410,9 +410,9 @@ static ssize_t ftl_mtd_erase(FAR struct ftl_struct_s *dev, off_t startblock)
|
||||
}
|
||||
|
||||
ret = MTD_ERASE(dev->mtd, dev->lptable[startblock], 1);
|
||||
if (ret == 1 || ret == -ENOSYS)
|
||||
if (ret >= 0 || ret == -ENOSYS)
|
||||
{
|
||||
return 1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
MTD_MARKBAD(dev->mtd, dev->lptable[startblock]);
|
||||
|
||||
Reference in New Issue
Block a user