aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/pstore/ram.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 6b7676738493..d770d7266e96 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -85,6 +85,33 @@ static int ramoops_pstore_open(struct pstore_info *psi)
85 return 0; 85 return 0;
86} 86}
87 87
88static struct persistent_ram_zone *
89ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
90 u64 *id,
91 enum pstore_type_id *typep, enum pstore_type_id type,
92 bool update)
93{
94 struct persistent_ram_zone *prz;
95 int i = (*c)++;
96
97 if (i >= max)
98 return NULL;
99
100 prz = przs[i];
101
102 if (update) {
103 /* Update old/shadowed buffer. */
104 persistent_ram_save_old(prz);
105 if (!persistent_ram_old_size(prz))
106 return NULL;
107 }
108
109 *typep = type;
110 *id = i;
111
112 return prz;
113}
114
88static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, 115static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
89 struct timespec *time, 116 struct timespec *time,
90 char **buf, 117 char **buf,
@@ -94,20 +121,16 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
94 struct ramoops_context *cxt = psi->data; 121 struct ramoops_context *cxt = psi->data;
95 struct persistent_ram_zone *prz; 122 struct persistent_ram_zone *prz;
96 123
97 if (cxt->dump_read_cnt >= cxt->max_dump_cnt) 124 prz = ramoops_get_next_prz(cxt->przs, &cxt->dump_read_cnt,
98 return -EINVAL; 125 cxt->max_dump_cnt, id, type,
99 126 PSTORE_TYPE_DMESG, 1);
100 *id = cxt->dump_read_cnt++; 127 if (!prz)
101 prz = cxt->przs[*id]; 128 return 0;
102 129
103 /* Only supports dmesg output so far. */
104 *type = PSTORE_TYPE_DMESG;
105 /* TODO(kees): Bogus time for the moment. */ 130 /* TODO(kees): Bogus time for the moment. */
106 time->tv_sec = 0; 131 time->tv_sec = 0;
107 time->tv_nsec = 0; 132 time->tv_nsec = 0;
108 133
109 /* Update old/shadowed buffer. */
110 persistent_ram_save_old(prz);
111 size = persistent_ram_old_size(prz); 134 size = persistent_ram_old_size(prz);
112 *buf = kmalloc(size, GFP_KERNEL); 135 *buf = kmalloc(size, GFP_KERNEL);
113 if (*buf == NULL) 136 if (*buf == NULL)