ptr = (struct ScsiInqData *)(srb->virt_map[0] + sg->offset); 
ptr = (struct ScsiInqData *)(page_address(sg->page) + sg->offset); 
static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,		struct ScsiReqBlk *srb){	u8 tempcnt, status;	struct scsi_cmnd *cmd = srb->cmd;	struct ScsiInqData *ptr;	enum dma_data_direction dir = cmd->sc_data_direction;	if (cmd->use_sg) {		struct scatterlist* sg = (struct scatterlist *)cmd->request_buffer;		ptr = (struct ScsiInqData *)(srb->virt_map[0] + sg->offset);	} else {		ptr = (struct ScsiInqData *)(cmd->request_buffer);	}	dprintkdbg(DBG_1, "srb_done: (pid#%li) <%02i-%i>\n", srb->cmd->pid,		srb->cmd->device->id, srb->cmd->device->lun);	dprintkdbg(DBG_SG, "srb_done: srb=%p sg=%i(%i/%i) buf=%p addr=%p\n",		srb, cmd->use_sg, srb->sg_index, srb->sg_count,		cmd->request_buffer, ptr);	status = srb->target_status;	if (srb->flag & AUTO_REQSENSE) {		dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE1\n");		pci_unmap_srb_sense(acb, srb);		/*		 ** target status..........................		 */		srb->flag &= ~AUTO_REQSENSE;		srb->adapter_status = 0;		srb->target_status = CHECK_CONDITION << 1;		if (debug_enabled(DBG_1)) {			switch (cmd->sense_buffer[2] & 0x0f) {			case NOT_READY:				dprintkl(KERN_DEBUG,				     "ReqSense: NOT_READY cmnd=0x%02x <%02i-%i> stat=%i scan=%i ",				     cmd->cmnd[0], dcb->target_id,				     dcb->target_lun, status, acb->scan_devices);				break;			case UNIT_ATTENTION:				dprintkl(KERN_DEBUG,				     "ReqSense: UNIT_ATTENTION cmnd=0x%02x <%02i-%i> stat=%i scan=%i ",				     cmd->cmnd[0], dcb->target_id,				     dcb->target_lun, status, acb->scan_devices);				break;			case ILLEGAL_REQUEST:				dprintkl(KERN_DEBUG,				     "ReqSense: ILLEGAL_REQUEST cmnd=0x%02x <%02i-%i> stat=%i scan=%i ",				     cmd->cmnd[0], dcb->target_id,				     dcb->target_lun, status, acb->scan_devices);				break;			case MEDIUM_ERROR:				dprintkl(KERN_DEBUG,				     "ReqSense: MEDIUM_ERROR cmnd=0x%02x <%02i-%i> stat=%i scan=%i ",				     cmd->cmnd[0], dcb->target_id,				     dcb->target_lun, status, acb->scan_devices);				break;			case HARDWARE_ERROR:				dprintkl(KERN_DEBUG,				     "ReqSense: HARDWARE_ERROR cmnd=0x%02x <%02i-%i> stat=%i scan=%i ",				     cmd->cmnd[0], dcb->target_id,				     dcb->target_lun, status, acb->scan_devices);				break;			}			if (cmd->sense_buffer[7] >= 6)				printk("sense=0x%02x ASC=0x%02x ASCQ=0x%02x "					"(0x%08x 0x%08x)\n",					cmd->sense_buffer[2], cmd->sense_buffer[12],					cmd->sense_buffer[13],					*((unsigned int *)(cmd->sense_buffer + 3)),					*((unsigned int *)(cmd->sense_buffer + 8)));			else				printk("sense=0x%02x No ASC/ASCQ (0x%08x)\n",					cmd->sense_buffer[2],					*((unsigned int *)(cmd->sense_buffer + 3)));		}		if (status == (CHECK_CONDITION << 1)) {			cmd->result = DID_BAD_TARGET << 16;			goto ckc_e;		}		dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE2\n");		if (srb->total_xfer_length		    && srb->total_xfer_length >= cmd->underflow)			cmd->result =			    MK_RES_LNX(DRIVER_SENSE, DID_OK,				       srb->end_message, CHECK_CONDITION);		/*SET_RES_DID(cmd->result,DID_OK) */		else			cmd->result =			    MK_RES_LNX(DRIVER_SENSE, DID_OK,				       srb->end_message, CHECK_CONDITION);		goto ckc_e;	}/*************************************************************/	if (status) {		/*		 * target status..........................		 */		if (status_byte(status) == CHECK_CONDITION) {			request_sense(acb, dcb, srb);			return;		} else if (status_byte(status) == QUEUE_FULL) {			tempcnt = (u8)list_size(&dcb->srb_going_list);			dprintkl(KERN_INFO, "QUEUE_FULL for dev <%02i-%i> with %i cmnds\n",			     dcb->target_id, dcb->target_lun, tempcnt);			if (tempcnt > 1)				tempcnt--;			dcb->max_command = tempcnt;			free_tag(dcb, srb);			srb_going_to_waiting_move(dcb, srb);			waiting_set_timer(acb, HZ / 20);			srb->adapter_status = 0;			srb->target_status = 0;			return;		} else if (status == SCSI_STAT_SEL_TIMEOUT) {			srb->adapter_status = H_SEL_TIMEOUT;			srb->target_status = 0;			cmd->result = DID_NO_CONNECT << 16;		} else {			srb->adapter_status = 0;			SET_RES_DID(cmd->result, DID_ERROR);			SET_RES_MSG(cmd->result, srb->end_message);			SET_RES_TARGET(cmd->result, status);		}	} else {		/*		 ** process initiator status..........................		 */		status = srb->adapter_status;		if (status & H_OVER_UNDER_RUN) {			srb->target_status = 0;			SET_RES_DID(cmd->result, DID_OK);			SET_RES_MSG(cmd->result, srb->end_message);		} else if (srb->status & PARITY_ERROR) {			SET_RES_DID(cmd->result, DID_PARITY);			SET_RES_MSG(cmd->result, srb->end_message);		} else {	/* No error */			srb->adapter_status = 0;			srb->target_status = 0;			SET_RES_DID(cmd->result, DID_OK);		}	}	if (dir != PCI_DMA_NONE) {		if (cmd->use_sg)			pci_dma_sync_sg_for_cpu(acb->dev,					(struct scatterlist *)cmd->					request_buffer, cmd->use_sg, dir);		else if (cmd->request_buffer)			pci_dma_sync_single_for_cpu(acb->dev,					    srb->segment_x[0].address,					    cmd->request_bufflen, dir);	}	if ((cmd->result & RES_DID) == 0 && cmd->cmnd[0] == INQUIRY	    && cmd->cmnd[2] == 0 && cmd->request_bufflen >= 8	    && dir != PCI_DMA_NONE && ptr && (ptr->Vers & 0x07) >= 2)		dcb->inquiry7 = ptr->Flags;/* Check Error Conditions */      ckc_e:	/*if( srb->cmd->cmnd[0] == INQUIRY && */	/*  (host_byte(cmd->result) == DID_OK || status_byte(cmd->result) & CHECK_CONDITION) ) */	if (cmd->cmnd[0] == INQUIRY && (cmd->result == (DID_OK << 16)					 || status_byte(cmd->							result) &					 CHECK_CONDITION)) {		if (!dcb->init_tcq_flag) {			add_dev(acb, dcb, ptr);			dcb->init_tcq_flag = 1;		}	}	/* Here is the info for Doug Gilbert's sg3 ... */	cmd->resid = srb->total_xfer_length;	/* This may be interpreted by sb. or not ... */	cmd->SCp.this_residual = srb->total_xfer_length;	cmd->SCp.buffers_residual = 0;	if (debug_enabled(DBG_KG)) {		if (srb->total_xfer_length)			dprintkdbg(DBG_KG, "srb_done: (pid#%li) <%02i-%i> "				"cmnd=0x%02x Missed %i bytes\n",				cmd->pid, cmd->device->id, cmd->device->lun,				cmd->cmnd[0], srb->total_xfer_length);	}	srb_going_remove(dcb, srb);	/* Add to free list */	if (srb == acb->tmp_srb)		dprintkl(KERN_ERR, "srb_done: ERROR! Completed cmd with tmp_srb\n");	else {		dprintkdbg(DBG_0, "srb_done: (pid#%li) done result=0x%08x\n",			cmd->pid, cmd->result);		srb_free_insert(acb, srb);	}	pci_unmap_srb(acb, srb);	cmd->scsi_done(cmd);	waiting_process_next(acb);}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/b4b08e581fac8e0ba9ae348bdc13246c9798c99e/dc395x.c/buggy/drivers/scsi/dc395x.c