target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c
static bool remap_block_v2(u16 block, u16 mapped_block, int copy_len)
{
	u16 new_block;
	struct bbbt *bbt;

	bbt = bmtd.bbt;
	new_block = find_valid_block_in_pool(bbt);
	if (new_block == 0)
		return false;

	/* Map new bad block to available block in pool */
	bbt->bb_tbl[block] = new_block;

	/* Erase new block */
	bbt_nand_erase(new_block);
	if (copy_len > 0)
		bbt_nand_copy(new_block, mapped_block, copy_len);

	bmtd.bmt_blk_idx = upload_bmt(bbt, bmtd.bmt_blk_idx);

	return true;
}
/* We met a bad block, mark it as bad and map it to a valid block in pool,
 * if it's a write failure, we need to write the data to mapped block
 */
We met a bad block, mark it as bad and map it to a valid block in pool,
if it's a write failure, we need to write the data to mapped block
We met a bad block mark it as bad and map it to a valid block in pool if it ' s a write failure we need to write the data to mapped block
static bool remap_block_v2(u16 block, u16 mapped_block, int copy_len)
{
	u16 new_block;
	struct bbbt *bbt;
	bbt = bmtd.bbt;
	new_block = find_valid_block_in_pool(bbt);
	if (new_block == 0)
		return false;
	bbt->bb_tbl[block] = new_block;
	bbt_nand_erase(new_block);
	if (copy_len > 0)
		bbt_nand_copy(new_block, mapped_block, copy_len);
	bmtd.bmt_blk_idx = upload_bmt(bbt, bmtd.bmt_blk_idx);
	return true;
}
static bool remap_block_v2 ( u16 block , u16 mapped_block , int copy_len ) { u16 new_block ; struct bbbt * bbt ; bbt = bmtd . bbt ; new_block = find_valid_block_in_pool ( bbt ) ; if ( new_block == 0 ) return false ; bbt -> bb_tbl [ block ] = new_block ; bbt_nand_erase ( new_block ) ; if ( copy_len > 0 ) bbt_nand_copy ( new_block , mapped_block , copy_len ) ; bmtd . bmt_blk_idx = upload_bmt ( bbt , bmtd . bmt_blk_idx ) ; return true ; }
We met a bad block, mark it as bad and map it to a valid block in pool,
 if it's a write failure, we need to write the data to mapped block
We met a bad block mark it as bad and map it to a valid block in pool if it ' s a write failure we need to write the data to mapped block
/* Map new bad block to available block in pool */ /* Erase new block */