unsigned long spintime_value = 0; 
unsigned long spintime_expire = 0; 
sd_spinup_disk(struct scsi_disk *sdkp, char *diskname,	       struct scsi_request *SRpnt, unsigned char *buffer) {	unsigned char cmd[10];	unsigned long spintime_value = 0;	int retries, spintime;	unsigned int the_result;	struct scsi_sense_hdr sshdr;	int sense_valid = 0;	spintime = 0;	/* Spin up drives, as required.  Only do this at boot time */	/* Spinup needs to be done for module loads too. */	do {		retries = 0;		do {			cmd[0] = TEST_UNIT_READY;			memset((void *) &cmd[1], 0, 9);			SRpnt->sr_cmd_len = 0;			memset(SRpnt->sr_sense_buffer, 0,			       SCSI_SENSE_BUFFERSIZE);			SRpnt->sr_data_direction = DMA_NONE;			scsi_wait_req (SRpnt, (void *) cmd, (void *) buffer,				       0/*512*/, SD_TIMEOUT, SD_MAX_RETRIES);			the_result = SRpnt->sr_result;			if (the_result)				sense_valid = scsi_request_normalize_sense(							SRpnt, &sshdr);			retries++;		} while (retries < 3 && 			 (!scsi_status_is_good(the_result) ||			  ((driver_byte(the_result) & DRIVER_SENSE) &&			  sense_valid && sshdr.sense_key == UNIT_ATTENTION)));		/*		 * If the drive has indicated to us that it doesn't have		 * any media in it, don't bother with any of the rest of		 * this crap.		 */		if (media_not_present(sdkp, SRpnt))			return;		if ((driver_byte(the_result) & DRIVER_SENSE) == 0) {			/* no sense, TUR either succeeded or failed			 * with a status error */			if(!spintime && !scsi_status_is_good(the_result))				printk(KERN_NOTICE "%s: Unit Not Ready, "				       "error = 0x%x\n", diskname, the_result);			break;		}							/*		 * The device does not want the automatic start to be issued.		 */		if (sdkp->device->no_start_on_add) {			break;		}		/*		 * If manual intervention is required, or this is an		 * absent USB storage device, a spinup is meaningless.		 */		if (sense_valid &&		    sshdr.sense_key == NOT_READY &&		    sshdr.asc == 4 && sshdr.ascq == 3) {			break;		/* manual intervention required */		/*		 * Issue command to spin up drive when not ready		 */		} else if (sense_valid && sshdr.sense_key == NOT_READY) {			if (!spintime) {				printk(KERN_NOTICE "%s: Spinning up disk...",				       diskname);				cmd[0] = START_STOP;				cmd[1] = 1;	/* Return immediately */				memset((void *) &cmd[2], 0, 8);				cmd[4] = 1;	/* Start spin cycle */				SRpnt->sr_cmd_len = 0;				memset(SRpnt->sr_sense_buffer, 0,					SCSI_SENSE_BUFFERSIZE);				SRpnt->sr_data_direction = DMA_NONE;				scsi_wait_req(SRpnt, (void *)cmd, 					      (void *) buffer, 0/*512*/, 					      SD_TIMEOUT, SD_MAX_RETRIES);				spintime_value = jiffies;			}			spintime = 1;			/* Wait 1 second for next try */			msleep(1000);			printk(".");		} else {			/* we don't understand the sense code, so it's			 * probably pointless to loop */			if(!spintime) {				printk(KERN_NOTICE "%s: Unit Not Ready, "					"sense:\n", diskname);				scsi_print_req_sense("", SRpnt);			}			break;		}					} while (spintime &&		 time_after(spintime_value + 100 * HZ, jiffies));	if (spintime) {		if (scsi_status_is_good(the_result))			printk("ready\n");		else			printk("not responding...\n");	}}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/4451e472627881e3e2240b224f127c99be500f91/sd.c/buggy/drivers/scsi/sd.c