esp->targets_present |= (1<<SCptr->device->id); 
esp->targets_present |= (1<<scmd_id(SCptr)); 
static int esp_select_complete(struct NCR_ESP *esp, struct ESP_regs *eregs){	Scsi_Cmnd *SCptr = esp->current_SC;	struct esp_device *esp_dev = SCptr->device->hostdata;	int cmd_bytes_sent, fcnt;	fcnt = (esp_read(eregs->esp_fflags) & ESP_FF_FBYTES);	cmd_bytes_sent = esp->dma_bytes_sent(esp, fcnt);	if(esp->dma_invalidate)		esp->dma_invalidate(esp);	/* Let's check to see if a reselect happened	 * while we we're trying to select.  This must	 * be checked first.	 */	if(esp->ireg == (ESP_INTR_RSEL | ESP_INTR_FDONE)) {		esp_reconnect(esp, SCptr);		return esp_do_reconnect(esp, eregs);	}	/* Looks like things worked, we should see a bus service &	 * a function complete interrupt at this point.  Note we	 * are doing a direct comparison because we don't want to	 * be fooled into thinking selection was successful if	 * ESP_INTR_DC is set, see below.	 */	if(esp->ireg == (ESP_INTR_FDONE | ESP_INTR_BSERV)) {		/* target speaks... */		esp->targets_present |= (1<<SCptr->device->id);		/* What if the target ignores the sdtr? */		if(esp->snip)			esp_dev->sync = 1;		/* See how far, if at all, we got in getting		 * the information out to the target.		 */		switch(esp->seqreg) {		default:		case ESP_STEP_ASEL:			/* Arbitration won, target selected, but			 * we are in some phase which is not command			 * phase nor is it message out phase.			 *			 * XXX We've confused the target, obviously.			 * XXX So clear it's state, but we also end			 * XXX up clearing everyone elses.  That isn't			 * XXX so nice.  I'd like to just reset this			 * XXX target, but if I cannot even get it's			 * XXX attention and finish selection to talk			 * XXX to it, there is not much more I can do.			 * XXX If we have a loaded bus we're going to			 * XXX spend the next second or so renegotiating			 * XXX for synchronous transfers.			 */			ESPLOG(("esp%d: STEP_ASEL for tgt %d\n",				esp->esp_id, SCptr->device->id));		case ESP_STEP_SID:			/* Arbitration won, target selected, went			 * to message out phase, sent one message			 * byte, then we stopped.  ATN is asserted			 * on the SCSI bus and the target is still			 * there hanging on.  This is a legal			 * sequence step if we gave the ESP a select			 * and stop command.			 *			 * XXX See above, I could set the borken flag			 * XXX in the device struct and retry the			 * XXX command.  But would that help for			 * XXX tagged capable targets?			 */		case ESP_STEP_NCMD:			/* Arbitration won, target selected, maybe			 * sent the one message byte in message out			 * phase, but we did not go to command phase			 * in the end.  Actually, we could have sent			 * only some of the message bytes if we tried			 * to send out the entire identify and tag			 * message using ESP_CMD_SA3.			 */			cmd_bytes_sent = 0;			break;		case ESP_STEP_PPC:			/* No, not the powerPC pinhead.  Arbitration			 * won, all message bytes sent if we went to			 * message out phase, went to command phase			 * but only part of the command was sent.			 *			 * XXX I've seen this, but usually in conjunction			 * XXX with a gross error which appears to have			 * XXX occurred between the time I told the			 * XXX ESP to arbitrate and when I got the			 * XXX interrupt.  Could I have misloaded the			 * XXX command bytes into the fifo?  Actually,			 * XXX I most likely missed a phase, and therefore			 * XXX went into never never land and didn't even			 * XXX know it.  That was the old driver though.			 * XXX What is even more peculiar is that the ESP			 * XXX showed the proper function complete and			 * XXX bus service bits in the interrupt register.			 */		case ESP_STEP_FINI4:		case ESP_STEP_FINI5:		case ESP_STEP_FINI6:		case ESP_STEP_FINI7:			/* Account for the identify message */			if(SCptr->SCp.phase == in_slct_norm)				cmd_bytes_sent -= 1;		};		esp_cmd(esp, eregs, ESP_CMD_NULL);		/* Be careful, we could really get fucked during synchronous		 * data transfers if we try to flush the fifo now.		 */		if(!fcnt && /* Fifo is empty and... */		   /* either we are not doing synchronous transfers or... */		   (!esp_dev->sync_max_offset ||		    /* We are not going into data in phase. */		    ((esp->sreg & ESP_STAT_PMASK) != ESP_DIP)))			esp_cmd(esp, eregs, ESP_CMD_FLUSH); /* flush is safe */		/* See how far we got if this is not a slow command. */		if(!esp->esp_slowcmd) {			if(cmd_bytes_sent < 0)				cmd_bytes_sent = 0;			if(cmd_bytes_sent != SCptr->cmd_len) {				/* Crapola, mark it as a slowcmd				 * so that we have some chance of				 * keeping the command alive with				 * good luck.				 *				 * XXX Actually, if we didn't send it all				 * XXX this means either we didn't set things				 * XXX up properly (driver bug) or the target				 * XXX or the ESP detected parity on one of				 * XXX the command bytes.  This makes much				 * XXX more sense, and therefore this code				 * XXX should be changed to send out a				 * XXX parity error message or if the status				 * XXX register shows no parity error then				 * XXX just expect the target to bring the				 * XXX bus into message in phase so that it				 * XXX can send us the parity error message.				 * XXX SCSI sucks...				 */				esp->esp_slowcmd = 1;				esp->esp_scmdp = &(SCptr->cmnd[cmd_bytes_sent]);				esp->esp_scmdleft = (SCptr->cmd_len - cmd_bytes_sent);			}		}		/* Now figure out where we went. */		esp_advance_phase(SCptr, in_the_dark);		return esp_do_phase_determine(esp, eregs);	}	/* Did the target even make it? */	if(esp->ireg == ESP_INTR_DC) {		/* wheee... nobody there or they didn't like		 * what we told it to do, clean up.		 */		/* If anyone is off the bus, but working on		 * a command in the background for us, tell		 * the ESP to listen for them.		 */		if(esp->disconnected_SC)			esp_cmd(esp, eregs, ESP_CMD_ESEL);		if(((1<<SCptr->device->id) & esp->targets_present) &&		   esp->seqreg && esp->cur_msgout[0] == EXTENDED_MESSAGE &&		   (SCptr->SCp.phase == in_slct_msg ||		    SCptr->SCp.phase == in_slct_stop)) {			/* shit */			esp->snip = 0;			ESPLOG(("esp%d: Failed synchronous negotiation for target %d "				"lun %d\n", esp->esp_id, SCptr->device->id, SCptr->device->lun));			esp_dev->sync_max_offset = 0;			esp_dev->sync_min_period = 0;			esp_dev->sync = 1; /* so we don't negotiate again */			/* Run the command again, this time though we			 * won't try to negotiate for synchronous transfers.			 *			 * XXX I'd like to do something like send an			 * XXX INITIATOR_ERROR or ABORT message to the			 * XXX target to tell it, "Sorry I confused you,			 * XXX please come back and I will be nicer next			 * XXX time".  But that requires having the target			 * XXX on the bus, and it has dropped BSY on us.			 */			esp->current_SC = NULL;			esp_advance_phase(SCptr, not_issued);			prepend_SC(&esp->issue_SC, SCptr);			esp_exec_cmd(esp);			return do_intr_end;		}		/* Ok, this is normal, this is what we see during boot		 * or whenever when we are scanning the bus for targets.		 * But first make sure that is really what is happening.		 */		if(((1<<SCptr->device->id) & esp->targets_present)) {			ESPLOG(("esp%d: Warning, live target %d not responding to "				"selection.\n", esp->esp_id, SCptr->device->id));			/* This _CAN_ happen.  The SCSI standard states that			 * the target is to _not_ respond to selection if			 * _it_ detects bad parity on the bus for any reason.			 * Therefore, we assume that if we've talked successfully			 * to this target before, bad parity is the problem.			 */			esp_done(esp, (DID_PARITY << 16));		} else {			/* Else, there really isn't anyone there. */			ESPMISC(("esp: selection failure, maybe nobody there?\n"));			ESPMISC(("esp: target %d lun %d\n",				 SCptr->device->id, SCptr->device->lun));			esp_done(esp, (DID_BAD_TARGET << 16));		}		return do_intr_end;	}	ESPLOG(("esp%d: Selection failure.\n", esp->esp_id));	printk("esp%d: Currently -- ", esp->esp_id);	esp_print_ireg(esp->ireg);	printk(" ");	esp_print_statreg(esp->sreg);	printk(" ");	esp_print_seqreg(esp->seqreg);	printk("\n");	printk("esp%d: New -- ", esp->esp_id);	esp->sreg = esp_read(eregs->esp_status);	esp->seqreg = esp_read(eregs->esp_sstep);	esp->ireg = esp_read(eregs->esp_intrpt);	esp_print_ireg(esp->ireg);	printk(" ");	esp_print_statreg(esp->sreg);	printk(" ");	esp_print_seqreg(esp->seqreg);	printk("\n");	ESPLOG(("esp%d: resetting bus\n", esp->esp_id));	return do_reset_bus; /* ugh... */}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/422c0d61d591cbfb70f029e13505fb437e169d68/NCR53C9x.c/clean/drivers/scsi/NCR53C9x.c