[PATCH/RFC] oops and panic message logging to MTD

Artem Bityutskiy dedekind at infradead.org
Tue Jun 19 04:07:35 EDT 2007


On Mon, 2007-06-18 at 17:31 +0100, Richard Purdie wrote:
> +static int mtdoops_erase_block(struct mtd_info *mtd, int offset)
> +{
> +	struct erase_info erase;
> +	DECLARE_WAITQUEUE(wait, current);
> +	wait_queue_head_t wait_q;
> +	int ret;
> +
> +	init_waitqueue_head(&wait_q);
> +	erase.mtd = mtd;
> +	erase.callback = mtdoops_erase_callback;
> +	erase.addr = offset;
> +	if (mtd->erasesize < OOPS_PAGE_SIZE)
> +		erase.len = OOPS_PAGE_SIZE;
> +	else
> +		erase.len = mtd->erasesize;
> +	erase.priv = (u_long)&wait_q;
> +
> +	set_current_state(TASK_INTERRUPTIBLE);
> +	add_wait_queue(&wait_q, &wait);
> +
> +	ret = mtd->erase(mtd, &erase);
> +	if (ret) {
> +		set_current_state(TASK_RUNNING);
> +		remove_wait_queue(&wait_q, &wait);
> +		printk(KERN_WARNING "mtdoops: erase of region [0x%x, 0x%x] "
> +				     "on \"%s\" failed\n",
> +			erase.addr, erase.len, mtd->name);
> +		return ret;
> +	}
> +
> +	schedule();  /* Wait for erase to finish. */
> +	remove_wait_queue(&wait_q, &wait);
> +
> +	return 0;
> +}

Also, could you please use wait_event_interruptible() instead of
set_current_state() which looks better (indeed, you have wait queue, so
use wq calls).

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)




More information about the linux-mtd mailing list