Skip to content

Commit

Permalink
Merge branch 'pstore' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/aegl/linux

* 'pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux:
  pstore: gracefully handle NULL pstore_info functions
  pstore: pass reason to backend write callback
  • Loading branch information
torvalds committed Jan 7, 2012
2 parents 5ee354a + 2174f6d commit 6ed23fd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 45 deletions.
6 changes: 4 additions & 2 deletions drivers/acpi/apei/erst.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,8 @@ static int erst_close_pstore(struct pstore_info *psi);
static ssize_t erst_reader(u64 *id, enum pstore_type_id *type,
struct timespec *time, char **buf,
struct pstore_info *psi);
static int erst_writer(enum pstore_type_id type, u64 *id, unsigned int part,
static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
u64 *id, unsigned int part,
size_t size, struct pstore_info *psi);
static int erst_clearer(enum pstore_type_id type, u64 id,
struct pstore_info *psi);
Expand Down Expand Up @@ -1053,7 +1054,8 @@ static ssize_t erst_reader(u64 *id, enum pstore_type_id *type,
return (rc < 0) ? rc : (len - sizeof(*rcd));
}

static int erst_writer(enum pstore_type_id type, u64 *id, unsigned int part,
static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
u64 *id, unsigned int part,
size_t size, struct pstore_info *psi)
{
struct cper_pstore_record *rcd = (struct cper_pstore_record *)
Expand Down
8 changes: 5 additions & 3 deletions drivers/firmware/efivars.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
return 0;
}

static int efi_pstore_write(enum pstore_type_id type, u64 *id,
static int efi_pstore_write(enum pstore_type_id type,
enum kmsg_dump_reason reason, u64 *id,
unsigned int part, size_t size, struct pstore_info *psi)
{
char name[DUMP_NAME_LEN];
Expand Down Expand Up @@ -565,7 +566,7 @@ static int efi_pstore_write(enum pstore_type_id type, u64 *id,
static int efi_pstore_erase(enum pstore_type_id type, u64 id,
struct pstore_info *psi)
{
efi_pstore_write(type, &id, (unsigned int)id, 0, psi);
efi_pstore_write(type, 0, &id, (unsigned int)id, 0, psi);

return 0;
}
Expand All @@ -587,7 +588,8 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type,
return -1;
}

static int efi_pstore_write(enum pstore_type_id type, u64 *id,
static int efi_pstore_write(enum pstore_type_id type,
enum kmsg_dump_reason reason, u64 *id,
unsigned int part, size_t size, struct pstore_info *psi)
{
return 0;
Expand Down
3 changes: 2 additions & 1 deletion fs/pstore/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
{
struct pstore_private *p = dentry->d_inode->i_private;

p->psi->erase(p->type, p->id, p->psi);
if (p->psi->erase)
p->psi->erase(p->type, p->id, p->psi);

return simple_unlink(dir, dentry);
}
Expand Down
36 changes: 4 additions & 32 deletions fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
memcpy(dst, s1 + s1_start, l1_cpy);
memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy);

ret = psinfo->write(PSTORE_TYPE_DMESG, &id, part,
ret = psinfo->write(PSTORE_TYPE_DMESG, reason, &id, part,
hsize + l1_cpy + l2_cpy, psinfo);
if (ret == 0 && reason == KMSG_DUMP_OOPS && pstore_is_mounted())
pstore_new_entry = 1;
Expand Down Expand Up @@ -207,8 +207,7 @@ void pstore_get_records(int quiet)
return;

mutex_lock(&psi->read_mutex);
rc = psi->open(psi);
if (rc)
if (psi->open && psi->open(psi))
goto out;

while ((size = psi->read(&id, &type, &time, &buf, psi)) > 0) {
Expand All @@ -219,7 +218,8 @@ void pstore_get_records(int quiet)
if (rc && (rc != -EEXIST || !quiet))
failed++;
}
psi->close(psi);
if (psi->close)
psi->close(psi);
out:
mutex_unlock(&psi->read_mutex);

Expand All @@ -243,33 +243,5 @@ static void pstore_timefunc(unsigned long dummy)
mod_timer(&pstore_timer, jiffies + PSTORE_INTERVAL);
}

/*
* Call platform driver to write a record to the
* persistent store.
*/
int pstore_write(enum pstore_type_id type, char *buf, size_t size)
{
u64 id;
int ret;
unsigned long flags;

if (!psinfo)
return -ENODEV;

if (size > psinfo->bufsize)
return -EFBIG;

spin_lock_irqsave(&psinfo->buf_lock, flags);
memcpy(psinfo->buf, buf, size);
ret = psinfo->write(type, &id, 0, size, psinfo);
if (ret == 0 && pstore_is_mounted())
pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, psinfo->buf,
size, CURRENT_TIME, psinfo);
spin_unlock_irqrestore(&psinfo->buf_lock, flags);

return 0;
}
EXPORT_SYMBOL_GPL(pstore_write);

module_param(backend, charp, 0444);
MODULE_PARM_DESC(backend, "Pstore backend to use");
12 changes: 5 additions & 7 deletions include/linux/pstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#ifndef _LINUX_PSTORE_H
#define _LINUX_PSTORE_H

#include <linux/time.h>
#include <linux/kmsg_dump.h>

/* types */
enum pstore_type_id {
PSTORE_TYPE_DMESG = 0,
Expand All @@ -41,7 +44,8 @@ struct pstore_info {
ssize_t (*read)(u64 *id, enum pstore_type_id *type,
struct timespec *time, char **buf,
struct pstore_info *psi);
int (*write)(enum pstore_type_id type, u64 *id,
int (*write)(enum pstore_type_id type,
enum kmsg_dump_reason reason, u64 *id,
unsigned int part, size_t size, struct pstore_info *psi);
int (*erase)(enum pstore_type_id type, u64 id,
struct pstore_info *psi);
Expand All @@ -50,18 +54,12 @@ struct pstore_info {

#ifdef CONFIG_PSTORE
extern int pstore_register(struct pstore_info *);
extern int pstore_write(enum pstore_type_id type, char *buf, size_t size);
#else
static inline int
pstore_register(struct pstore_info *psi)
{
return -ENODEV;
}
static inline int
pstore_write(enum pstore_type_id type, char *buf, size_t size)
{
return -ENODEV;
}
#endif

#endif /*_LINUX_PSTORE_H*/

0 comments on commit 6ed23fd

Please sign in to comment.