[PATCH] mtd: add mtd partition lock/unlock support

Renaud Barbier renaud.barbier at ge.com
Wed Apr 2 07:13:01 PDT 2014


This patch adds support to lock/unlock mtd partitions following changes
in the partition registration.

Signed-off-by: Renaud Barbier <renaud.barbier at ge.com>
---
 drivers/mtd/partition.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mtd/partition.c b/drivers/mtd/partition.c
index 351c583..618e9c4 100644
--- a/drivers/mtd/partition.c
+++ b/drivers/mtd/partition.c
@@ -75,6 +75,22 @@ static int mtd_part_block_markbad(struct mtd_info *mtd, loff_t ofs)
 	return res;
 }
 
+static int mtd_part_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
+{
+	if (ofs >= mtd->size)
+		return -EINVAL;
+
+	return mtd->master->lock(mtd->master, ofs + mtd->master_offset, len);
+}
+
+static int mtd_part_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
+{
+	if (ofs >= mtd->size)
+		return -EINVAL;
+
+	return mtd->master->unlock(mtd->master, ofs + mtd->master_offset, len);
+}
+
 struct mtd_info *mtd_add_partition(struct mtd_info *mtd, off_t offset, size_t size,
 		unsigned long flags, const char *name)
 {
@@ -95,6 +111,8 @@ struct mtd_info *mtd_add_partition(struct mtd_info *mtd, off_t offset, size_t si
 	part->ecclayout = mtd->ecclayout;
 	part->ecc_strength = mtd->ecc_strength;
 	part->subpage_sft = mtd->subpage_sft;
+	part->lock = mtd_part_lock;
+	part->unlock = mtd_part_unlock;
 
 	/*
 	 * find the number of eraseregions the partition includes.
-- 
1.8.3.1




More information about the barebox mailing list