target = &data->target[SCpnt->device->id]; 
target = &data->target[scmd_id(SCpnt)]; 
static int nsp32_queuecommand(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)){	nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata;	nsp32_target *target;	nsp32_lunt   *cur_lunt;	int ret;	nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND,		  "enter. target: 0x%x LUN: 0x%x cmnd: 0x%x cmndlen: 0x%x "		  "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x",		  SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], SCpnt->cmd_len,		  SCpnt->use_sg, SCpnt->request_buffer, SCpnt->request_bufflen);	if (data->CurrentSC != NULL) {		nsp32_msg(KERN_ERR, "Currentsc != NULL. Cancel this command request");		data->CurrentSC = NULL;		SCpnt->result   = DID_NO_CONNECT << 16;		done(SCpnt);		return 0;	}	/* check target ID is not same as this initiator ID */	if (SCpnt->device->id == SCpnt->device->host->this_id) {		nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "terget==host???");		SCpnt->result = DID_BAD_TARGET << 16;		done(SCpnt);		return 0;	}	/* check target LUN is allowable value */	if (SCpnt->device->lun >= MAX_LUN) {		nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "no more lun");		SCpnt->result = DID_BAD_TARGET << 16;		done(SCpnt);		return 0;	}	show_command(SCpnt);	SCpnt->scsi_done     = done;	data->CurrentSC      = SCpnt;	SCpnt->SCp.Status    = CHECK_CONDITION;	SCpnt->SCp.Message   = 0;	SCpnt->resid         = SCpnt->request_bufflen;	SCpnt->SCp.ptr		    = (char *) SCpnt->request_buffer;	SCpnt->SCp.this_residual    = SCpnt->request_bufflen;	SCpnt->SCp.buffer	    = NULL;	SCpnt->SCp.buffers_residual = 0;	/* initialize data */	data->msgout_len	= 0;	data->msgin_len		= 0;	cur_lunt		= &(data->lunt[SCpnt->device->id][SCpnt->device->lun]);	cur_lunt->SCpnt		= SCpnt;	cur_lunt->save_datp	= 0;	cur_lunt->msgin03	= FALSE;	data->cur_lunt		= cur_lunt;	data->cur_id		= SCpnt->device->id;	data->cur_lun		= SCpnt->device->lun;	ret = nsp32_setup_sg_table(SCpnt);	if (ret == FALSE) {		nsp32_msg(KERN_ERR, "SGT fail");		SCpnt->result = DID_ERROR << 16;		nsp32_scsi_done(SCpnt);		return 0;	}	/* Build IDENTIFY */	nsp32_build_identify(SCpnt);	/* 	 * If target is the first time to transfer after the reset	 * (target don't have SDTR_DONE and SDTR_INITIATOR), sync	 * message SDTR is needed to do synchronous transfer.	 */	target = &data->target[SCpnt->device->id];	data->cur_target = target;	if (!(target->sync_flag & (SDTR_DONE | SDTR_INITIATOR | SDTR_TARGET))) {		unsigned char period, offset;		if (trans_mode != ASYNC_MODE) {			nsp32_set_max_sync(data, target, &period, &offset);			nsp32_build_sdtr(SCpnt, period, offset);			target->sync_flag |= SDTR_INITIATOR;		} else {			nsp32_set_async(data, target);			target->sync_flag |= SDTR_DONE;		}		nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND,			  "SDTR: entry: %d start_period: 0x%x offset: 0x%x\n",			  target->limit_entry, period, offset);	} else if (target->sync_flag & SDTR_INITIATOR) {		/*		 * It was negotiating SDTR with target, sending from the		 * initiator, but there are no chance to remove this flag.		 * Set async because we don't get proper negotiation.		 */		nsp32_set_async(data, target);		target->sync_flag &= ~SDTR_INITIATOR;		target->sync_flag |= SDTR_DONE;		nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND,			  "SDTR_INITIATOR: fall back to async");	} else if (target->sync_flag & SDTR_TARGET) {		/*		 * It was negotiating SDTR with target, sending from target,		 * but there are no chance to remove this flag.  Set async		 * because we don't get proper negotiation.		 */		nsp32_set_async(data, target);		target->sync_flag &= ~SDTR_TARGET;		target->sync_flag |= SDTR_DONE;		nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND,			  "Unknown SDTR from target is reached, fall back to async.");	}	nsp32_dbg(NSP32_DEBUG_TARGETFLAG,		  "target: %d sync_flag: 0x%x syncreg: 0x%x ackwidth: 0x%x",		  SCpnt->device->id, target->sync_flag, target->syncreg,		  target->ackwidth);	/* Selection */	if (auto_param == 0) {		ret = nsp32_selection_autopara(SCpnt);	} else {		ret = nsp32_selection_autoscsi(SCpnt);	}	if (ret != TRUE) {		nsp32_dbg(NSP32_DEBUG_QUEUECOMMAND, "selection fail");		nsp32_scsi_done(SCpnt);	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/422c0d61d591cbfb70f029e13505fb437e169d68/nsp32.c/clean/drivers/scsi/nsp32.c