--- zzzz-none-000/linux-4.1.52/drivers/mtd/cmdlinepart.c 2018-05-28 02:26:45.000000000 +0000 +++ bcm63-7530ax-731/linux-4.1.52/drivers/mtd/cmdlinepart.c 2022-03-02 11:37:13.000000000 +0000 @@ -46,6 +46,22 @@ * * 1 NOR Flash with 2 partitions, 1 NAND with one * edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home) + * + * ========================================================================== + * AVM extensions + * -------------- + * + * A new command line parameter 'mtdparts_ext' was introduced with + * same format as 'mtdparts' above. + * + * The semantics of 'mtdparts' force a complete override of previously + * given parameters in case another 'mtdparts' entry is found. + * + * All 'mtdparts_ext' entries however are appended. + * When the parser kicks in the first time, the kernel's 'mtdparts' + * is appended to the 'mtdparts_ext' collection, so that the system is fed + * with the complete information. + * ========================================================================== */ #include @@ -54,6 +70,9 @@ #include #include #include +#include + +#include /* error message prefix */ #define ERRP "mtd: " @@ -82,9 +101,23 @@ /* the command line passed to mtdpart_setup() */ static char *mtdparts; -static char *cmdline; +static char *system_cmdline; static int cmdline_parsed; +static int cmdline_locked; +static char avm_cmdline_mtd_ext[AVM_MAX_CMDLINE_MTD_EXT + COMMAND_LINE_SIZE + 1]; + + +static int mtdpart_setup_ext(char *s); + +static char *cmdline(void) +{ + if (!cmdline_locked) + mtdpart_setup_ext(system_cmdline); + cmdline_locked = 1; + return avm_cmdline_mtd_ext; +} + /* * Parse one partition definition for an MTD. Since there can be many * comma separated partition definitions, this function calls itself @@ -316,7 +349,7 @@ /* parse command line */ if (!cmdline_parsed) { - err = mtdpart_setup_real(cmdline); + err = mtdpart_setup_real(cmdline()); if (err) return err; } @@ -379,11 +412,28 @@ */ static int __init mtdpart_setup(char *s) { - cmdline = s; + system_cmdline = s; + return 1; +} + +static int mtdpart_setup_ext(char *s) +{ + size_t len = strlen(avm_cmdline_mtd_ext); + + if (len && (strlen(s) > 0)) + (void)strlcat(avm_cmdline_mtd_ext, ";", AVM_MAX_CMDLINE_MTD_EXT); + + if (strlcat(avm_cmdline_mtd_ext, s, AVM_MAX_CMDLINE_MTD_EXT) > AVM_MAX_CMDLINE_MTD_EXT) { + avm_cmdline_mtd_ext[len] = 0; + pr_err("[%s] ERROR: cmdline part \"%s\" dropped!", __func__, s); + return 0; + } + return 1; } __setup("mtdparts=", mtdpart_setup); +__setup("mtdparts_ext=", mtdpart_setup_ext); static struct mtd_part_parser cmdline_parser = { .owner = THIS_MODULE,