cp->phys.select.sel_id		= sdev->id; 
cp->phys.select.sel_id		= sdev_id(sdev); 
static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd){	struct scsi_device *sdev = cmd->device;	struct tcb *tp = &np->target[sdev->id];	struct lcb *lp = tp->lp[sdev->lun];	struct ccb *cp;	int	segments;	u_char	idmsg, *msgptr;	u32	msglen;	int	direction;	u32	lastp, goalp;	/*---------------------------------------------	**	**      Some shortcuts ...	**	**---------------------------------------------	*/	if ((sdev->id == np->myaddr	  ) ||		(sdev->id >= MAX_TARGET) ||		(sdev->lun    >= MAX_LUN   )) {		return(DID_BAD_TARGET);	}	/*---------------------------------------------	**	**	Complete the 1st TEST UNIT READY command	**	with error condition if the device is 	**	flagged NOSCAN, in order to speed up 	**	the boot.	**	**---------------------------------------------	*/	if ((cmd->cmnd[0] == 0 || cmd->cmnd[0] == 0x12) && 	    (tp->usrflag & UF_NOSCAN)) {		tp->usrflag &= ~UF_NOSCAN;		return DID_BAD_TARGET;	}	if (DEBUG_FLAGS & DEBUG_TINY) {		PRINT_ADDR(cmd, "CMD=%x ", cmd->cmnd[0]);	}	/*---------------------------------------------------	**	**	Assign a ccb / bind cmd.	**	If resetting, shorten settle_time if necessary	**	in order to avoid spurious timeouts.	**	If resetting or no free ccb,	**	insert cmd into the waiting list.	**	**----------------------------------------------------	*/	if (np->settle_time && cmd->timeout_per_command >= HZ) {		u_long tlimit = jiffies + cmd->timeout_per_command - HZ;		if (time_after(np->settle_time, tlimit))			np->settle_time = tlimit;	}	if (np->settle_time || !(cp=ncr_get_ccb (np, cmd))) {		insert_into_waiting_list(np, cmd);		return(DID_OK);	}	cp->cmd = cmd;	/*----------------------------------------------------	**	**	Build the identify / tag / sdtr message	**	**----------------------------------------------------	*/	idmsg = M_IDENTIFY | sdev->lun;	if (cp ->tag != NO_TAG ||		(cp != np->ccb && np->disc && !(tp->usrflag & UF_NODISC)))		idmsg |= 0x40;	msgptr = cp->scsi_smsg;	msglen = 0;	msgptr[msglen++] = idmsg;	if (cp->tag != NO_TAG) {		char order = np->order;		/*		**	Force ordered tag if necessary to avoid timeouts 		**	and to preserve interactivity.		*/		if (lp && time_after(jiffies, lp->tags_stime)) {			if (lp->tags_smap) {				order = M_ORDERED_TAG;				if ((DEBUG_FLAGS & DEBUG_TAGS)||bootverbose>2){ 					PRINT_ADDR(cmd,						"ordered tag forced.\n");				}			}			lp->tags_stime = jiffies + 3*HZ;			lp->tags_smap = lp->tags_umap;		}		if (order == 0) {			/*			**	Ordered write ops, unordered read ops.			*/			switch (cmd->cmnd[0]) {			case 0x08:  /* READ_SMALL (6) */			case 0x28:  /* READ_BIG  (10) */			case 0xa8:  /* READ_HUGE (12) */				order = M_SIMPLE_TAG;				break;			default:				order = M_ORDERED_TAG;			}		}		msgptr[msglen++] = order;		/*		**	Actual tags are numbered 1,3,5,..2*MAXTAGS+1,		**	since we may have to deal with devices that have 		**	problems with #TAG 0 or too great #TAG numbers.		*/		msgptr[msglen++] = (cp->tag << 1) + 1;	}	/*----------------------------------------------------	**	**	Build the data descriptors	**	**----------------------------------------------------	*/	direction = cmd->sc_data_direction;	if (direction != DMA_NONE) {		segments = ncr_scatter(np, cp, cp->cmd);		if (segments < 0) {			ncr_free_ccb(np, cp);			return(DID_ERROR);		}	}	else {		cp->data_len = 0;		segments = 0;	}	/*---------------------------------------------------	**	**	negotiation required?	**	**	(nego_status is filled by ncr_prepare_nego())	**	**---------------------------------------------------	*/	cp->nego_status = 0;	if ((!tp->widedone || !tp->period) && !tp->nego_cp && lp) {		msglen += ncr_prepare_nego (np, cp, msgptr + msglen);	}	/*----------------------------------------------------	**	**	Determine xfer direction.	**	**----------------------------------------------------	*/	if (!cp->data_len)		direction = DMA_NONE;	/*	**	If data direction is BIDIRECTIONAL, speculate FROM_DEVICE	**	but prepare alternate pointers for TO_DEVICE in case 	**	of our speculation will be just wrong.	**	SCRIPTS will swap values if needed.	*/	switch(direction) {	case DMA_BIDIRECTIONAL:	case DMA_TO_DEVICE:		goalp = NCB_SCRIPT_PHYS (np, data_out2) + 8;		if (segments <= MAX_SCATTERL)			lastp = goalp - 8 - (segments * 16);		else {			lastp = NCB_SCRIPTH_PHYS (np, hdata_out2);			lastp -= (segments - MAX_SCATTERL) * 16;		}		if (direction != DMA_BIDIRECTIONAL)			break;		cp->phys.header.wgoalp	= cpu_to_scr(goalp);		cp->phys.header.wlastp	= cpu_to_scr(lastp);		/* fall through */	case DMA_FROM_DEVICE:		goalp = NCB_SCRIPT_PHYS (np, data_in2) + 8;		if (segments <= MAX_SCATTERL)			lastp = goalp - 8 - (segments * 16);		else {			lastp = NCB_SCRIPTH_PHYS (np, hdata_in2);			lastp -= (segments - MAX_SCATTERL) * 16;		}		break;	default:	case DMA_NONE:		lastp = goalp = NCB_SCRIPT_PHYS (np, no_data);		break;	}	/*	**	Set all pointers values needed by SCRIPTS.	**	If direction is unknown, start at data_io.	*/	cp->phys.header.lastp = cpu_to_scr(lastp);	cp->phys.header.goalp = cpu_to_scr(goalp);	if (direction == DMA_BIDIRECTIONAL)		cp->phys.header.savep = 			cpu_to_scr(NCB_SCRIPTH_PHYS (np, data_io));	else		cp->phys.header.savep= cpu_to_scr(lastp);	/*	**	Save the initial data pointer in order to be able 	**	to redo the command.	*/	cp->startp = cp->phys.header.savep;	/*----------------------------------------------------	**	**	fill in ccb	**	**----------------------------------------------------	**	**	**	physical -> virtual backlink	**	Generic SCSI command	*/	/*	**	Startqueue	*/	cp->start.schedule.l_paddr   = cpu_to_scr(NCB_SCRIPT_PHYS (np, select));	cp->restart.schedule.l_paddr = cpu_to_scr(NCB_SCRIPT_PHYS (np, resel_dsa));	/*	**	select	*/	cp->phys.select.sel_id		= sdev->id;	cp->phys.select.sel_scntl3	= tp->wval;	cp->phys.select.sel_sxfer	= tp->sval;	/*	**	message	*/	cp->phys.smsg.addr		= cpu_to_scr(CCB_PHYS (cp, scsi_smsg));	cp->phys.smsg.size		= cpu_to_scr(msglen);	/*	**	command	*/	memcpy(cp->cdb_buf, cmd->cmnd, min_t(int, cmd->cmd_len, sizeof(cp->cdb_buf)));	cp->phys.cmd.addr		= cpu_to_scr(CCB_PHYS (cp, cdb_buf[0]));	cp->phys.cmd.size		= cpu_to_scr(cmd->cmd_len);	/*	**	status	*/	cp->actualquirks		= 0;	cp->host_status			= cp->nego_status ? HS_NEGOTIATE : HS_BUSY;	cp->scsi_status			= S_ILLEGAL;	cp->parity_status		= 0;	cp->xerr_status			= XE_OK;#if 0	cp->sync_status			= tp->sval;	cp->wide_status			= tp->wval;#endif	/*----------------------------------------------------	**	**	Critical region: start this job.	**	**----------------------------------------------------	*/	/* activate this job.  */	cp->magic		= CCB_MAGIC;	/*	**	insert next CCBs into start queue.	**	2 max at a time is enough to flush the CCB wait queue.	*/	cp->auto_sense = 0;	if (lp)		ncr_start_next_ccb(np, lp, 2);	else		ncr_put_start_queue(np, cp);	/* Command is successfully queued.  */	return DID_OK;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/422c0d61d591cbfb70f029e13505fb437e169d68/ncr53c8xx.c/buggy/drivers/scsi/ncr53c8xx.c