target/linux/generic/files/drivers/mtd/nand/mtk_bmt_nmbm.c
static void nmbm_init_structure(struct nmbm_instance *ni)
{
	uint32_t pages_per_block, blocks_per_chip;
	uintptr_t ptr;

	pages_per_block = bmtd.blk_size / bmtd.pg_size;
	blocks_per_chip = bmtd.total_blks;

	ni->rawpage_size = bmtd.pg_size + bmtd.mtd->oobsize;
	ni->rawblock_size = pages_per_block * ni->rawpage_size;
	ni->rawchip_size = blocks_per_chip * ni->rawblock_size;

	/* Calculate number of block this chip */
	ni->block_count = blocks_per_chip;

	/* Calculate info table size */
	ni->state_table_size = ((ni->block_count + NMBM_BITMAP_BLOCKS_PER_UNIT - 1) /
		NMBM_BITMAP_BLOCKS_PER_UNIT) * NMBM_BITMAP_UNIT_SIZE;
	ni->mapping_table_size = ni->block_count * sizeof(*ni->block_mapping);

	ni->info_table_size = ALIGN(sizeof(ni->info_table),
					 bmtd.pg_size);
	ni->info_table.state_table_off = ni->info_table_size;

	ni->info_table_size += ALIGN(ni->state_table_size,
					  bmtd.pg_size);
	ni->info_table.mapping_table_off = ni->info_table_size;

	ni->info_table_size += ALIGN(ni->mapping_table_size,
					  bmtd.pg_size);

	ni->info_table_spare_blocks = nmbm_get_spare_block_count(
		size2blk(ni, ni->info_table_size));

	/* Assign memory to members */
	ptr = (uintptr_t)ni + sizeof(*ni);

	ni->info_table_cache = (void *)ptr;
	ptr += ni->info_table_size;

	ni->block_state = (void *)ptr;
	ptr += ni->state_table_size;

	ni->block_mapping = (void *)ptr;
	ptr += ni->mapping_table_size;

	ni->page_cache = bmtd.data_buf;

	/* Initialize block state table */
	ni->block_state_changed = 0;
	memset(ni->block_state, 0xff, ni->state_table_size);

	/* Initialize block mapping table */
	ni->block_mapping_changed = 0;
}
/*
 * nmbm_init_structure - Initialize members of instance structure
 * @ni: NMBM instance structure
 */
Initialize members of instance structure
@ni: NMBM instance structure
Initialize members of instance structure @ni : NMBM instance structure
static void nmbm_init_structure(struct nmbm_instance *ni)
{
	uint32_t pages_per_block, blocks_per_chip;
	uintptr_t ptr;
	pages_per_block = bmtd.blk_size / bmtd.pg_size;
	blocks_per_chip = bmtd.total_blks;
	ni->rawpage_size = bmtd.pg_size + bmtd.mtd->oobsize;
	ni->rawblock_size = pages_per_block * ni->rawpage_size;
	ni->rawchip_size = blocks_per_chip * ni->rawblock_size;
	ni->block_count = blocks_per_chip;
	ni->state_table_size = ((ni->block_count + NMBM_BITMAP_BLOCKS_PER_UNIT - 1) /
		NMBM_BITMAP_BLOCKS_PER_UNIT) * NMBM_BITMAP_UNIT_SIZE;
	ni->mapping_table_size = ni->block_count * sizeof(*ni->block_mapping);
	ni->info_table_size = ALIGN(sizeof(ni->info_table),
					 bmtd.pg_size);
	ni->info_table.state_table_off = ni->info_table_size;
	ni->info_table_size += ALIGN(ni->state_table_size,
					  bmtd.pg_size);
	ni->info_table.mapping_table_off = ni->info_table_size;
	ni->info_table_size += ALIGN(ni->mapping_table_size,
					  bmtd.pg_size);
	ni->info_table_spare_blocks = nmbm_get_spare_block_count(
		size2blk(ni, ni->info_table_size));
	ptr = (uintptr_t)ni + sizeof(*ni);
	ni->info_table_cache = (void *)ptr;
	ptr += ni->info_table_size;
	ni->block_state = (void *)ptr;
	ptr += ni->state_table_size;
	ni->block_mapping = (void *)ptr;
	ptr += ni->mapping_table_size;
	ni->page_cache = bmtd.data_buf;
	ni->block_state_changed = 0;
	memset(ni->block_state, 0xff, ni->state_table_size);
	ni->block_mapping_changed = 0;
}
static void nmbm_init_structure ( struct nmbm_instance * ni ) { uint32_t pages_per_block , blocks_per_chip ; uintptr_t ptr ; pages_per_block = bmtd . blk_size / bmtd . pg_size ; blocks_per_chip = bmtd . total_blks ; ni -> rawpage_size = bmtd . pg_size + bmtd . mtd -> oobsize ; ni -> rawblock_size = pages_per_block * ni -> rawpage_size ; ni -> rawchip_size = blocks_per_chip * ni -> rawblock_size ; ni -> block_count = blocks_per_chip ; ni -> state_table_size = ( ( ni -> block_count + NMBM_BITMAP_BLOCKS_PER_UNIT - 1 ) / NMBM_BITMAP_BLOCKS_PER_UNIT ) * NMBM_BITMAP_UNIT_SIZE ; ni -> mapping_table_size = ni -> block_count * sizeof ( * ni -> block_mapping ) ; ni -> info_table_size = ALIGN ( sizeof ( ni -> info_table ) , bmtd . pg_size ) ; ni -> info_table . state_table_off = ni -> info_table_size ; ni -> info_table_size += ALIGN ( ni -> state_table_size , bmtd . pg_size ) ; ni -> info_table . mapping_table_off = ni -> info_table_size ; ni -> info_table_size += ALIGN ( ni -> mapping_table_size , bmtd . pg_size ) ; ni -> info_table_spare_blocks = nmbm_get_spare_block_count ( size2blk ( ni , ni -> info_table_size ) ) ; ptr = ( uintptr_t ) ni + sizeof ( * ni ) ; ni -> info_table_cache = ( void * ) ptr ; ptr += ni -> info_table_size ; ni -> block_state = ( void * ) ptr ; ptr += ni -> state_table_size ; ni -> block_mapping = ( void * ) ptr ; ptr += ni -> mapping_table_size ; ni -> page_cache = bmtd . data_buf ; ni -> block_state_changed = 0 ; memset ( ni -> block_state , 0xff , ni -> state_table_size ) ; ni -> block_mapping_changed = 0 ; }
nmbm_init_structure - Initialize members of instance structure
 @ni: NMBM instance structure
nmbm_init_structure - Initialize members of instance structure @ni : NMBM instance structure
/* Calculate number of block this chip */ /* Calculate info table size */ /* Assign memory to members */ /* Initialize block state table */ /* Initialize block mapping table */