summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-07-12 07:10:18 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-07-12 07:10:18 +0200
commitcab56acd98643d7cf08ab992cbb0557b4c2488f7 (patch)
tree404123ae35e715a6d2682795fad2632f9abe3d5f /fs
parentca1c1456a16ee50f60f53e4efda04b310372a9b7 (diff)
parent5b1bc2224cff7deb2f1e048bb82a60d857f642be (diff)
downloadbarebox-cab56acd98643d7cf08ab992cbb0557b4c2488f7.tar.gz
Merge branch 'for-next/pstore'
Diffstat (limited to 'fs')
-rw-r--r--fs/pstore/platform.c93
-rw-r--r--fs/pstore/ram.c17
2 files changed, 24 insertions, 86 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 755363c..0a6fa38 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -44,83 +44,39 @@ void pstore_set_kmsg_bytes(int bytes)
kmsg_bytes = bytes;
}
-#ifdef CONFIG_FS_PSTORE_CONSOLE
-static void pstore_console_write(const char *s, unsigned c)
-{
- const char *e = s + c;
-
- while (s < e) {
- struct pstore_record record = {
- .type = PSTORE_TYPE_CONSOLE,
- .psi = psinfo,
- };
-
- if (c > psinfo->bufsize)
- c = psinfo->bufsize;
-
- record.buf = (char *)s;
- record.size = c;
- psinfo->write_buf(PSTORE_TYPE_CONSOLE, 0, &record.id, 0,
- record.buf, 0, record.size, psinfo);
- s += c;
- c = e - s;
- }
-}
-
-static int pstore_console_puts(struct console_device *cdev, const char *s)
-{
- pstore_console_write(s, strlen(s));
- return strlen(s);
-}
+static int pstore_ready;
-static void pstore_console_putc(struct console_device *cdev, char c)
+void pstore_log(const char *str)
{
- const char s[1] = { c };
+ uint64_t id;
+ static int in_pstore;
- pstore_console_write(s, 1);
-}
-
-static void pstore_console_capture_log(void)
-{
- struct log_entry *log;
-
- list_for_each_entry(log, &barebox_logbuf, list)
- pstore_console_write(log->msg, strlen(log->msg));
-}
-
-static struct console_device *pstore_cdev;
+ if (!IS_ENABLED(CONFIG_FS_PSTORE_CONSOLE))
+ return;
-static void pstore_register_console(void)
-{
- struct console_device *cdev;
- int ret;
+ if (!pstore_ready)
+ return;
- cdev = xzalloc(sizeof(struct console_device));
- pstore_cdev = cdev;
+ if (in_pstore)
+ return;
- cdev->puts = pstore_console_puts;
- cdev->putc = pstore_console_putc;
- cdev->devname = "pstore";
- cdev->devid = DEVICE_ID_SINGLE;
+ in_pstore = 1;
- ret = console_register(cdev);
- if (ret)
- pr_err("registering failed with %s\n", strerror(-ret));
+ psinfo->write_buf(PSTORE_TYPE_CONSOLE, 0, &id, 0,
+ str, 0, strlen(str), psinfo);
- pstore_console_capture_log();
-
- console_set_active(pstore_cdev, CONSOLE_STDOUT);
+ in_pstore = 0;
}
-#else
-static void pstore_register_console(void) {}
-#endif
-static int pstore_write_compat(struct pstore_record *record)
+static void pstore_console_capture_log(void)
{
- return record->psi->write_buf(record->type, record->reason,
- &record->id, record->part,
- psinfo->buf, record->compressed,
- record->size, record->psi);
+ uint64_t id;
+ struct log_entry *log, *tmp;
+
+ list_for_each_entry_safe(log, tmp, &barebox_logbuf, list) {
+ psinfo->write_buf(PSTORE_TYPE_CONSOLE, 0, &id, 0,
+ log->msg, 0, strlen(log->msg), psinfo);
+ }
}
/*
@@ -143,15 +99,14 @@ int pstore_register(struct pstore_info *psi)
return -EBUSY;
}
- if (!psi->write)
- psi->write = pstore_write_compat;
psinfo = psi;
mutex_init(&psinfo->read_mutex);
spin_unlock(&pstore_lock);
pstore_get_records(0);
- pstore_register_console();
+ pstore_console_capture_log();
+ pstore_ready = 1;
pr_info("Registered %s as persistent store backend\n", psi->name);
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 734d0c3..86049f9 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -609,22 +609,7 @@ static int ramoops_probe(struct device_d *dev)
goto fail_init_mprz;
cxt->pstore.data = cxt;
- /*
- * Console can handle any buffer size, so prefer LOG_LINE_MAX. If we
- * have to handle dumps, we must have at least record_size buffer. And
- * for ftrace, bufsize is irrelevant (if bufsize is 0, buf will be
- * ZERO_SIZE_PTR).
- */
- if (cxt->console_size)
- cxt->pstore.bufsize = 1024; /* LOG_LINE_MAX */
- cxt->pstore.bufsize = max(cxt->record_size, cxt->pstore.bufsize);
- cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL);
spin_lock_init(&cxt->pstore.buf_lock);
- if (!cxt->pstore.buf) {
- pr_err("cannot allocate pstore buffer\n");
- err = -ENOMEM;
- goto fail_clear;
- }
err = pstore_register(&cxt->pstore);
if (err) {
@@ -661,9 +646,7 @@ static int ramoops_probe(struct device_d *dev)
return 0;
fail_buf:
- kfree(cxt->pstore.buf);
fail_clear:
- cxt->pstore.bufsize = 0;
kfree(cxt->mprz);
fail_init_mprz:
kfree(cxt->fprz);