mtd/parition:MTD partiton check whether the erase interface exist

Since there is a storage device like RRAM that doesn't
require erasing, the MTD erase function may not exist.
Here, we should first check whether the erase interface
exists before performing the erasing operation.

Signed-off-by: jingfei <jingfei@xiaomi.com>
This commit is contained in:
jingfei
2025-04-30 10:38:10 +08:00
committed by Xiang Xiao
parent e8fbc997fa
commit 3559e97659

View File

@@ -901,7 +901,7 @@ FAR struct mtd_dev_s *mtd_partition(FAR struct mtd_dev_s *mtd,
* nullified by kmm_zalloc).
*/
part->child.erase = part_erase;
part->child.erase = mtd->erase ? part_erase : NULL;
part->child.bread = part_bread;
part->child.bwrite = part_bwrite;
part->child.read = mtd->read ? part_read : NULL;