mirror of
https://github.com/apache/nuttx.git
synced 2026-08-24 23:18:21 +00:00
ftl:remove erase buffer for mtd device without erase interface
When there's no erase function for mtd, we decide if we need erase_buffer based on this: 1. If we've got bad block marking, we still need the erase buffer. If a write fails, it's used to read back the entire bad block's contents before writing to a new block. 2. If we don't have bad block marking, the erase buffer isn't needed and can be skipped. Signed-off-by: jingfei <jingfei@xiaomi.com>
This commit is contained in:
parent
e823681091
commit
152ea6c4bd
1 changed files with 12 additions and 0 deletions
|
|
@ -561,6 +561,18 @@ static ssize_t ftl_flush(FAR void *priv, FAR const uint8_t *buffer,
|
|||
int nbytes;
|
||||
int ret;
|
||||
|
||||
if (dev->mtd->erase == NULL && dev->lptable == NULL)
|
||||
{
|
||||
ret = MTD_BWRITE(dev->mtd, startblock, nblocks, buffer);
|
||||
if (ret != nblocks)
|
||||
{
|
||||
ferr("ERROR: Direct write block %" PRIdOFF " failed: %d\n",
|
||||
startblock, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (dev->oflags & O_DIRECT)
|
||||
{
|
||||
/* Direct write mode */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue