aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdoops.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/mtdoops.c')
-rw-r--r--drivers/mtd/mtdoops.c57
1 files changed, 34 insertions, 23 deletions
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index cfc28ab4a3dc..62ee2043d046 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -250,40 +250,50 @@ static void mtdoops_notify_remove(struct mtd_info *mtd)
250 flush_scheduled_work(); 250 flush_scheduled_work();
251} 251}
252 252
253 253static void mtdoops_console_sync(void)
254static void
255mtdoops_console_write(struct console *co, const char *s, unsigned int count)
256{ 254{
257 struct mtdoops_context *cxt = co->data; 255 struct mtdoops_context *cxt = &oops_cxt;
258 struct mtd_info *mtd = cxt->mtd; 256 struct mtd_info *mtd = cxt->mtd;
259 int i, ret; 257 size_t retlen;
258 int ret;
260 259
261 if (!cxt->ready || !mtd) 260 if (!cxt->ready || !mtd)
262 return; 261 return;
263 262
264 if (!oops_in_progress && cxt->writecount != 0) { 263 if (cxt->writecount == 0)
265 size_t retlen; 264 return;
266 if (cxt->writecount < OOPS_PAGE_SIZE) 265
267 memset(cxt->oops_buf + cxt->writecount, 0xff, 266 if (cxt->writecount < OOPS_PAGE_SIZE)
267 memset(cxt->oops_buf + cxt->writecount, 0xff,
268 OOPS_PAGE_SIZE - cxt->writecount); 268 OOPS_PAGE_SIZE - cxt->writecount);
269 269
270 ret = mtd->write(mtd, cxt->nextpage * OOPS_PAGE_SIZE, 270 ret = mtd->write(mtd, cxt->nextpage * OOPS_PAGE_SIZE,
271 OOPS_PAGE_SIZE, &retlen, cxt->oops_buf); 271 OOPS_PAGE_SIZE, &retlen, cxt->oops_buf);
272 cxt->ready = 0; 272 cxt->ready = 0;
273 cxt->writecount = 0; 273 cxt->writecount = 0;
274 274
275 if ((retlen != OOPS_PAGE_SIZE) || (ret < 0)) 275 if ((retlen != OOPS_PAGE_SIZE) || (ret < 0))
276 printk(KERN_ERR "mtdoops: Write failure at %d (%d of %d" 276 printk(KERN_ERR "mtdoops: Write failure at %d (%d of %d written), err %d.\n",
277 " written), err %d.\n", 277 cxt->nextpage * OOPS_PAGE_SIZE, retlen, OOPS_PAGE_SIZE, ret);
278 cxt->nextpage * OOPS_PAGE_SIZE, retlen, 278
279 OOPS_PAGE_SIZE, ret); 279 ret = mtdoops_inc_counter(cxt);
280 280 if (ret == 1)
281 ret = mtdoops_inc_counter(cxt); 281 schedule_work(&cxt->work);
282 if (ret == 1) 282}
283 schedule_work(&cxt->work); 283
284static void
285mtdoops_console_write(struct console *co, const char *s, unsigned int count)
286{
287 struct mtdoops_context *cxt = co->data;
288 struct mtd_info *mtd = cxt->mtd;
289 int i;
290
291 if (!oops_in_progress) {
292 mtdoops_console_sync();
293 return;
284 } 294 }
285 295
286 if (!oops_in_progress) 296 if (!cxt->ready || !mtd)
287 return; 297 return;
288 298
289 if (cxt->writecount == 0) { 299 if (cxt->writecount == 0) {
@@ -323,6 +333,7 @@ static struct console mtdoops_console = {
323 .name = "ttyMTD", 333 .name = "ttyMTD",
324 .write = mtdoops_console_write, 334 .write = mtdoops_console_write,
325 .setup = mtdoops_console_setup, 335 .setup = mtdoops_console_setup,
336 .unblank = mtdoops_console_sync,
326 .flags = CON_PRINTBUFFER, 337 .flags = CON_PRINTBUFFER,
327 .index = -1, 338 .index = -1,
328 .data = &oops_cxt, 339 .data = &oops_cxt,