diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-10-08 09:44:29 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-11-09 00:16:27 -0500 |
commit | 7b1f4020d0d16a17b9c48570bdb7b4ad99be3553 (patch) | |
tree | 88c0de92a9196f84b263f422f98d04a8e0f05322 /arch/powerpc/platforms | |
parent | 9b56d54380adb5fef71f687109bbd6f8413d694f (diff) |
spufs: get rid of dump_emit() wrappers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r-- | arch/powerpc/platforms/cell/spufs/coredump.c | 69 |
1 files changed, 20 insertions, 49 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c index 5d9b0a288f36..1aaaa586fa50 100644 --- a/arch/powerpc/platforms/cell/spufs/coredump.c +++ b/arch/powerpc/platforms/cell/spufs/coredump.c | |||
@@ -50,33 +50,6 @@ static ssize_t do_coredump_read(int num, struct spu_context *ctx, void *buffer, | |||
50 | return ++ret; /* count trailing NULL */ | 50 | return ++ret; /* count trailing NULL */ |
51 | } | 51 | } |
52 | 52 | ||
53 | /* | ||
54 | * These are the only things you should do on a core-file: use only these | ||
55 | * functions to write out all the necessary info. | ||
56 | */ | ||
57 | static int spufs_dump_write(struct coredump_params *cprm, const void *addr, int nr) | ||
58 | { | ||
59 | if (!dump_emit(cprm, addr, nr)) | ||
60 | return -EIO; | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static int spufs_dump_align(struct coredump_params *cprm, char *buf, loff_t new_off) | ||
65 | { | ||
66 | int rc, size; | ||
67 | |||
68 | size = min((loff_t)PAGE_SIZE, new_off - cprm->written); | ||
69 | memset(buf, 0, size); | ||
70 | |||
71 | rc = 0; | ||
72 | while (rc == 0 && new_off > cprm->written) { | ||
73 | size = min((loff_t)PAGE_SIZE, new_off - cprm->written); | ||
74 | rc = spufs_dump_write(cprm, buf, size); | ||
75 | } | ||
76 | |||
77 | return rc; | ||
78 | } | ||
79 | |||
80 | static int spufs_ctx_note_size(struct spu_context *ctx, int dfd) | 53 | static int spufs_ctx_note_size(struct spu_context *ctx, int dfd) |
81 | { | 54 | { |
82 | int i, sz, total = 0; | 55 | int i, sz, total = 0; |
@@ -159,7 +132,7 @@ static int spufs_arch_write_note(struct spu_context *ctx, int i, | |||
159 | struct coredump_params *cprm, int dfd) | 132 | struct coredump_params *cprm, int dfd) |
160 | { | 133 | { |
161 | loff_t pos = 0; | 134 | loff_t pos = 0; |
162 | int sz, rc, nread, total = 0; | 135 | int sz, rc, total = 0; |
163 | const int bufsz = PAGE_SIZE; | 136 | const int bufsz = PAGE_SIZE; |
164 | char *name; | 137 | char *name; |
165 | char fullname[80], *buf; | 138 | char fullname[80], *buf; |
@@ -177,38 +150,36 @@ static int spufs_arch_write_note(struct spu_context *ctx, int i, | |||
177 | en.n_descsz = sz; | 150 | en.n_descsz = sz; |
178 | en.n_type = NT_SPU; | 151 | en.n_type = NT_SPU; |
179 | 152 | ||
180 | rc = spufs_dump_write(cprm, &en, sizeof(en)); | 153 | if (!dump_emit(cprm, &en, sizeof(en))) |
181 | if (rc) | 154 | goto Eio; |
182 | goto out; | ||
183 | 155 | ||
184 | rc = spufs_dump_write(cprm, fullname, en.n_namesz); | 156 | if (!dump_emit(cprm, fullname, en.n_namesz)) |
185 | if (rc) | 157 | goto Eio; |
186 | goto out; | ||
187 | 158 | ||
188 | rc = spufs_dump_align(cprm, buf, roundup(cprm->written, 4)); | 159 | if (!dump_skip(cprm, roundup(cprm->written, 4) - cprm->written)) |
189 | if (rc) | 160 | goto Eio; |
190 | goto out; | ||
191 | 161 | ||
192 | do { | 162 | do { |
193 | nread = do_coredump_read(i, ctx, buf, bufsz, &pos); | 163 | rc = do_coredump_read(i, ctx, buf, bufsz, &pos); |
194 | if (nread > 0) { | 164 | if (rc > 0) { |
195 | rc = spufs_dump_write(cprm, buf, nread); | 165 | if (!dump_emit(cprm, buf, rc)) |
196 | if (rc) | 166 | goto Eio; |
197 | goto out; | 167 | total += rc; |
198 | total += nread; | ||
199 | } | 168 | } |
200 | } while (nread == bufsz && total < sz); | 169 | } while (rc == bufsz && total < sz); |
201 | 170 | ||
202 | if (nread < 0) { | 171 | if (rc < 0) |
203 | rc = nread; | ||
204 | goto out; | 172 | goto out; |
205 | } | ||
206 | |||
207 | rc = spufs_dump_align(cprm, buf, roundup(cprm->written - total + sz, 4)); | ||
208 | 173 | ||
174 | if (!dump_skip(cprm, | ||
175 | roundup(cprm->written - total + sz, 4) - cprm->written)) | ||
176 | goto Eio; | ||
209 | out: | 177 | out: |
210 | free_page((unsigned long)buf); | 178 | free_page((unsigned long)buf); |
211 | return rc; | 179 | return rc; |
180 | Eio: | ||
181 | free_page((unsigned long)buf); | ||
182 | return -EIO; | ||
212 | } | 183 | } |
213 | 184 | ||
214 | int spufs_coredump_extra_notes_write(struct coredump_params *cprm) | 185 | int spufs_coredump_extra_notes_write(struct coredump_params *cprm) |