/* On NAND we try to mark this block bad. If the block was erased more than MAX_ERASE_FAILURES we mark it finaly bad. Don't care about failures. This block remains on the erase-pending or badblock list as long as nobody manipulates the flash with a bootloader or something like that.  */
int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, uint32_t bad_offset)
/* On NAND we try to mark this block bad. If the block was erased more than MAX_ERASE_FAILURES we mark it finaly bad. Don't care about failures. This block remains on the erase-pending or badblock list as long as nobody manipulates the flash with a bootloader or something like that.  */
int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, uint32_t bad_offset)
{
	int 	ret;
	if( ++jeb->bad_count < MAX_ERASE_FAILURES)
		return 0;
	if (!c->mtd->block_markbad)
		return 1;
	printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset);
	ret = c->mtd->block_markbad(c->mtd, bad_offset);
	if (ret) {
		D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret));
		return ret;
	}
	return 1;
}