diff options
-rw-r--r-- | drivers/acpi/apei/erst.c | 6 | ||||
-rw-r--r-- | drivers/firmware/efivars.c | 8 | ||||
-rw-r--r-- | fs/pstore/inode.c | 3 | ||||
-rw-r--r-- | fs/pstore/platform.c | 36 | ||||
-rw-r--r-- | include/linux/pstore.h | 12 |
5 files changed, 20 insertions, 45 deletions
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c index 631b9477b99c..6a9e3bad13f4 100644 --- a/drivers/acpi/apei/erst.c +++ b/drivers/acpi/apei/erst.c | |||
@@ -934,7 +934,8 @@ static int erst_close_pstore(struct pstore_info *psi); | |||
934 | static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, | 934 | static ssize_t erst_reader(u64 *id, enum pstore_type_id *type, |
935 | struct timespec *time, char **buf, | 935 | struct timespec *time, char **buf, |
936 | struct pstore_info *psi); | 936 | struct pstore_info *psi); |
937 | static int erst_writer(enum pstore_type_id type, u64 *id, unsigned int part, | 937 | static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason, |
938 | u64 *id, unsigned int part, | ||
938 | size_t size, struct pstore_info *psi); | 939 | size_t size, struct pstore_info *psi); |
939 | static int erst_clearer(enum pstore_type_id type, u64 id, | 940 | static int erst_clearer(enum pstore_type_id type, u64 id, |
940 | struct pstore_info *psi); | 941 | struct pstore_info *psi); |
@@ -1053,7 +1054,8 @@ out: | |||
1053 | return (rc < 0) ? rc : (len - sizeof(*rcd)); | 1054 | return (rc < 0) ? rc : (len - sizeof(*rcd)); |
1054 | } | 1055 | } |
1055 | 1056 | ||
1056 | static int erst_writer(enum pstore_type_id type, u64 *id, unsigned int part, | 1057 | static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason, |
1058 | u64 *id, unsigned int part, | ||
1057 | size_t size, struct pstore_info *psi) | 1059 | size_t size, struct pstore_info *psi) |
1058 | { | 1060 | { |
1059 | struct cper_pstore_record *rcd = (struct cper_pstore_record *) | 1061 | struct cper_pstore_record *rcd = (struct cper_pstore_record *) |
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index b0a81173a268..d25599f2a3f8 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c | |||
@@ -495,7 +495,8 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, | |||
495 | return 0; | 495 | return 0; |
496 | } | 496 | } |
497 | 497 | ||
498 | static int efi_pstore_write(enum pstore_type_id type, u64 *id, | 498 | static int efi_pstore_write(enum pstore_type_id type, |
499 | enum kmsg_dump_reason reason, u64 *id, | ||
499 | unsigned int part, size_t size, struct pstore_info *psi) | 500 | unsigned int part, size_t size, struct pstore_info *psi) |
500 | { | 501 | { |
501 | char name[DUMP_NAME_LEN]; | 502 | char name[DUMP_NAME_LEN]; |
@@ -565,7 +566,7 @@ static int efi_pstore_write(enum pstore_type_id type, u64 *id, | |||
565 | static int efi_pstore_erase(enum pstore_type_id type, u64 id, | 566 | static int efi_pstore_erase(enum pstore_type_id type, u64 id, |
566 | struct pstore_info *psi) | 567 | struct pstore_info *psi) |
567 | { | 568 | { |
568 | efi_pstore_write(type, &id, (unsigned int)id, 0, psi); | 569 | efi_pstore_write(type, 0, &id, (unsigned int)id, 0, psi); |
569 | 570 | ||
570 | return 0; | 571 | return 0; |
571 | } | 572 | } |
@@ -587,7 +588,8 @@ static ssize_t efi_pstore_read(u64 *id, enum pstore_type_id *type, | |||
587 | return -1; | 588 | return -1; |
588 | } | 589 | } |
589 | 590 | ||
590 | static int efi_pstore_write(enum pstore_type_id type, u64 *id, | 591 | static int efi_pstore_write(enum pstore_type_id type, |
592 | enum kmsg_dump_reason reason, u64 *id, | ||
591 | unsigned int part, size_t size, struct pstore_info *psi) | 593 | unsigned int part, size_t size, struct pstore_info *psi) |
592 | { | 594 | { |
593 | return 0; | 595 | return 0; |
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 379a02dc1217..b3b426edb2fd 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c | |||
@@ -80,7 +80,8 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry) | |||
80 | { | 80 | { |
81 | struct pstore_private *p = dentry->d_inode->i_private; | 81 | struct pstore_private *p = dentry->d_inode->i_private; |
82 | 82 | ||
83 | p->psi->erase(p->type, p->id, p->psi); | 83 | if (p->psi->erase) |
84 | p->psi->erase(p->type, p->id, p->psi); | ||
84 | 85 | ||
85 | return simple_unlink(dir, dentry); | 86 | return simple_unlink(dir, dentry); |
86 | } | 87 | } |
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 57bbf9078ac8..9ec22d3b4293 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c | |||
@@ -122,7 +122,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, | |||
122 | memcpy(dst, s1 + s1_start, l1_cpy); | 122 | memcpy(dst, s1 + s1_start, l1_cpy); |
123 | memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); | 123 | memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); |
124 | 124 | ||
125 | ret = psinfo->write(PSTORE_TYPE_DMESG, &id, part, | 125 | ret = psinfo->write(PSTORE_TYPE_DMESG, reason, &id, part, |
126 | hsize + l1_cpy + l2_cpy, psinfo); | 126 | hsize + l1_cpy + l2_cpy, psinfo); |
127 | if (ret == 0 && reason == KMSG_DUMP_OOPS && pstore_is_mounted()) | 127 | if (ret == 0 && reason == KMSG_DUMP_OOPS && pstore_is_mounted()) |
128 | pstore_new_entry = 1; | 128 | pstore_new_entry = 1; |
@@ -207,8 +207,7 @@ void pstore_get_records(int quiet) | |||
207 | return; | 207 | return; |
208 | 208 | ||
209 | mutex_lock(&psi->read_mutex); | 209 | mutex_lock(&psi->read_mutex); |
210 | rc = psi->open(psi); | 210 | if (psi->open && psi->open(psi)) |
211 | if (rc) | ||
212 | goto out; | 211 | goto out; |
213 | 212 | ||
214 | while ((size = psi->read(&id, &type, &time, &buf, psi)) > 0) { | 213 | while ((size = psi->read(&id, &type, &time, &buf, psi)) > 0) { |
@@ -219,7 +218,8 @@ void pstore_get_records(int quiet) | |||
219 | if (rc && (rc != -EEXIST || !quiet)) | 218 | if (rc && (rc != -EEXIST || !quiet)) |
220 | failed++; | 219 | failed++; |
221 | } | 220 | } |
222 | psi->close(psi); | 221 | if (psi->close) |
222 | psi->close(psi); | ||
223 | out: | 223 | out: |
224 | mutex_unlock(&psi->read_mutex); | 224 | mutex_unlock(&psi->read_mutex); |
225 | 225 | ||
@@ -243,33 +243,5 @@ static void pstore_timefunc(unsigned long dummy) | |||
243 | mod_timer(&pstore_timer, jiffies + PSTORE_INTERVAL); | 243 | mod_timer(&pstore_timer, jiffies + PSTORE_INTERVAL); |
244 | } | 244 | } |
245 | 245 | ||
246 | /* | ||
247 | * Call platform driver to write a record to the | ||
248 | * persistent store. | ||
249 | */ | ||
250 | int pstore_write(enum pstore_type_id type, char *buf, size_t size) | ||
251 | { | ||
252 | u64 id; | ||
253 | int ret; | ||
254 | unsigned long flags; | ||
255 | |||
256 | if (!psinfo) | ||
257 | return -ENODEV; | ||
258 | |||
259 | if (size > psinfo->bufsize) | ||
260 | return -EFBIG; | ||
261 | |||
262 | spin_lock_irqsave(&psinfo->buf_lock, flags); | ||
263 | memcpy(psinfo->buf, buf, size); | ||
264 | ret = psinfo->write(type, &id, 0, size, psinfo); | ||
265 | if (ret == 0 && pstore_is_mounted()) | ||
266 | pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, psinfo->buf, | ||
267 | size, CURRENT_TIME, psinfo); | ||
268 | spin_unlock_irqrestore(&psinfo->buf_lock, flags); | ||
269 | |||
270 | return 0; | ||
271 | } | ||
272 | EXPORT_SYMBOL_GPL(pstore_write); | ||
273 | |||
274 | module_param(backend, charp, 0444); | 246 | module_param(backend, charp, 0444); |
275 | MODULE_PARM_DESC(backend, "Pstore backend to use"); | 247 | MODULE_PARM_DESC(backend, "Pstore backend to use"); |
diff --git a/include/linux/pstore.h b/include/linux/pstore.h index 2ca8cde5459d..e1461e143be2 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h | |||
@@ -22,6 +22,9 @@ | |||
22 | #ifndef _LINUX_PSTORE_H | 22 | #ifndef _LINUX_PSTORE_H |
23 | #define _LINUX_PSTORE_H | 23 | #define _LINUX_PSTORE_H |
24 | 24 | ||
25 | #include <linux/time.h> | ||
26 | #include <linux/kmsg_dump.h> | ||
27 | |||
25 | /* types */ | 28 | /* types */ |
26 | enum pstore_type_id { | 29 | enum pstore_type_id { |
27 | PSTORE_TYPE_DMESG = 0, | 30 | PSTORE_TYPE_DMESG = 0, |
@@ -41,7 +44,8 @@ struct pstore_info { | |||
41 | ssize_t (*read)(u64 *id, enum pstore_type_id *type, | 44 | ssize_t (*read)(u64 *id, enum pstore_type_id *type, |
42 | struct timespec *time, char **buf, | 45 | struct timespec *time, char **buf, |
43 | struct pstore_info *psi); | 46 | struct pstore_info *psi); |
44 | int (*write)(enum pstore_type_id type, u64 *id, | 47 | int (*write)(enum pstore_type_id type, |
48 | enum kmsg_dump_reason reason, u64 *id, | ||
45 | unsigned int part, size_t size, struct pstore_info *psi); | 49 | unsigned int part, size_t size, struct pstore_info *psi); |
46 | int (*erase)(enum pstore_type_id type, u64 id, | 50 | int (*erase)(enum pstore_type_id type, u64 id, |
47 | struct pstore_info *psi); | 51 | struct pstore_info *psi); |
@@ -50,18 +54,12 @@ struct pstore_info { | |||
50 | 54 | ||
51 | #ifdef CONFIG_PSTORE | 55 | #ifdef CONFIG_PSTORE |
52 | extern int pstore_register(struct pstore_info *); | 56 | extern int pstore_register(struct pstore_info *); |
53 | extern int pstore_write(enum pstore_type_id type, char *buf, size_t size); | ||
54 | #else | 57 | #else |
55 | static inline int | 58 | static inline int |
56 | pstore_register(struct pstore_info *psi) | 59 | pstore_register(struct pstore_info *psi) |
57 | { | 60 | { |
58 | return -ENODEV; | 61 | return -ENODEV; |
59 | } | 62 | } |
60 | static inline int | ||
61 | pstore_write(enum pstore_type_id type, char *buf, size_t size) | ||
62 | { | ||
63 | return -ENODEV; | ||
64 | } | ||
65 | #endif | 63 | #endif |
66 | 64 | ||
67 | #endif /*_LINUX_PSTORE_H*/ | 65 | #endif /*_LINUX_PSTORE_H*/ |