net/enc28j60: section fix
[pandora-kernel.git] / drivers / mtd / cmdlinepart.c
index a7a7bfe..e472a0e 100644 (file)
@@ -9,7 +9,7 @@
  *
  * mtdparts=<mtddef>[;<mtddef]
  * <mtddef>  := <mtd-id>:<partdef>[,<partdef>]
- * <partdef> := <size>[@offset][<name>][ro]
+ * <partdef> := <size>[@offset][<name>][ro][lk]
  * <mtd-id>  := unique name used in mapping driver/device (mtd->name)
  * <size>    := standard linux memsize OR "-" to denote all remaining space
  * <name>    := '(' NAME ')'
@@ -119,7 +119,8 @@ static struct mtd_partition * newpart(char *s,
                char *p;
 
                name = ++s;
-               if ((p = strchr(name, delim)) == 0)
+               p = strchr(name, delim);
+               if (!p)
                {
                        printk(KERN_ERR ERRP "no closing %c found in partition name\n", delim);
                        return NULL;
@@ -143,6 +144,13 @@ static struct mtd_partition * newpart(char *s,
                s += 2;
         }
 
+        /* if lk is found do NOT unlock the MTD partition*/
+        if (strncmp(s, "lk", 2) == 0)
+       {
+               mask_flags |= MTD_POWERUP_LOCK;
+               s += 2;
+        }
+
        /* test if more partitions are following */
        if (*s == ',')
        {
@@ -152,9 +160,10 @@ static struct mtd_partition * newpart(char *s,
                        return NULL;
                }
                /* more partitions follow, parse them */
-               if ((parts = newpart(s + 1, &s, num_parts,
-                                    this_part + 1, &extra_mem, extra_mem_size)) == 0)
-                 return NULL;
+               parts = newpart(s + 1, &s, num_parts, this_part + 1,
+                               &extra_mem, extra_mem_size);
+               if (!parts)
+                       return NULL;
        }
        else
        {       /* this is the last partition: allocate space for all */
@@ -163,13 +172,12 @@ static struct mtd_partition * newpart(char *s,
                *num_parts = this_part + 1;
                alloc_size = *num_parts * sizeof(struct mtd_partition) +
                             extra_mem_size;
-               parts = kmalloc(alloc_size, GFP_KERNEL);
+               parts = kzalloc(alloc_size, GFP_KERNEL);
                if (!parts)
                {
                        printk(KERN_ERR ERRP "out of memory\n");
                        return NULL;
                }
-               memset(parts, 0, alloc_size);
                extra_mem = (unsigned char *)(parts + *num_parts);
        }
        /* enter this partition (offset will be calculated later if it is zero at this point) */
@@ -302,9 +310,6 @@ static int parse_cmdline_partitions(struct mtd_info *master,
        struct cmdline_mtd_partition *part;
        char *mtd_id = master->name;
 
-       if(!cmdline)
-               return -EINVAL;
-
        /* parse command line */
        if (!cmdline_parsed)
                mtdpart_setup_real(cmdline);
@@ -335,7 +340,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,
                        return part->num_parts;
                }
        }
-       return -EINVAL;
+       return 0;
 }
 
 
@@ -346,7 +351,7 @@ static int parse_cmdline_partitions(struct mtd_info *master,
  *
  * This function needs to be visible for bootloaders.
  */
-int mtdpart_setup(char *s)
+static int mtdpart_setup(char *s)
 {
        cmdline = s;
        return 1;