set_current_state(TASK_INTERRUPTIBLE); schedule_timeout((HZ+17)*40/18); 
schedule_timeout_interruptible((HZ+17)*40/18); 
static int __init sony535_init(void){	struct s535_sony_drive_config drive_config;	Byte cmd_buff[3];	Byte ret_buff[2];	Byte status[2];	unsigned long snap;	int  got_result = 0;	int  tmp_irq;	int  i;	int err;	/* Setting the base I/O address to 0 will disable it. */	if ((sony535_cd_base_io == 0xffff)||(sony535_cd_base_io == 0))		return 0;	/* Set up all the register locations */	result_reg = sony535_cd_base_io;	command_reg = sony535_cd_base_io;	data_reg = sony535_cd_base_io + 1;	read_status_reg = sony535_cd_base_io + 2;	select_unit_reg = sony535_cd_base_io + 3;#ifndef USE_IRQ	sony535_irq_used = 0;	/* polling only until this is ready... */#endif	/* we need to poll until things get initialized */	tmp_irq = sony535_irq_used;	sony535_irq_used = 0;#if DEBUG > 0	printk(KERN_INFO CDU535_MESSAGE_NAME ": probing base address %03X\n",			sony535_cd_base_io);#endif	/* look for the CD-ROM, follows the procedure in the DOS driver */	inb(select_unit_reg);	/* wait for 40 18 Hz ticks (reverse-engineered from DOS driver) */	set_current_state(TASK_INTERRUPTIBLE);	schedule_timeout((HZ+17)*40/18);	inb(result_reg);	outb(0, read_status_reg);	/* does a reset? */	snap = jiffies;	while (jiffies-snap < SONY_JIFFIES_TIMEOUT) {		select_unit(0);		if (inb(result_reg) != 0xff) {			got_result = 1;			break;		}		sony_sleep();	}	if (!got_result || check_drive_status() == TIME_OUT)		goto Enodev;	/* CD-ROM drive responded --  get the drive configuration */	cmd_buff[0] = SONY535_INQUIRY;	if (do_sony_cmd(cmd_buff, 1, status, (Byte *)&drive_config, 28, 1) != 0)		goto Enodev;	/* was able to get the configuration,	 * set drive mode as rest of init	 */#if DEBUG > 0	/* 0x50 == CADDY_NOT_INSERTED | NOT_SPINNING */	if ( (status[0] & 0x7f) != 0 && (status[0] & 0x7f) != 0x50 )		printk(CDU535_MESSAGE_NAME				"Inquiry command returned status = 0x%x\n", status[0]);#endif	/* now ready to use interrupts, if available */	sony535_irq_used = tmp_irq;	/* A negative sony535_irq_used will attempt an autoirq. */	if (sony535_irq_used < 0) {		unsigned long irq_mask, delay;		irq_mask = probe_irq_on();		enable_interrupts();		outb(0, read_status_reg);	/* does a reset? */		delay = jiffies + HZ/10;		while (time_before(jiffies, delay)) ;		sony535_irq_used = probe_irq_off(irq_mask);		disable_interrupts();	}	if (sony535_irq_used > 0) {	    if (request_irq(sony535_irq_used, cdu535_interrupt,						SA_INTERRUPT, CDU535_HANDLE, NULL)) {			printk("Unable to grab IRQ%d for the " CDU535_MESSAGE_NAME					" driver; polling instead.\n", sony535_irq_used);			sony535_irq_used = 0;		}	}	cmd_buff[0] = SONY535_SET_DRIVE_MODE;	cmd_buff[1] = 0x0;	/* default audio */	if (do_sony_cmd(cmd_buff, 2, status, ret_buff, 1, 1) != 0)		goto Enodev_irq;	/* set the drive mode successful, we are set! */	sony_buffer_size = SONY535_BUFFER_SIZE;	sony_buffer_sectors = sony_buffer_size / CDU535_BLOCK_SIZE;	printk(KERN_INFO CDU535_MESSAGE_NAME " I/F CDROM : %8.8s %16.16s %4.4s",		   drive_config.vendor_id,		   drive_config.product_id,		   drive_config.product_rev_level);	printk("  base address %03X, ", sony535_cd_base_io);	if (tmp_irq > 0)		printk("IRQ%d, ", tmp_irq);	printk("using %d byte buffer\n", sony_buffer_size);	if (register_blkdev(MAJOR_NR, CDU535_HANDLE)) {		err = -EIO;		goto out1;	}	sonycd535_queue = blk_init_queue(do_cdu535_request, &sonycd535_lock);	if (!sonycd535_queue) {		err = -ENOMEM;		goto out1a;	}	blk_queue_hardsect_size(sonycd535_queue, CDU535_BLOCK_SIZE);	sony_toc = kmalloc(sizeof(struct s535_sony_toc), GFP_KERNEL);	err = -ENOMEM;	if (!sony_toc)		goto out2;	last_sony_subcode = kmalloc(sizeof(struct s535_sony_subcode), GFP_KERNEL);	if (!last_sony_subcode)		goto out3;	sony_buffer = kmalloc(sizeof(Byte *) * sony_buffer_sectors, GFP_KERNEL);	if (!sony_buffer)		goto out4;	for (i = 0; i < sony_buffer_sectors; i++) {		sony_buffer[i] = kmalloc(CDU535_BLOCK_SIZE, GFP_KERNEL);		if (!sony_buffer[i]) {			while (--i>=0)				kfree(sony_buffer[i]);			goto out5;		}	}	initialized = 1;	cdu_disk = alloc_disk(1);	if (!cdu_disk)		goto out6;	cdu_disk->major = MAJOR_NR;	cdu_disk->first_minor = 0;	cdu_disk->fops = &cdu_fops;	sprintf(cdu_disk->disk_name, "cdu");	sprintf(cdu_disk->devfs_name, "cdu535");	if (!request_region(sony535_cd_base_io, 4, CDU535_HANDLE)) {		printk(KERN_WARNING"sonycd535: Unable to request region 0x%x\n",			sony535_cd_base_io);		goto out7;	}	cdu_disk->queue = sonycd535_queue;	add_disk(cdu_disk);	return 0;out7:	put_disk(cdu_disk);out6:	for (i = 0; i < sony_buffer_sectors; i++)		kfree(sony_buffer[i]);out5:	kfree(sony_buffer);out4:	kfree(last_sony_subcode);out3:	kfree(sony_toc);out2:	blk_cleanup_queue(sonycd535_queue);out1a:	unregister_blkdev(MAJOR_NR, CDU535_HANDLE);out1:	if (sony535_irq_used)		free_irq(sony535_irq_used, NULL);	return err;Enodev_irq:	if (sony535_irq_used)		free_irq(sony535_irq_used, NULL);Enodev:	printk("Did not find a " CDU535_MESSAGE_NAME " drive\n");	return -EIO;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/2ddee1b7a732dc96d479afaa7d0a26aa53990089/sonycd535.c/clean/drivers/cdrom/sonycd535.c