--- zzzz-none-000/linux-2.6.39.4/drivers/mtd/devices/phram.c 2011-08-03 19:43:28.000000000 +0000 +++ puma6-atom-6490-729/linux-2.6.39.4/drivers/mtd/devices/phram.c 2021-11-10 13:38:15.000000000 +0000 @@ -1,5 +1,5 @@ /** - * Copyright (c) ???? Jochen Schäuble + * Copyright (c) ???? Jochen Schäuble * Copyright (c) 2003-2004 Joern Engel * * Usage: @@ -25,6 +25,8 @@ #include #include #include +#include +#include struct phram_mtd_list { struct mtd_info mtd; @@ -33,6 +35,9 @@ static LIST_HEAD(phram_list); +static const char *cmdline = NULL; +static struct mtd_info *curr_mtd = NULL; +static int inited = 0; static int phram_erase(struct mtd_info *mtd, struct erase_info *instr) { @@ -158,6 +163,9 @@ goto out2; } + /* Save for later use */ + curr_mtd = &new->mtd; + list_add_tail(&new->list, &phram_list); return 0; @@ -191,8 +199,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; @@ -242,6 +254,14 @@ uint32_t len; int i, ret; + if (!inited) + { + /* Before module init, just save the command line for later */ + cmdline = val; + /* Nothing more to do here */ + return 0; + } + if (strnlen(val, sizeof(buf)) >= sizeof(buf)) parse_err("parameter too long\n"); @@ -288,7 +308,42 @@ static int __init init_phram(void) { - return 0; + int ret = 0; + + inited = 1; + + 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%.8llx," + ".size = 0x%.8llx (%lluK) }\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)