From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: David Woodhouse <dwmw2@infradead.org>,
Russell King <linux@arm.linux.org.uk>,
dedekind1@gmail.com
Subject: [PATCH 1/3] mtd: add a flags for partitions which should just leave smth. after them
Date: Mon, 6 Jun 2011 18:04:14 +0400 [thread overview]
Message-ID: <1307369056-29319-2-git-send-email-dbaryshkov@gmail.com> (raw)
In-Reply-To: <1307369056-29319-1-git-send-email-dbaryshkov@gmail.com>
Add support for MTDPART_OFS_RETAIN: such partitions start at the current
offset, take as much space as possible, but rain part->size bytes after
the end of the partitions for other parts. Primarily this is intended
for ts72xx arm platforms cleanup.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/mtdpart.c | 13 +++++++++++++
include/linux/mtd/partitions.h | 5 ++++-
2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 3477e16..63c19f9 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -479,6 +479,19 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
(unsigned long long)cur_offset, (unsigned long long)slave->offset);
}
}
+ if (slave->offset == MTDPART_OFS_RETAIN) {
+ slave->offset = cur_offset;
+ if (master->size - slave->offset >= slave->mtd.size) {
+ slave->mtd.size =
+ master->size - slave->offset - slave->mtd.size;
+ } else {
+ printk(KERN_ERR "mtd partition \"%s\" doesn't have enough space: %#llx < %#llx, disabled\n",
+ part->name,
+ master->size - slave->offset, slave->mtd.size);
+ /* register to preserve ordering */
+ goto out_register;
+ }
+ }
if (slave->mtd.size == MTDPART_SIZ_FULL)
slave->mtd.size = master->size - slave->offset;
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 08c9c7b..1431cf2 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -24,7 +24,9 @@
* will extend to the end of the master MTD device.
* offset: absolute starting position within the master MTD device; if
* defined as MTDPART_OFS_APPEND, the partition will start where the
- * previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block.
+ * previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block;
+ * if MTDPART_OFS_RETAIN, consume as much as possible, leaving size
+ * after the end of partition.
* mask_flags: contains flags that have to be masked (removed) from the
* master MTD flag set for the corresponding MTD partition.
* For example, to force a read-only partition, simply adding
@@ -42,6 +44,7 @@ struct mtd_partition {
struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */
};
+#define MTDPART_OFS_RETAIN (-3)
#define MTDPART_OFS_NXTBLK (-2)
#define MTDPART_OFS_APPEND (-1)
#define MTDPART_SIZ_FULL (0)
--
1.7.4.4
next prev parent reply other threads:[~2011-06-06 14:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-06 14:04 [PATCH 0/3] mtd: cleanup plat-nand/ts72xx partitions interface Dmitry Eremin-Solenikov
2011-06-06 14:04 ` Dmitry Eremin-Solenikov [this message]
2011-06-07 4:20 ` [PATCH 1/3] mtd: add a flags for partitions which should just leave smth. after them Artem Bityutskiy
2011-06-06 14:04 ` [PATCH 2/3] ts72xx: use MTDPART_OFS_RETAIN for mtd partitioning Dmitry Eremin-Solenikov
2011-06-06 14:04 ` Dmitry Eremin-Solenikov
2011-06-11 9:22 ` Petr Štetiar
2011-07-08 15:35 ` Petr Štetiar
2011-06-11 10:38 ` Petr Štetiar
2011-06-11 10:38 ` Petr Štetiar
2011-06-11 21:02 ` Dmitry Eremin-Solenikov
2011-06-11 21:02 ` Dmitry Eremin-Solenikov
2011-06-06 14:04 ` [PATCH 3/3] mtd: plat-nand: drop unused fields from platform_nand_data Dmitry Eremin-Solenikov
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=1307369056-29319-2-git-send-email-dbaryshkov@gmail.com \
--to=dbaryshkov@gmail.com \
--cc=dedekind1@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux@arm.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.