--- zzzz-none-000/linux-2.6.28.10/drivers/mtd/devices/phram.c 2009-05-02 18:54:43.000000000 +0000 +++ puma5-6360-529/linux-2.6.28.10/drivers/mtd/devices/phram.c 2010-09-03 08:39:50.000000000 +0000 @@ -22,6 +22,8 @@ #include #include #include +#include +#include #define ERROR(fmt, args...) printk(KERN_ERR "phram: " fmt , ## args) @@ -32,6 +34,8 @@ static LIST_HEAD(phram_list); +static const char *cmdline = NULL; +static struct mtd_info *curr_mtd = NULL; static int phram_erase(struct mtd_info *mtd, struct erase_info *instr) { @@ -156,6 +160,9 @@ goto out2; } + /* Save for later use */ + curr_mtd = &new->mtd; + list_add_tail(&new->list, &phram_list); return 0; @@ -189,8 +196,12 @@ { char *endp; unsigned long n; + int base = 0; + + if (token[0] == '0' && toupper(token[1]) == 'X') + base = 16; - n = ustrtoul(token, &endp, 0); + n = ustrtoul(token, &endp, base); if (*endp) return -EINVAL; @@ -257,7 +268,11 @@ ret = parse_name(&name, token[0]); if (ret == -ENOMEM) + { + /* Try later */ + cmdline = val; parse_err("out of memory\n"); + } if (ret == -ENOSPC) parse_err("name too long\n"); if (ret) @@ -286,7 +301,40 @@ static int __init init_phram(void) { - return 0; + int ret = 0; + + if (cmdline != NULL) + { + /* Got earlier, parse now */ + ret = phram_setup(cmdline, NULL); + cmdline = NULL; +#ifdef CONFIG_MTD_CMDLINE_PARTS + /* Since this is from the command line, check if there are MTD partitions on */ + /* this device */ + if (curr_mtd != NULL) + { + int nr_parts = 0; + struct mtd_partition *parts = NULL; + static const char *part_probes[] = { "cmdlinepart", NULL,}; + int i; + + nr_parts = parse_mtd_partitions(curr_mtd,part_probes, &parts, 0); + + if (nr_parts > 0) { + for (i = 0; i < nr_parts; i++){ + printk("partitions[%d] = ""{.name = %s, .offset = 0x%.8x," + ".size = 0x%.8x (%uK) }\n",i, parts[i].name, + parts[i].offset,parts[i].size, + parts[i].size / 1024); + } + add_mtd_partitions(curr_mtd, parts, nr_parts); + } + + curr_mtd = NULL; + } +#endif + } + return ret; } static void __exit cleanup_phram(void)