OSDN Git Service

pstore/ram: Run without kernel crash dump region
[android-x86/kernel.git] / fs / pstore / ram.c
index eb67bb7..316c164 100644 (file)
@@ -803,27 +803,36 @@ static int ramoops_probe(struct platform_device *pdev)
 
        cxt->pstore.data = cxt;
        /*
-        * Since bufsize is only used for dmesg crash dumps, it
-        * must match the size of the dprz record (after PRZ header
-        * and ECC bytes have been accounted for).
+        * Prepare frontend flags based on which areas are initialized.
+        * For ramoops_init_przs() cases, the "max count" variable tells
+        * if there are regions present. For ramoops_init_prz() cases,
+        * the single region size is how to check.
         */
-       cxt->pstore.bufsize = cxt->dprzs[0]->buffer_size;
-       cxt->pstore.buf = kzalloc(cxt->pstore.bufsize, GFP_KERNEL);
-       if (!cxt->pstore.buf) {
-               pr_err("cannot allocate pstore crash dump buffer\n");
-               err = -ENOMEM;
-               goto fail_clear;
-       }
-       spin_lock_init(&cxt->pstore.buf_lock);
-
-       cxt->pstore.flags = PSTORE_FLAGS_DMESG;
+       cxt->pstore.flags = 0;
+       if (cxt->max_dump_cnt)
+               cxt->pstore.flags |= PSTORE_FLAGS_DMESG;
        if (cxt->console_size)
                cxt->pstore.flags |= PSTORE_FLAGS_CONSOLE;
-       if (cxt->ftrace_size)
+       if (cxt->max_ftrace_cnt)
                cxt->pstore.flags |= PSTORE_FLAGS_FTRACE;
        if (cxt->pmsg_size)
                cxt->pstore.flags |= PSTORE_FLAGS_PMSG;
 
+       /*
+        * Since bufsize is only used for dmesg crash dumps, it
+        * must match the size of the dprz record (after PRZ header
+        * and ECC bytes have been accounted for).
+        */
+       if (cxt->pstore.flags & PSTORE_FLAGS_DMESG) {
+               cxt->pstore.bufsize = cxt->dprzs[0]->buffer_size;
+               cxt->pstore.buf = kzalloc(cxt->pstore.bufsize, GFP_KERNEL);
+               if (!cxt->pstore.buf) {
+                       pr_err("cannot allocate pstore crash dump buffer\n");
+                       err = -ENOMEM;
+                       goto fail_clear;
+               }
+       }
+
        err = pstore_register(&cxt->pstore);
        if (err) {
                pr_err("registering with pstore failed\n");
@@ -956,7 +965,7 @@ static int __init ramoops_init(void)
 
        return ret;
 }
-late_initcall(ramoops_init);
+postcore_initcall(ramoops_init);
 
 static void __exit ramoops_exit(void)
 {