int __init ns_init_module(void) 
static int __init ns_init_module(void) 
int __init ns_init_module(void){	struct nand_chip *chip;	struct nandsim *nand;	int retval = -ENOMEM;	if (bus_width != 8 && bus_width != 16) {		NS_ERR("wrong bus width (%d), use only 8 or 16\n", bus_width);		return -EINVAL;	}	/* Allocate and initialize mtd_info, nand_chip and nandsim structures */	nsmtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip)				+ sizeof(struct nandsim), GFP_KERNEL);	if (!nsmtd) {		NS_ERR("unable to allocate core structures.\n");		return -ENOMEM;	}	memset(nsmtd, 0, sizeof(struct mtd_info) + sizeof(struct nand_chip) +			sizeof(struct nandsim));	chip        = (struct nand_chip *)(nsmtd + 1);        nsmtd->priv = (void *)chip;	nand        = (struct nandsim *)(chip + 1);	chip->priv  = (void *)nand;	/*	 * Register simulator's callbacks.	 */	chip->hwcontrol  = ns_hwcontrol;	chip->read_byte  = ns_nand_read_byte;	chip->dev_ready  = ns_device_ready;	chip->write_byte = ns_nand_write_byte;	chip->write_buf  = ns_nand_write_buf;	chip->read_buf   = ns_nand_read_buf;	chip->verify_buf = ns_nand_verify_buf;	chip->write_word = ns_nand_write_word;	chip->read_word  = ns_nand_read_word;	chip->eccmode    = NAND_ECC_SOFT;	chip->options   |= NAND_SKIP_BBTSCAN;	/*	 * Perform minimum nandsim structure initialization to handle	 * the initial ID read command correctly	 */	if (third_id_byte != 0xFF || fourth_id_byte != 0xFF)		nand->geom.idbytes = 4;	else		nand->geom.idbytes = 2;	nand->regs.status = NS_STATUS_OK(nand);	nand->nxstate = STATE_UNKNOWN;	nand->options |= OPT_PAGE256; /* temporary value */	nand->ids[0] = first_id_byte;	nand->ids[1] = second_id_byte;	nand->ids[2] = third_id_byte;	nand->ids[3] = fourth_id_byte;	if (bus_width == 16) {		nand->busw = 16;		chip->options |= NAND_BUSWIDTH_16;	}	if ((retval = nand_scan(nsmtd, 1)) != 0) {		NS_ERR("can't register NAND Simulator\n");		if (retval > 0)			retval = -ENXIO;		goto error;	}	if ((retval = init_nandsim(nsmtd)) != 0) {		NS_ERR("scan_bbt: can't initialize the nandsim structure\n");		goto error;	}	if ((retval = nand_default_bbt(nsmtd)) != 0) {		free_nandsim(nand);		goto error;	}	/* Register NAND as one big partition */	add_mtd_partitions(nsmtd, &nand->part, 1);        return 0;error:	kfree(nsmtd);	return retval;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/2b9175c174b83b8d97db9398efe948fa9092938f/nandsim.c/buggy/drivers/mtd/nand/nandsim.c