aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/devices/phram.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 9d2bf1741fb2..3d91ace1ee4c 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -39,7 +39,8 @@ static int phram_erase(struct mtd_info *mtd, struct erase_info *instr)
39 39
40 memset(start + instr->addr, 0xff, instr->len); 40 memset(start + instr->addr, 0xff, instr->len);
41 41
42 /* This'll catch a few races. Free the thing before returning :) 42 /*
43 * This'll catch a few races. Free the thing before returning :)
43 * I don't feel at all ashamed. This kind of thing is possible anyway 44 * I don't feel at all ashamed. This kind of thing is possible anyway
44 * with flash, but unlikely. 45 * with flash, but unlikely.
45 */ 46 */
@@ -204,7 +205,17 @@ static inline void kill_final_newline(char *str)
204 return 1; \ 205 return 1; \
205} while (0) 206} while (0)
206 207
207static int phram_setup(const char *val, struct kernel_param *kp) 208/*
209 * This shall contain the module parameter if any. It is of the form:
210 * - phram=<device>,<address>,<size> for module case
211 * - phram.phram=<device>,<address>,<size> for built-in case
212 * We leave 64 bytes for the device name, 12 for the address and 12 for the
213 * size.
214 * Example: phram.phram=rootfs,0xa0000000,512Mi
215 */
216static __initdata char phram_paramline[64+12+12];
217
218static int phram_setup(const char *val)
208{ 219{
209 char buf[64+12+12], *str = buf; 220 char buf[64+12+12], *str = buf;
210 char *token[3]; 221 char *token[3];
@@ -253,12 +264,28 @@ static int phram_setup(const char *val, struct kernel_param *kp)
253 return ret; 264 return ret;
254} 265}
255 266
256module_param_call(phram, phram_setup, NULL, NULL, 000); 267static int __init phram_param_call(const char *val, struct kernel_param *kp)
268{
269 /*
270 * This function is always called before 'init_phram()', whether
271 * built-in or module.
272 */
273 if (strlen(val) >= sizeof(phram_paramline))
274 return -ENOSPC;
275 strcpy(phram_paramline, val);
276
277 return 0;
278}
279
280module_param_call(phram, phram_param_call, NULL, NULL, 000);
257MODULE_PARM_DESC(phram, "Memory region to map. \"phram=<name>,<start>,<length>\""); 281MODULE_PARM_DESC(phram, "Memory region to map. \"phram=<name>,<start>,<length>\"");
258 282
259 283
260static int __init init_phram(void) 284static int __init init_phram(void)
261{ 285{
286 if (phram_paramline[0])
287 return phram_setup(phram_paramline);
288
262 return 0; 289 return 0;
263} 290}
264 291