Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] mtd cmdlinepart: allow zero offset value

Current cmdlinepart.c uses offset value 0 to specify a continuous
partition. This prevents creating a second partition starting at 0.

For example, I can split 4MB device using "mtdparts=id:2M,2M", but I can
not do "mtdparts=id:2M@2M,2M@0" to swap mtd0 and mtd1.

This patch introduces special OFFSET_CONTINUOUS value for a continuous
partition and allows 0 for offset value.

Also this patch replaces 0xffffffff with UINT_MAX for SIZE_REMAINING.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Atsushi Nemoto and committed by
Linus Torvalds
b175d03d 87d10f3c

+4 -3
+4 -3
drivers/mtd/cmdlinepart.c
··· 42 42 43 43 44 44 /* special size referring to all the remaining space in a partition */ 45 - #define SIZE_REMAINING 0xffffffff 45 + #define SIZE_REMAINING UINT_MAX 46 + #define OFFSET_CONTINUOUS UINT_MAX 46 47 47 48 struct cmdline_mtd_partition { 48 49 struct cmdline_mtd_partition *next; ··· 76 75 { 77 76 struct mtd_partition *parts; 78 77 unsigned long size; 79 - unsigned long offset = 0; 78 + unsigned long offset = OFFSET_CONTINUOUS; 80 79 char *name; 81 80 int name_len; 82 81 unsigned char *extra_mem; ··· 315 314 { 316 315 for(i = 0, offset = 0; i < part->num_parts; i++) 317 316 { 318 - if (!part->parts[i].offset) 317 + if (part->parts[i].offset == OFFSET_CONTINUOUS) 319 318 part->parts[i].offset = offset; 320 319 else 321 320 offset = part->parts[i].offset;