X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fmtd%2Fmtdoops.c;h=5a680e1e61f14dbc2ba684482792f2f40aabbee9;hb=72800df9ba3199df02a95b3830c49fbf16ec4a6d;hp=34681bc911058ea6a12b9e497cc72aeb17877488;hpb=b7e23d913aafc93fc5f119e1be17620073cc3811;p=linux-2.6 diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index 34681bc911..5a680e1e61 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c @@ -28,12 +28,14 @@ #include #include #include +#include #include +#include #include #define OOPS_PAGE_SIZE 4096 -struct mtdoops_context { +static struct mtdoops_context { int mtd_index; struct work_struct work_erase; struct work_struct work_write; @@ -183,10 +185,8 @@ badblock: goto badblock; } -static void mtdoops_workfunc_write(struct work_struct *work) +static void mtdoops_write(struct mtdoops_context *cxt, int panic) { - struct mtdoops_context *cxt = - container_of(work, struct mtdoops_context, work_write); struct mtd_info *mtd = cxt->mtd; size_t retlen; int ret; @@ -195,7 +195,11 @@ static void mtdoops_workfunc_write(struct work_struct *work) memset(cxt->oops_buf + cxt->writecount, 0xff, OOPS_PAGE_SIZE - cxt->writecount); - ret = mtd->write(mtd, cxt->nextpage * OOPS_PAGE_SIZE, + if (panic) + ret = mtd->panic_write(mtd, cxt->nextpage * OOPS_PAGE_SIZE, + OOPS_PAGE_SIZE, &retlen, cxt->oops_buf); + else + ret = mtd->write(mtd, cxt->nextpage * OOPS_PAGE_SIZE, OOPS_PAGE_SIZE, &retlen, cxt->oops_buf); cxt->writecount = 0; @@ -205,6 +209,15 @@ static void mtdoops_workfunc_write(struct work_struct *work) cxt->nextpage * OOPS_PAGE_SIZE, retlen, OOPS_PAGE_SIZE, ret); mtdoops_inc_counter(cxt); +} + + +static void mtdoops_workfunc_write(struct work_struct *work) +{ + struct mtdoops_context *cxt = + container_of(work, struct mtdoops_context, work_write); + + mtdoops_write(cxt, 0); } static void find_next_position(struct mtdoops_context *cxt) @@ -314,7 +327,11 @@ static void mtdoops_console_sync(void) cxt->ready = 0; spin_unlock_irqrestore(&cxt->writecount_lock, flags); - schedule_work(&cxt->work_write); + if (mtd->panic_write && in_interrupt()) + /* Interrupt context, we're going to panic so try and log */ + mtdoops_write(cxt, 1); + else + schedule_work(&cxt->work_write); } static void