diff options
Diffstat (limited to 'drivers/mtd/devices/phram.c')
-rw-r--r-- | drivers/mtd/devices/phram.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index e1f2aebaa489..2cceebfb251e 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c | |||
@@ -205,6 +205,8 @@ static inline void kill_final_newline(char *str) | |||
205 | return 1; \ | 205 | return 1; \ |
206 | } while (0) | 206 | } while (0) |
207 | 207 | ||
208 | #ifndef MODULE | ||
209 | static int phram_init_called; | ||
208 | /* | 210 | /* |
209 | * This shall contain the module parameter if any. It is of the form: | 211 | * This shall contain the module parameter if any. It is of the form: |
210 | * - phram=<device>,<address>,<size> for module case | 212 | * - phram=<device>,<address>,<size> for module case |
@@ -213,9 +215,10 @@ static inline void kill_final_newline(char *str) | |||
213 | * size. | 215 | * size. |
214 | * Example: phram.phram=rootfs,0xa0000000,512Mi | 216 | * Example: phram.phram=rootfs,0xa0000000,512Mi |
215 | */ | 217 | */ |
216 | static __initdata char phram_paramline[64 + 20 + 20]; | 218 | static char phram_paramline[64 + 20 + 20]; |
219 | #endif | ||
217 | 220 | ||
218 | static int __init phram_setup(const char *val) | 221 | static int phram_setup(const char *val) |
219 | { | 222 | { |
220 | char buf[64 + 20 + 20], *str = buf; | 223 | char buf[64 + 20 + 20], *str = buf; |
221 | char *token[3]; | 224 | char *token[3]; |
@@ -264,17 +267,36 @@ static int __init phram_setup(const char *val) | |||
264 | return ret; | 267 | return ret; |
265 | } | 268 | } |
266 | 269 | ||
267 | static int __init phram_param_call(const char *val, struct kernel_param *kp) | 270 | static int phram_param_call(const char *val, struct kernel_param *kp) |
268 | { | 271 | { |
272 | #ifdef MODULE | ||
273 | return phram_setup(val); | ||
274 | #else | ||
269 | /* | 275 | /* |
270 | * This function is always called before 'init_phram()', whether | 276 | * If more parameters are later passed in via |
271 | * built-in or module. | 277 | * /sys/module/phram/parameters/phram |
278 | * and init_phram() has already been called, | ||
279 | * we can parse the argument now. | ||
272 | */ | 280 | */ |
281 | |||
282 | if (phram_init_called) | ||
283 | return phram_setup(val); | ||
284 | |||
285 | /* | ||
286 | * During early boot stage, we only save the parameters | ||
287 | * here. We must parse them later: if the param passed | ||
288 | * from kernel boot command line, phram_param_call() is | ||
289 | * called so early that it is not possible to resolve | ||
290 | * the device (even kmalloc() fails). Defer that work to | ||
291 | * phram_setup(). | ||
292 | */ | ||
293 | |||
273 | if (strlen(val) >= sizeof(phram_paramline)) | 294 | if (strlen(val) >= sizeof(phram_paramline)) |
274 | return -ENOSPC; | 295 | return -ENOSPC; |
275 | strcpy(phram_paramline, val); | 296 | strcpy(phram_paramline, val); |
276 | 297 | ||
277 | return 0; | 298 | return 0; |
299 | #endif | ||
278 | } | 300 | } |
279 | 301 | ||
280 | module_param_call(phram, phram_param_call, NULL, NULL, 000); | 302 | module_param_call(phram, phram_param_call, NULL, NULL, 000); |
@@ -283,10 +305,15 @@ MODULE_PARM_DESC(phram, "Memory region to map. \"phram=<name>,<start>,<length>\" | |||
283 | 305 | ||
284 | static int __init init_phram(void) | 306 | static int __init init_phram(void) |
285 | { | 307 | { |
308 | int ret = 0; | ||
309 | |||
310 | #ifndef MODULE | ||
286 | if (phram_paramline[0]) | 311 | if (phram_paramline[0]) |
287 | return phram_setup(phram_paramline); | 312 | ret = phram_setup(phram_paramline); |
313 | phram_init_called = 1; | ||
314 | #endif | ||
288 | 315 | ||
289 | return 0; | 316 | return ret; |
290 | } | 317 | } |
291 | 318 | ||
292 | static void __exit cleanup_phram(void) | 319 | static void __exit cleanup_phram(void) |