aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAnton Vorontsov <anton.vorontsov@linaro.org>2012-06-18 22:15:50 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-20 19:15:22 -0400
commit924d37118f9e18825294b2012a10c6245d6c25e1 (patch)
tree9cc0169d406efeddab7d149700e0a507718f9864 /fs
parent62a1efb9f868690d68b11ffb22dc598e547aa184 (diff)
pstore/ram: Probe as early as possible
Registering the platform driver before module_init allows us to log oopses that happen during device probing. This requires changing module_init to postcore_initcall, and switching from platform_driver_probe to platform_driver_register because the platform device is not registered when the platform driver is registered; and because we use driver_register, now can't use create_bundle() (since it will try to register the same driver once again), so we have to switch to platform_device_register_data(). Also, some __init -> __devinit changes were needed. Overall, the registration logic is now much clearer, since we have only one driver registration point, and just an optional dummy device, which is created from the module parameters. Suggested-by: Colin Cross <ccross@android.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/pstore/ram.c63
-rw-r--r--fs/pstore/ram_core.c9
2 files changed, 37 insertions, 35 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index c7acf94ff475..0b36e91978e6 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -330,7 +330,7 @@ static int ramoops_init_prz(struct device *dev, struct ramoops_context *cxt,
330 return 0; 330 return 0;
331} 331}
332 332
333static int __init ramoops_probe(struct platform_device *pdev) 333static int __devinit ramoops_probe(struct platform_device *pdev)
334{ 334{
335 struct device *dev = &pdev->dev; 335 struct device *dev = &pdev->dev;
336 struct ramoops_platform_data *pdata = pdev->dev.platform_data; 336 struct ramoops_platform_data *pdata = pdev->dev.platform_data;
@@ -452,6 +452,7 @@ static int __exit ramoops_remove(struct platform_device *pdev)
452} 452}
453 453
454static struct platform_driver ramoops_driver = { 454static struct platform_driver ramoops_driver = {
455 .probe = ramoops_probe,
455 .remove = __exit_p(ramoops_remove), 456 .remove = __exit_p(ramoops_remove),
456 .driver = { 457 .driver = {
457 .name = "ramoops", 458 .name = "ramoops",
@@ -459,46 +460,46 @@ static struct platform_driver ramoops_driver = {
459 }, 460 },
460}; 461};
461 462
462static int __init ramoops_init(void) 463static void ramoops_register_dummy(void)
463{ 464{
464 int ret; 465 if (!mem_size)
465 ret = platform_driver_probe(&ramoops_driver, ramoops_probe); 466 return;
466 if (ret == -ENODEV) { 467
467 /* 468 pr_info("using module parameters\n");
468 * If we didn't find a platform device, we use module parameters 469
469 * building platform data on the fly. 470 dummy_data = kzalloc(sizeof(*dummy_data), GFP_KERNEL);
470 */ 471 if (!dummy_data) {
471 pr_info("platform device not found, using module parameters\n"); 472 pr_info("could not allocate pdata\n");
472 dummy_data = kzalloc(sizeof(struct ramoops_platform_data), 473 return;
473 GFP_KERNEL);
474 if (!dummy_data)
475 return -ENOMEM;
476 dummy_data->mem_size = mem_size;
477 dummy_data->mem_address = mem_address;
478 dummy_data->record_size = record_size;
479 dummy_data->console_size = ramoops_console_size;
480 dummy_data->dump_oops = dump_oops;
481 dummy_data->ecc = ramoops_ecc;
482 dummy = platform_create_bundle(&ramoops_driver, ramoops_probe,
483 NULL, 0, dummy_data,
484 sizeof(struct ramoops_platform_data));
485
486 if (IS_ERR(dummy))
487 ret = PTR_ERR(dummy);
488 else
489 ret = 0;
490 } 474 }
491 475
492 return ret; 476 dummy_data->mem_size = mem_size;
477 dummy_data->mem_address = mem_address;
478 dummy_data->record_size = record_size;
479 dummy_data->console_size = ramoops_console_size;
480 dummy_data->dump_oops = dump_oops;
481 dummy_data->ecc = ramoops_ecc;
482
483 dummy = platform_device_register_data(NULL, "ramoops", -1,
484 dummy_data, sizeof(struct ramoops_platform_data));
485 if (IS_ERR(dummy)) {
486 pr_info("could not create platform device: %ld\n",
487 PTR_ERR(dummy));
488 }
489}
490
491static int __init ramoops_init(void)
492{
493 ramoops_register_dummy();
494 return platform_driver_register(&ramoops_driver);
493} 495}
496postcore_initcall(ramoops_init);
494 497
495static void __exit ramoops_exit(void) 498static void __exit ramoops_exit(void)
496{ 499{
497 platform_driver_unregister(&ramoops_driver); 500 platform_driver_unregister(&ramoops_driver);
498 kfree(dummy_data); 501 kfree(dummy_data);
499} 502}
500
501module_init(ramoops_init);
502module_exit(ramoops_exit); 503module_exit(ramoops_exit);
503 504
504MODULE_LICENSE("GPL"); 505MODULE_LICENSE("GPL");
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 0fd81611525c..26531856daf8 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -390,7 +390,8 @@ static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size,
390 return 0; 390 return 0;
391} 391}
392 392
393static int __init persistent_ram_post_init(struct persistent_ram_zone *prz, bool ecc) 393static int __devinit persistent_ram_post_init(struct persistent_ram_zone *prz,
394 bool ecc)
394{ 395{
395 int ret; 396 int ret;
396 397
@@ -436,9 +437,9 @@ void persistent_ram_free(struct persistent_ram_zone *prz)
436 kfree(prz); 437 kfree(prz);
437} 438}
438 439
439struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start, 440struct persistent_ram_zone * __devinit persistent_ram_new(phys_addr_t start,
440 size_t size, 441 size_t size,
441 bool ecc) 442 bool ecc)
442{ 443{
443 struct persistent_ram_zone *prz; 444 struct persistent_ram_zone *prz;
444 int ret = -ENOMEM; 445 int ret = -ENOMEM;