target/linux/generic/files/drivers/mtd/nand/mtk_bmt_nmbm.c
static bool nmbm_map_block(struct nmbm_instance *ni, uint32_t lb)
{
	uint32_t pb;
	bool success;

	if (ni->mapping_blocks_ba == ni->mapping_blocks_top_ba) {
		nlog_warn(ni, "No spare unmapped blocks.\n");
		return false;
	}

	success = nmbm_block_walk(ni, false, ni->mapping_blocks_top_ba, &pb, 0,
				  ni->mapping_blocks_ba);
	if (!success) {
		nlog_warn(ni, "No spare unmapped blocks.\n");
		nmbm_update_info_table(ni);
		ni->mapping_blocks_top_ba = ni->mapping_blocks_ba;
		return false;
	}

	ni->block_mapping[lb] = pb;
	ni->mapping_blocks_top_ba--;
	ni->block_mapping_changed++;

	nlog_info(ni, "Logic block %u mapped to physical block %u\n", lb, pb);

	return true;
}
/*
 * nmbm_map_block - Map a bad block to a unused spare block
 * @ni: NMBM instance structure
 * @lb: logic block addr to map
 */
Map a bad block to a unused spare block
@ni: NMBM instance structure
@lb: logic block addr to map
Map a bad block to a unused spare block @ni : NMBM instance structure @lb : logic block addr to map
static bool nmbm_map_block(struct nmbm_instance *ni, uint32_t lb)
{
	uint32_t pb;
	bool success;
	if (ni->mapping_blocks_ba == ni->mapping_blocks_top_ba) {
		nlog_warn(ni, "No spare unmapped blocks.\n");
		return false;
	}
	success = nmbm_block_walk(ni, false, ni->mapping_blocks_top_ba, &pb, 0,
				  ni->mapping_blocks_ba);
	if (!success) {
		nlog_warn(ni, "No spare unmapped blocks.\n");
		nmbm_update_info_table(ni);
		ni->mapping_blocks_top_ba = ni->mapping_blocks_ba;
		return false;
	}
	ni->block_mapping[lb] = pb;
	ni->mapping_blocks_top_ba--;
	ni->block_mapping_changed++;
	nlog_info(ni, "Logic block %u mapped to physical block %u\n", lb, pb);
	return true;
}
static bool nmbm_map_block ( struct nmbm_instance * ni , uint32_t lb ) { uint32_t pb ; bool success ; if ( ni -> mapping_blocks_ba == ni -> mapping_blocks_top_ba ) { nlog_warn ( ni , " \n " ) ; return false ; } success = nmbm_block_walk ( ni , false , ni -> mapping_blocks_top_ba , & pb , 0 , ni -> mapping_blocks_ba ) ; if ( ! success ) { nlog_warn ( ni , " \n " ) ; nmbm_update_info_table ( ni ) ; ni -> mapping_blocks_top_ba = ni -> mapping_blocks_ba ; return false ; } ni -> block_mapping [ lb ] = pb ; ni -> mapping_blocks_top_ba -- ; ni -> block_mapping_changed ++ ; nlog_info ( ni , " \n " , lb , pb ) ; return true ; }
nmbm_map_block - Map a bad block to a unused spare block
 @ni: NMBM instance structure
 @lb: logic block addr to map
nmbm_map_block - Map a bad block to a unused spare block @ni : NMBM instance structure @lb : logic block addr to map