print_req_sense("sg_cmd_done", SRpnt); 
scsi_print_req_sense("sg_cmd_done", SRpnt); 
sg_cmd_done(Scsi_Cmnd * SCpnt){	Scsi_Request *SRpnt = NULL;	Sg_device *sdp = NULL;	Sg_fd *sfp;	Sg_request *srp = NULL;	unsigned long iflags;	if (SCpnt && (SRpnt = SCpnt->sc_request))		srp = (Sg_request *) SRpnt->upper_private_data;	if (NULL == srp) {		printk(KERN_ERR "sg_cmd_done: NULL request\n");		if (SRpnt)			scsi_release_request(SRpnt);		return;	}	sfp = srp->parentfp;	if (sfp)		sdp = sfp->parentdp;	if ((NULL == sdp) || sdp->detached) {		printk(KERN_INFO "sg_cmd_done: device detached\n");		scsi_release_request(SRpnt);		return;	}	/* First transfer ownership of data buffers to sg_device object. */	srp->data.k_use_sg = SRpnt->sr_use_sg;	srp->data.sglist_len = SRpnt->sr_sglist_len;	srp->data.bufflen = SRpnt->sr_bufflen;	srp->data.buffer = SRpnt->sr_buffer;	/* now clear out request structure */	SRpnt->sr_use_sg = 0;	SRpnt->sr_sglist_len = 0;	SRpnt->sr_bufflen = 0;	SRpnt->sr_buffer = NULL;	SRpnt->sr_underflow = 0;	SRpnt->sr_request->rq_disk = NULL; /* "sg" _disowns_ request blk */	srp->my_cmdp = NULL;	SCSI_LOG_TIMEOUT(4, printk("sg_cmd_done: %s, pack_id=%d, res=0x%x\n",		sdp->disk->disk_name, srp->header.pack_id, (int) SRpnt->sr_result));	srp->header.resid = SCpnt->resid;	/* N.B. unit of duration changes here from jiffies to millisecs */	srp->header.duration =	    jiffies_to_msecs(jiffies - srp->header.duration);	if (0 != SRpnt->sr_result) {		struct scsi_sense_hdr sshdr;		memcpy(srp->sense_b, SRpnt->sr_sense_buffer,		       sizeof (srp->sense_b));		srp->header.status = 0xff & SRpnt->sr_result;		srp->header.masked_status = status_byte(SRpnt->sr_result);		srp->header.msg_status = msg_byte(SRpnt->sr_result);		srp->header.host_status = host_byte(SRpnt->sr_result);		srp->header.driver_status = driver_byte(SRpnt->sr_result);		if ((sdp->sgdebug > 0) &&		    ((CHECK_CONDITION == srp->header.masked_status) ||		     (COMMAND_TERMINATED == srp->header.masked_status)))			print_req_sense("sg_cmd_done", SRpnt);		/* Following if statement is a patch supplied by Eric Youngdale */		if (driver_byte(SRpnt->sr_result) != 0		    && scsi_command_normalize_sense(SCpnt, &sshdr)		    && !scsi_sense_is_deferred(&sshdr)		    && sshdr.sense_key == UNIT_ATTENTION		    && sdp->device->removable) {			/* Detected possible disc change. Set the bit - this */			/* may be used if there are filesystems using this device */			sdp->device->changed = 1;		}	}	/* Rely on write phase to clean out srp status values, so no "else" */	scsi_release_request(SRpnt);	SRpnt = NULL;	if (sfp->closed) {	/* whoops this fd already released, cleanup */		SCSI_LOG_TIMEOUT(1, printk("sg_cmd_done: already closed, freeing ...\n"));		sg_finish_rem_req(srp);		srp = NULL;		if (NULL == sfp->headrp) {			SCSI_LOG_TIMEOUT(1, printk("sg...bh: already closed, final cleanup\n"));			if (0 == sg_remove_sfp(sdp, sfp)) {	/* device still present */				scsi_device_put(sdp->device);			}			sfp = NULL;		}	} else if (srp && srp->orphan) {		if (sfp->keep_orphan)			srp->sg_io_owned = 0;		else {			sg_finish_rem_req(srp);			srp = NULL;		}	}	if (sfp && srp) {		/* Now wake up any sg_read() that is waiting for this packet. */		kill_fasync(&sfp->async_qp, SIGPOLL, POLL_IN);		write_lock_irqsave(&sfp->rq_list_lock, iflags);		srp->done = 1;		wake_up_interruptible(&sfp->read_wait);		write_unlock_irqrestore(&sfp->rq_list_lock, iflags);	}}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/1409277c4aad2e87ad27b2b8a6901ce78eaf8081/sg.c/buggy/drivers/scsi/sg.c