aboutsummaryrefslogtreecommitdiffstats
path: root/fs/pstore/platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/pstore/platform.c')
-rw-r--r--fs/pstore/platform.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 791743deedf1..588461bb2dd4 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -237,6 +237,14 @@ static void allocate_buf_for_compression(void)
237 237
238} 238}
239 239
240static void free_buf_for_compression(void)
241{
242 kfree(stream.workspace);
243 stream.workspace = NULL;
244 kfree(big_oops_buf);
245 big_oops_buf = NULL;
246}
247
240/* 248/*
241 * Called when compression fails, since the printk buffer 249 * Called when compression fails, since the printk buffer
242 * would be fetched for compression calling it again when 250 * would be fetched for compression calling it again when
@@ -353,6 +361,19 @@ static struct kmsg_dumper pstore_dumper = {
353 .dump = pstore_dump, 361 .dump = pstore_dump,
354}; 362};
355 363
364/*
365 * Register with kmsg_dump to save last part of console log on panic.
366 */
367static void pstore_register_kmsg(void)
368{
369 kmsg_dump_register(&pstore_dumper);
370}
371
372static void pstore_unregister_kmsg(void)
373{
374 kmsg_dump_unregister(&pstore_dumper);
375}
376
356#ifdef CONFIG_PSTORE_CONSOLE 377#ifdef CONFIG_PSTORE_CONSOLE
357static void pstore_console_write(struct console *con, const char *s, unsigned c) 378static void pstore_console_write(struct console *con, const char *s, unsigned c)
358{ 379{
@@ -390,8 +411,14 @@ static void pstore_register_console(void)
390{ 411{
391 register_console(&pstore_console); 412 register_console(&pstore_console);
392} 413}
414
415static void pstore_unregister_console(void)
416{
417 unregister_console(&pstore_console);
418}
393#else 419#else
394static void pstore_register_console(void) {} 420static void pstore_register_console(void) {}
421static void pstore_unregister_console(void) {}
395#endif 422#endif
396 423
397static int pstore_write_compat(enum pstore_type_id type, 424static int pstore_write_compat(enum pstore_type_id type,
@@ -410,8 +437,6 @@ static int pstore_write_compat(enum pstore_type_id type,
410 * read function right away to populate the file system. If not 437 * read function right away to populate the file system. If not
411 * then the pstore mount code will call us later to fill out 438 * then the pstore mount code will call us later to fill out
412 * the file system. 439 * the file system.
413 *
414 * Register with kmsg_dump to save last part of console log on panic.
415 */ 440 */
416int pstore_register(struct pstore_info *psi) 441int pstore_register(struct pstore_info *psi)
417{ 442{
@@ -442,7 +467,7 @@ int pstore_register(struct pstore_info *psi)
442 if (pstore_is_mounted()) 467 if (pstore_is_mounted())
443 pstore_get_records(0); 468 pstore_get_records(0);
444 469
445 kmsg_dump_register(&pstore_dumper); 470 pstore_register_kmsg();
446 471
447 if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) { 472 if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) {
448 pstore_register_console(); 473 pstore_register_console();
@@ -462,12 +487,28 @@ int pstore_register(struct pstore_info *psi)
462 */ 487 */
463 backend = psi->name; 488 backend = psi->name;
464 489
490 module_put(owner);
491
465 pr_info("Registered %s as persistent store backend\n", psi->name); 492 pr_info("Registered %s as persistent store backend\n", psi->name);
466 493
467 return 0; 494 return 0;
468} 495}
469EXPORT_SYMBOL_GPL(pstore_register); 496EXPORT_SYMBOL_GPL(pstore_register);
470 497
498void pstore_unregister(struct pstore_info *psi)
499{
500 pstore_unregister_pmsg();
501 pstore_unregister_ftrace();
502 pstore_unregister_console();
503 pstore_unregister_kmsg();
504
505 free_buf_for_compression();
506
507 psinfo = NULL;
508 backend = NULL;
509}
510EXPORT_SYMBOL_GPL(pstore_unregister);
511
471/* 512/*
472 * Read all the records from the persistent store. Create 513 * Read all the records from the persistent store. Create
473 * files in our filesystem. Don't warn about -EEXIST errors 514 * files in our filesystem. Don't warn about -EEXIST errors