[PATCH] [MTD] cmdlinepart: allow zero offset value

Atsushi Nemoto anemo at mba.ocn.ne.jp
Thu Nov 24 12:28:02 EST 2005


Current cmdlinepart.c uses offset value 0 to specify 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 at 2M,2M at 0".  In this case, I wanted to swap
mtd0 and mtd1 by command line.

This patch introduce special OFFSET_CONTINUOUS value for continuous
partition and allow 0 for offset value.

Signed-off-by: Atsushi Nemoto <anemo at mba.ocn.ne.jp>

diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index 6b8bb2e..123cfe0 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -43,6 +43,7 @@
 
 /* special size referring to all the remaining space in a partition */
 #define SIZE_REMAINING 0xffffffff
+#define OFFSET_CONTINUOUS 0xffffffff
 
 struct cmdline_mtd_partition {
 	struct cmdline_mtd_partition *next;
@@ -75,7 +76,7 @@ static struct mtd_partition * newpart(ch
 {
 	struct mtd_partition *parts;
 	unsigned long size;
-	unsigned long offset = 0;
+	unsigned long offset = OFFSET_CONTINUOUS;
 	char *name;
 	int name_len;
 	unsigned char *extra_mem;
@@ -314,7 +315,7 @@ static int parse_cmdline_partitions(stru
 		{
 			for(i = 0, offset = 0; i < part->num_parts; i++)
 			{
-				if (!part->parts[i].offset)
+				if (part->parts[i].offset == OFFSET_CONTINUOUS)
 				  part->parts[i].offset = offset;
 				else
 				  offset = part->parts[i].offset;

---
Atsushi Nemoto




More information about the linux-mtd mailing list