public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Daniel Danzberger <daniel@dd-wrt.com>
To: linux-mtd@lists.infradead.org
Cc: Daniel Danzberger <daniel@dd-wrt.com>
Subject: [PATCH] mtd: allow multiple -(name) parts on cmdline.
Date: Mon,  5 Nov 2018 14:37:52 +0100	[thread overview]
Message-ID: <20181105133752.27480-1-daniel@dd-wrt.com> (raw)

This allows to specify multiple -(name) SIZE_REMAINING partitions on the
commandline parser.

Example:
mtdparts=physmap-flash.0:256k(uboot),128k(params),-(firmware),1966080(kernel),-(rootfs)

Having a "firmaware" partition makes it easier to flash/erase firmware on embedded decvices.
Many platforms have such a partition already defined in their platform or device tree code.

This patch makes it possible to define such partitions
on the cmdline as well.

Signed-off-by: Daniel Danzberger <daniel@dd-wrt.com>
---
 drivers/mtd/cmdlinepart.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index 3ea44cff9b75..b011e661f8a8 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -167,10 +167,6 @@ static struct mtd_partition * newpart(char *s,
 
 	/* test if more partitions are following */
 	if (*s == ',') {
-		if (size == SIZE_REMAINING) {
-			pr_err("no partitions allowed after a fill-up partition\n");
-			return ERR_PTR(-EINVAL);
-		}
 		/* more partitions follow, parse them */
 		parts = newpart(s + 1, &s, num_parts, this_part + 1,
 				&extra_mem, extra_mem_size);
@@ -335,20 +331,28 @@ static int parse_cmdline_partitions(struct mtd_info *master,
 		return 0;
 
 	for (i = 0, offset = 0; i < part->num_parts; i++) {
+		int move_offset;
+
 		if (part->parts[i].offset == OFFSET_CONTINUOUS)
 			part->parts[i].offset = offset;
 		else
 			offset = part->parts[i].offset;
 
-		if (part->parts[i].size == SIZE_REMAINING)
+		if (part->parts[i].size == SIZE_REMAINING) {
 			part->parts[i].size = master->size - offset;
+			move_offset = 0;
+		} else {
+			move_offset = 1;
+		}
 
 		if (offset + part->parts[i].size > master->size) {
 			pr_warn("%s: partitioning exceeds flash size, truncating\n",
 				part->mtd_id);
 			part->parts[i].size = master->size - offset;
 		}
-		offset += part->parts[i].size;
+
+		if (move_offset)
+			offset += part->parts[i].size;
 
 		if (part->parts[i].size == 0) {
 			pr_warn("%s: skipping zero sized partition\n",
-- 
2.19.1

             reply	other threads:[~2018-11-05 13:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-05 13:37 Daniel Danzberger [this message]
2018-11-05 14:39 ` [PATCH] mtd: allow multiple -(name) parts on cmdline Boris Brezillon

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=20181105133752.27480-1-daniel@dd-wrt.com \
    --to=daniel@dd-wrt.com \
    --cc=linux-mtd@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