if (!(stuffp = kmalloc(size, GFP_KERNEL))) { 
if (!(stuffp = kzalloc(size, GFP_KERNEL))) { 
static int __init mcdx_init_drive(int drive){	struct s_version version;	struct gendisk *disk;	struct s_drive_stuff *stuffp;	int size = sizeof(*stuffp);	char msg[80];	xtrace(INIT, "init() try drive %d\n", drive);	xtrace(INIT, "kmalloc space for stuffpt's\n");	xtrace(MALLOC, "init() malloc %d bytes\n", size);	if (!(stuffp = kmalloc(size, GFP_KERNEL))) {		xwarn("init() malloc failed\n");		return 1;	}	disk = alloc_disk(1);	if (!disk) {		xwarn("init() malloc failed\n");		kfree(stuffp);		return 1;	}	xtrace(INIT, "init() got %d bytes for drive stuff @ %p\n",	       sizeof(*stuffp), stuffp);	/* set default values */	memset(stuffp, 0, sizeof(*stuffp));	stuffp->present = 0;	/* this should be 0 already */	stuffp->toc = NULL;	/* this should be NULL already */	/* setup our irq and i/o addresses */	stuffp->irq = irq(mcdx_drive_map[drive]);	stuffp->wreg_data = stuffp->rreg_data = port(mcdx_drive_map[drive]);	stuffp->wreg_reset = stuffp->rreg_status = stuffp->wreg_data + 1;	stuffp->wreg_hcon = stuffp->wreg_reset + 1;	stuffp->wreg_chn = stuffp->wreg_hcon + 1;	init_waitqueue_head(&stuffp->busyq);	init_waitqueue_head(&stuffp->lockq);	init_waitqueue_head(&stuffp->sleepq);	/* check if i/o addresses are available */	if (!request_region(stuffp->wreg_data, MCDX_IO_SIZE, "mcdx")) {		xwarn("0x%03x,%d: Init failed. "		      "I/O ports (0x%03x..0x%03x) already in use.\n",		      stuffp->wreg_data, stuffp->irq,		      stuffp->wreg_data,		      stuffp->wreg_data + MCDX_IO_SIZE - 1);		xtrace(MALLOC, "init() free stuffp @ %p\n", stuffp);		kfree(stuffp);		put_disk(disk);		xtrace(INIT, "init() continue at next drive\n");		return 0;	/* next drive */	}	xtrace(INIT, "init() i/o port is available at 0x%03x\n"	       stuffp->wreg_data);	xtrace(INIT, "init() hardware reset\n");	mcdx_reset(stuffp, HARD, 1);	xtrace(INIT, "init() get version\n");	if (-1 == mcdx_requestversion(stuffp, &version, 4)) {		/* failed, next drive */		release_region(stuffp->wreg_data, MCDX_IO_SIZE);		xwarn("%s=0x%03x,%d: Init failed. Can't get version.\n",		      MCDX, stuffp->wreg_data, stuffp->irq);		xtrace(MALLOC, "init() free stuffp @ %p\n", stuffp);		kfree(stuffp);		put_disk(disk);		xtrace(INIT, "init() continue at next drive\n");		return 0;	}	switch (version.code) {	case 'D':		stuffp->readcmd = READ2X;		stuffp->present = DOUBLE | DOOR | MULTI;		break;	case 'F':		stuffp->readcmd = READ1X;		stuffp->present = SINGLE | DOOR | MULTI;		break;	case 'M':		stuffp->readcmd = READ1X;		stuffp->present = SINGLE;		break;	default:		stuffp->present = 0;		break;	}	stuffp->playcmd = READ1X;	if (!stuffp->present) {		release_region(stuffp->wreg_data, MCDX_IO_SIZE);		xwarn("%s=0x%03x,%d: Init failed. No Mitsumi CD-ROM?.\n",		      MCDX, stuffp->wreg_data, stuffp->irq);		kfree(stuffp);		put_disk(disk);		return 0;	/* next drive */	}	xtrace(INIT, "init() register blkdev\n");	if (register_blkdev(MAJOR_NR, "mcdx")) {		release_region(stuffp->wreg_data, MCDX_IO_SIZE);		kfree(stuffp);		put_disk(disk);		return 1;	}	mcdx_queue = blk_init_queue(do_mcdx_request, &mcdx_lock);	if (!mcdx_queue) {		unregister_blkdev(MAJOR_NR, "mcdx");		release_region(stuffp->wreg_data, MCDX_IO_SIZE);		kfree(stuffp);		put_disk(disk);		return 1;	}	xtrace(INIT, "init() subscribe irq and i/o\n");	if (request_irq(stuffp->irq, mcdx_intr, SA_INTERRUPT, "mcdx", stuffp)) {		release_region(stuffp->wreg_data, MCDX_IO_SIZE);		xwarn("%s=0x%03x,%d: Init failed. Can't get irq (%d).\n",		      MCDX, stuffp->wreg_data, stuffp->irq, stuffp->irq);		stuffp->irq = 0;		blk_cleanup_queue(mcdx_queue);		kfree(stuffp);		put_disk(disk);		return 0;	}	xtrace(INIT, "init() get garbage\n");	{		int i;		mcdx_delay(stuffp, HZ / 2);		for (i = 100; i; i--)			(void) inb(stuffp->rreg_status);	}#ifdef WE_KNOW_WHY	/* irq 11 -> channel register */	outb(0x50, stuffp->wreg_chn);#endif	xtrace(INIT, "init() set non dma but irq mode\n");	mcdx_config(stuffp, 1);	stuffp->info.ops = &mcdx_dops;	stuffp->info.speed = 2;	stuffp->info.capacity = 1;	stuffp->info.handle = stuffp;	sprintf(stuffp->info.name, "mcdx%d", drive);	disk->major = MAJOR_NR;	disk->first_minor = drive;	strcpy(disk->disk_name, stuffp->info.name);	disk->fops = &mcdx_bdops;	disk->flags = GENHD_FL_CD;	stuffp->disk = disk;	sprintf(msg, " mcdx: Mitsumi CD-ROM installed at 0x%03x, irq %d."		" (Firmware version %c %x)\n",		stuffp->wreg_data, stuffp->irq, version.code, version.ver);	mcdx_stuffp[drive] = stuffp;	xtrace(INIT, "init() mcdx_stuffp[%d] = %p\n", drive, stuffp);	if (register_cdrom(&stuffp->info) != 0) {		printk("Cannot register Mitsumi CD-ROM!\n");		free_irq(stuffp->irq, NULL);		release_region(stuffp->wreg_data, MCDX_IO_SIZE);		kfree(stuffp);		put_disk(disk);		if (unregister_blkdev(MAJOR_NR, "mcdx") != 0)			xwarn("cleanup() unregister_blkdev() failed\n");		blk_cleanup_queue(mcdx_queue);		return 2;	}	disk->private_data = stuffp;	disk->queue = mcdx_queue;	add_disk(disk);	printk(msg);	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/5c857eeb0c18adaa7432afb519db066a6349687f/mcdx.c/clean/drivers/cdrom/mcdx.c