@@ -136,6 +136,18 @@ config MTD_PHRAM
doesn't have access to, memory beyond the mem=xxx limit, nvram,
memory on the video card, etc...
+config MTD_PHRAM_MAX_CMDLINE_ARGS
+ int "Max number of devices via Kernel command line"
+ depends on MTD_PHRAM=y
+ default 1
+ help
+ Specify the number of phram devices that can be initialised
+ using the Kernel command line.
+
+ This option is only applicable when phram is built into the
+ Kernel. When built as a module many devices can be specified
+ at module insmod.
+
config MTD_LART
tristate "28F160xx flash driver for LART"
depends on SA1100_LART
@@ -212,9 +212,13 @@ static int phram_init_called;
* - phram.phram=<device>,<address>,<size> for built-in case
* We leave 64 bytes for the device name, 20 for the address and 20 for the
* size.
+ *
+ * The maximum number of devices supported is controlled by the
+ * MTD_PHRAM_MAX_CMDLINE_ARGS config option
+ *
* Example: phram.phram=rootfs,0xa0000000,512Mi
*/
-static char phram_paramline[64 + 20 + 20];
+static char phram_paramline[CONFIG_MTD_PHRAM_MAX_CMDLINE_ARGS][64 + 20 + 20];
#endif
static int phram_setup(const char *val)
@@ -271,6 +275,8 @@ static int phram_param_call(const char *val, struct kernel_param *kp)
#ifdef MODULE
return phram_setup(val);
#else
+ int i;
+
/*
* If more parameters are later passed in via
* /sys/module/phram/parameters/phram
@@ -290,9 +296,25 @@ static int phram_param_call(const char *val, struct kernel_param *kp)
* phram_setup().
*/
- if (strlen(val) >= sizeof(phram_paramline))
+ if (strlen(val) >= sizeof(phram_paramline[0]))
return -ENOSPC;
- strcpy(phram_paramline, val);
+
+ /*
+ * Check if any space is left in the array. If no space
+ * is left then print warning and return 0
+ */
+
+ if (phram_paramline[ARRAY_SIZE(phram_paramline) - 1][0]) {
+ pr_warn("exceeded limit via cmd_line - %s ignored", val);
+ return 0;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(phram_paramline); i++) {
+ if (!phram_paramline[i][0]) {
+ strcpy(phram_paramline[i], val);
+ break;
+ }
+ }
return 0;
#endif
@@ -307,8 +329,15 @@ static int __init init_phram(void)
int ret = 0;
#ifndef MODULE
- if (phram_paramline[0])
- ret = phram_setup(phram_paramline);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(phram_paramline); i++) {
+ if (phram_paramline[i][0]) {
+ ret = phram_setup(phram_paramline[i]);
+ if (ret)
+ break;
+ }
+ }
phram_init_called = 1;
#endif