* [PATCH] mtd: allow multiple -(name) parts on cmdline.
@ 2018-11-05 13:37 Daniel Danzberger
2018-11-05 14:39 ` Boris Brezillon
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Danzberger @ 2018-11-05 13:37 UTC (permalink / raw)
To: linux-mtd; +Cc: Daniel Danzberger
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] mtd: allow multiple -(name) parts on cmdline.
2018-11-05 13:37 [PATCH] mtd: allow multiple -(name) parts on cmdline Daniel Danzberger
@ 2018-11-05 14:39 ` Boris Brezillon
0 siblings, 0 replies; 2+ messages in thread
From: Boris Brezillon @ 2018-11-05 14:39 UTC (permalink / raw)
To: Daniel Danzberger; +Cc: linux-mtd, Rafał Miłecki
+Rafal for the subpartition stuff
Hi Daniel,
On Mon, 5 Nov 2018 14:37:52 +0100
Daniel Danzberger <daniel@dd-wrt.com> wrote:
> 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)
Now that Rafal introduced sub-partitioning support I'd prefer to go for
this solution. If I take your example, that would give something like:
mtdparts=physmap-flash.0:256k(uboot),128k(params),-(firmware);firmware:1966080(kernel),-(rootfs)
I'm not entirely sure, but I think all you'd have to do to support that
is add "cmdline" to the default_subpartition_type[] array [1] (or
simply use default_partition_type since default_subpartition_type and
default_partition_type would be the same after this change).
Regards,
Boris
[1]https://elixir.bootlin.com/linux/latest/source/drivers/mtd/mtdpart.c#L800
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-05 14:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-05 13:37 [PATCH] mtd: allow multiple -(name) parts on cmdline Daniel Danzberger
2018-11-05 14:39 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox