diff options
author | Richard Purdie <rpurdie@openedhand.com> | 2007-07-10 20:33:54 +0100 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2007-07-11 14:57:17 +0100 |
commit | 8691a729a2a3d739ee40a577053157393450aabd (patch) | |
tree | db9c69d95dc2ff04e0752ba2df8ecb3bfd217d21 /drivers/mtd/mtdoops.c | |
parent | a2e96b627b58efe2d618a415f34b9b9d9f829bd6 (diff) |
[MTD] Add sync/unblank function to mtdoops
mtdoops wasn't ensuring data was flushed to flash in crash situations
after recent changes in mainline kernels as tracking the
oops_in_progress variable was no longer enough. We can use the "unblank"
console call as a sync call to tell us to write out the buffer though.
Therefore add a sync function to mtdoops and call this when console
unblank events occur.
Signed-off-by: Richard Purdie <rpurdie@openedhand.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers/mtd/mtdoops.c')
-rw-r--r-- | drivers/mtd/mtdoops.c | 57 |
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) flush_scheduled_work(); } - -static void -mtdoops_console_write(struct console *co, const char *s, unsigned int count) +static void mtdoops_console_sync(void) { - struct mtdoops_context *cxt = co->data; + struct mtdoops_context *cxt = &oops_cxt; struct mtd_info *mtd = cxt->mtd; - int i, ret; + size_t retlen; + int ret; if (!cxt->ready || !mtd) return; - if (!oops_in_progress && cxt->writecount != 0) { - size_t retlen; - if (cxt->writecount < OOPS_PAGE_SIZE) - memset(cxt->oops_buf + cxt->writecount, 0xff, + if (cxt->writecount == 0) + return; + + if (cxt->writecount < OOPS_PAGE_SIZE) + memset(cxt->oops_buf + cxt->writecount, 0xff, OOPS_PAGE_SIZE - cxt->writecount); - ret = mtd->write(mtd, cxt->nextpage * OOPS_PAGE_SIZE, + ret = mtd->write(mtd, cxt->nextpage * OOPS_PAGE_SIZE, OOPS_PAGE_SIZE, &retlen, cxt->oops_buf); - cxt->ready = 0; - cxt->writecount = 0; - - if ((retlen != OOPS_PAGE_SIZE) || (ret < 0)) - printk(KERN_ERR "mtdoops: Write failure at %d (%d of %d" - " written), err %d.\n", - cxt->nextpage * OOPS_PAGE_SIZE, retlen, - OOPS_PAGE_SIZE, ret); - - ret = mtdoops_inc_counter(cxt); - if (ret == 1) - schedule_work(&cxt->work); + cxt->ready = 0; + cxt->writecount = 0; + + if ((retlen != OOPS_PAGE_SIZE) || (ret < 0)) + printk(KERN_ERR "mtdoops: Write failure at %d (%d of %d written), err %d.\n", + cxt->nextpage * OOPS_PAGE_SIZE, retlen, OOPS_PAGE_SIZE, ret); + + ret = mtdoops_inc_counter(cxt); + if (ret == 1) + schedule_work(&cxt->work); +} + +static void +mtdoops_console_write(struct console *co, const char *s, unsigned int count) +{ + struct mtdoops_context *cxt = co->data; + struct mtd_info *mtd = cxt->mtd; + int i; + + if (!oops_in_progress) { + mtdoops_console_sync(); + return; } - if (!oops_in_progress) + if (!cxt->ready || !mtd) return; if (cxt->writecount == 0) { @@ -323,6 +333,7 @@ static struct console mtdoops_console = { .name = "ttyMTD", .write = mtdoops_console_write, .setup = mtdoops_console_setup, + .unblank = mtdoops_console_sync, .flags = CON_PRINTBUFFER, .index = -1, .data = &oops_cxt, |