* [PATCH] mtd: add mtd partition lock/unlock support
@ 2014-04-02 14:13 Renaud Barbier
0 siblings, 0 replies; only message in thread
From: Renaud Barbier @ 2014-04-02 14:13 UTC (permalink / raw)
To: barebox
This patch adds support to lock/unlock mtd partitions following changes
in the partition registration.
Signed-off-by: Renaud Barbier <renaud.barbier@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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-04-02 14:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-02 14:13 [PATCH] mtd: add mtd partition lock/unlock support Renaud Barbier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox