Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 621e4f8e authored by Richard Purdie's avatar Richard Purdie Committed by David Woodhouse
Browse files

[MTD] mtdoops: Use the panic_write function when present



When the MTD provides a panic_write function, use it.

Signed-off-by: default avatarRichard Purdie <rpurdie@rpsys.net>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 388bbb09
Loading
Loading
Loading
Loading
+21 −5
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@
#include <linux/workqueue.h>
#include <linux/workqueue.h>
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/wait.h>
#include <linux/wait.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/spinlock.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/mtd.h>


@@ -183,10 +184,8 @@ badblock:
	goto 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;
	struct mtd_info *mtd = cxt->mtd;
	size_t retlen;
	size_t retlen;
	int ret;
	int ret;
@@ -195,6 +194,10 @@ static void mtdoops_workfunc_write(struct work_struct *work)
		memset(cxt->oops_buf + cxt->writecount, 0xff,
		memset(cxt->oops_buf + cxt->writecount, 0xff,
					OOPS_PAGE_SIZE - cxt->writecount);
					OOPS_PAGE_SIZE - cxt->writecount);


	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,
		ret = mtd->write(mtd, cxt->nextpage * OOPS_PAGE_SIZE,
					OOPS_PAGE_SIZE, &retlen, cxt->oops_buf);
					OOPS_PAGE_SIZE, &retlen, cxt->oops_buf);


@@ -207,6 +210,15 @@ static void mtdoops_workfunc_write(struct work_struct *work)
	mtdoops_inc_counter(cxt);
	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)
static void find_next_position(struct mtdoops_context *cxt)
{
{
	struct mtd_info *mtd = cxt->mtd;
	struct mtd_info *mtd = cxt->mtd;
@@ -314,6 +326,10 @@ static void mtdoops_console_sync(void)
	cxt->ready = 0;
	cxt->ready = 0;
	spin_unlock_irqrestore(&cxt->writecount_lock, flags);
	spin_unlock_irqrestore(&cxt->writecount_lock, flags);


	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);
		schedule_work(&cxt->work_write);
}
}