This patch adds support to lock/unlock mtd partitions following changes in the partition registration. Signed-off-by: Renaud Barbier <renaud.barbier@xxxxxx> --- 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 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox