[PATCH 02/10] mtd: partition: implement write_oob

Sascha Hauer s.hauer at pengutronix.de
Thu Jun 11 23:35:38 PDT 2015


To enable mtd_write_oob for partitions.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/mtd/partition.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/mtd/partition.c b/drivers/mtd/partition.c
index 98b9081..c11a3db 100644
--- a/drivers/mtd/partition.c
+++ b/drivers/mtd/partition.c
@@ -31,6 +31,16 @@ static int mtd_part_write(struct mtd_info *mtd, loff_t to, size_t len,
 					len, retlen, buf);
 }
 
+static int mtd_part_write_oob(struct mtd_info *mtd, loff_t to,
+		struct mtd_oob_ops *ops)
+{
+	if (to >= mtd->size)
+		return -EINVAL;
+	if (ops->datbuf && to + ops->len > mtd->size)
+		return -EINVAL;
+	return mtd->master->write_oob(mtd->master, to + mtd->master_offset, ops);
+}
+
 static int mtd_part_erase(struct mtd_info *mtd, struct erase_info *instr)
 {
 	int ret;
@@ -160,6 +170,9 @@ struct mtd_info *mtd_add_partition(struct mtd_info *mtd, off_t offset,
 		part->block_markbad = mtd->block_markbad ? mtd_part_block_markbad : NULL;
 	}
 
+	if (mtd->write_oob)
+		part->write_oob = mtd_part_write_oob;
+
 	part->block_isbad = mtd->block_isbad ? mtd_part_block_isbad : NULL;
 	part->size = size;
 	part->name = xstrdup(name);
-- 
2.1.4




More information about the barebox mailing list