Skip to contentSkip to conversation

add cmdline parsing (mtdparts=) support to cafe_nand

PATCH New Philip Rakity 1 participant 1 message Oct 8, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add cmdline parsing (mtdparts=) support to cafe_nand

Adds command line mtdparts= support for cafe_nand flash.

NOTE:
I changed where add_mtd_device was done so that there is NOT a complete flash mount point following by the partitions that were added. Before this n+1 partitions were added. 1 partition for the complete flash and then n partitions.

drivers/mtd/nand/cafe_nand.c 2008-10-08 15:52:08.000000000 -0700 renamed from drivers/mtd/nand/cafe_nand.c.orig 2008-10-08 15:47:24.000000000 -0700 +14 -5
@@ -87,8 +87,12 @@ static int timing[3];
 module_param_array(timing, int, &numtimings, 0644);
 
 #ifdef CONFIG_MTD_PARTITIONS
+#ifdef CONFIG_MTD_CMDLINE_PARTS
+static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
+#else
 static const char *part_probes[] = { "RedBoot", NULL };
 #endif
+#endif
 
 /* Hrm. Why isn't this already conditional on something in the struct device? */
 #define cafe_dev_dbg(dev, args...) do { if (debug) dev_dbg(dev, ##args); } while(0)
@@ -628,7 +632,7 @@ static int __devinit cafe_nand_probe(str
        struct cafe_priv *cafe;
        struct mtd_partition *parts;
        uint32_t ctrl;
-       int nr_parts;
+       int nr_parts = 0;
        int err = 0;
 
        /* Very old versions shared the same PCI ident for all three
@@ -796,17 +800,21 @@ static int __devinit cafe_nand_probe(str
 
        pci_set_drvdata(pdev, mtd);
 
-       /* We register the whole device first, separate from the partitions */
-       add_mtd_device(mtd);
-
 #ifdef CONFIG_MTD_PARTITIONS
+#ifdef CONFIG_MTD_CMDLINE_PARTS
+        mtd->name = "cafe_nand";
+#endif
        nr_parts = parse_mtd_partitions(mtd, part_probes, &parts, 0);
        if (nr_parts > 0) {
                cafe->parts = parts;
-               dev_info(&cafe->pdev->dev, "%d RedBoot partitions found\n", nr_parts);
+               dev_info(&cafe->pdev->dev, "%d partitions found\n", nr_parts);
                add_mtd_partitions(mtd, parts, nr_parts);
        }
 #endif
+
+       /* We register the whole device first, separate from the partitions */
+       if (nr_parts <= 0)
+               add_mtd_device(mtd);
        goto out;
 
  out_irq:
@@ -908,3 +916,4 @@ module_exit(cafe_nand_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("David Woodhouse <[email protected]>");
 MODULE_DESCRIPTION("NAND flash driver for OLPC CAFÉ chip");
+