SRpnt->sr_data_direction = SCSI_DATA_READ; 
SRpnt->sr_data_direction = DMA_FROM_DEVICE; 
sg_common_write(Sg_fd * sfp, Sg_request * srp,		unsigned char *cmnd, int timeout, int blocking){	int k;	Scsi_Request *SRpnt;	Sg_device *sdp = sfp->parentdp;	sg_io_hdr_t *hp = &srp->header;	request_queue_t *q;	srp->data.cmd_opcode = cmnd[0];	/* hold opcode of command */	hp->status = 0;	hp->masked_status = 0;	hp->msg_status = 0;	hp->info = 0;	hp->host_status = 0;	hp->driver_status = 0;	hp->resid = 0;	SCSI_LOG_TIMEOUT(4, printk("sg_common_write:  scsi opcode=0x%02x, cmd_size=%d\n",			  (int) cmnd[0], (int) hp->cmd_len));	if ((k = sg_start_req(srp))) {		SCSI_LOG_TIMEOUT(1, printk("sg_write: start_req err=%d\n", k));		sg_finish_rem_req(srp);		return k;	/* probably out of space --> ENOMEM */	}	if ((k = sg_write_xfer(srp))) {		SCSI_LOG_TIMEOUT(1, printk("sg_write: write_xfer, bad address\n"));		sg_finish_rem_req(srp);		return k;	}	if (sdp->detached) {		sg_finish_rem_req(srp);		return -ENODEV;	}	SRpnt = scsi_allocate_request(sdp->device, GFP_ATOMIC);	if (SRpnt == NULL) {		SCSI_LOG_TIMEOUT(1, printk("sg_write: no mem\n"));		sg_finish_rem_req(srp);		return -ENOMEM;	}	srp->my_cmdp = SRpnt;	q = SRpnt->sr_device->request_queue;	SRpnt->sr_request->rq_disk = sdp->disk;	SRpnt->sr_sense_buffer[0] = 0;	SRpnt->sr_cmd_len = hp->cmd_len;	SRpnt->sr_use_sg = srp->data.k_use_sg;	SRpnt->sr_sglist_len = srp->data.sglist_len;	SRpnt->sr_bufflen = srp->data.bufflen;	SRpnt->sr_underflow = 0;	SRpnt->sr_buffer = srp->data.buffer;	switch (hp->dxfer_direction) {	case SG_DXFER_TO_FROM_DEV:	case SG_DXFER_FROM_DEV:		SRpnt->sr_data_direction = SCSI_DATA_READ;		break;	case SG_DXFER_TO_DEV:		SRpnt->sr_data_direction = SCSI_DATA_WRITE;		break;	case SG_DXFER_UNKNOWN:		SRpnt->sr_data_direction = SCSI_DATA_UNKNOWN;		break;	default:		SRpnt->sr_data_direction = SCSI_DATA_NONE;		break;	}	SRpnt->upper_private_data = srp;	srp->data.k_use_sg = 0;	srp->data.sglist_len = 0;	srp->data.bufflen = 0;	srp->data.buffer = NULL;	hp->duration = jiffies_to_msecs(jiffies);/* Now send everything of to mid-level. The next time we hear about this   packet is when sg_cmd_done() is called (i.e. a callback). */	scsi_do_req(SRpnt, (void *) cmnd,		    (void *) SRpnt->sr_buffer, hp->dxfer_len,		    sg_cmd_done, timeout, SG_DEFAULT_RETRIES);	/* dxfer_len overwrites SRpnt->sr_bufflen, hence need for b_malloc_len */	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/be7db055dd7261522557046370f49160728e3847/sg.c/clean/drivers/scsi/sg.c