mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Renaud Barbier <renaud.barbier@ge.com>
To: barebox@lists.infradead.org
Subject: [PATCH] mtd: add mtd partition lock/unlock support
Date: Wed,  2 Apr 2014 15:13:01 +0100	[thread overview]
Message-ID: <1396447981-18092-1-git-send-email-renaud.barbier@ge.com> (raw)

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

                 reply	other threads:[~2014-04-02 14:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1396447981-18092-1-git-send-email-renaud.barbier@ge.com \
    --to=renaud.barbier@ge.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox