Commit 897dba02 authored by Anton Vorontsov's avatar Anton Vorontsov Committed by Greg Kroah-Hartman

pstore: Introduce write_buf backend callback

For function tracing we need to stop using pstore.buf directly, since
in a tracing callback we can't use spinlocks, and thus we can't safely
use the global buffer.

With write_buf callback, backends no longer need to access pstore.buf
directly, and thus we can pass any buffers (e.g. allocated on stack).
Signed-off-by: default avatarAnton Vorontsov <anton.vorontsov@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b2ad368b
...@@ -188,6 +188,14 @@ static void pstore_register_console(void) ...@@ -188,6 +188,14 @@ static void pstore_register_console(void)
static void pstore_register_console(void) {} static void pstore_register_console(void) {}
#endif #endif
static int pstore_write_compat(enum pstore_type_id type,
enum kmsg_dump_reason reason,
u64 *id, unsigned int part,
size_t size, struct pstore_info *psi)
{
return psi->write_buf(type, reason, id, part, psinfo->buf, size, psi);
}
/* /*
* platform specific persistent storage driver registers with * platform specific persistent storage driver registers with
* us here. If pstore is already mounted, call the platform * us here. If pstore is already mounted, call the platform
...@@ -212,6 +220,8 @@ int pstore_register(struct pstore_info *psi) ...@@ -212,6 +220,8 @@ int pstore_register(struct pstore_info *psi)
return -EINVAL; return -EINVAL;
} }
if (!psi->write)
psi->write = pstore_write_compat;
psinfo = psi; psinfo = psi;
mutex_init(&psinfo->read_mutex); mutex_init(&psinfo->read_mutex);
spin_unlock(&pstore_lock); spin_unlock(&pstore_lock);
......
...@@ -48,6 +48,10 @@ struct pstore_info { ...@@ -48,6 +48,10 @@ struct pstore_info {
int (*write)(enum pstore_type_id type, int (*write)(enum pstore_type_id type,
enum kmsg_dump_reason reason, u64 *id, enum kmsg_dump_reason reason, u64 *id,
unsigned int part, size_t size, struct pstore_info *psi); unsigned int part, size_t size, struct pstore_info *psi);
int (*write_buf)(enum pstore_type_id type,
enum kmsg_dump_reason reason, u64 *id,
unsigned int part, const char *buf, size_t size,
struct pstore_info *psi);
int (*erase)(enum pstore_type_id type, u64 id, int (*erase)(enum pstore_type_id type, u64 id,
struct pstore_info *psi); struct pstore_info *psi);
void *data; void *data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment