if (fdomain_select( current_SC->device->id )) { 
if (fdomain_select( scmd_id(current_SC) )) { 
static irqreturn_t do_fdomain_16x0_intr(int irq, void *dev_id,					struct pt_regs * regs ){   unsigned long flags;   int      status;   int      done = 0;   unsigned data_count;				/* The fdomain_16x0_intr is only called via				   the interrupt handler.  The goal of the				   sti() here is to allow other				   interruptions while this routine is				   running. */   /* Check for other IRQ sources */   if ((inb(port_base + TMC_Status) & 0x01) == 0)   	return IRQ_NONE;   /* It is our IRQ */   	   outb(0x00, port_base + Interrupt_Cntl);   /* We usually have one spurious interrupt after each command.  Ignore it. */   if (!in_command || !current_SC) {	/* Spurious interrupt */#if EVERY_ACCESS      printk( "Spurious interrupt, in_command = %d, current_SC = %x\n",	      in_command, current_SC );#endif      return IRQ_NONE;   }   /* Abort calls my_done, so we do nothing here. */   if (current_SC->SCp.phase & aborted) {#if DEBUG_ABORT      printk( "scsi: <fdomain> Interrupt after abort, ignoring\n" );#endif      /*      return IRQ_HANDLED; */   }#if DEBUG_RACE   ++in_interrupt_flag;#endif   if (current_SC->SCp.phase & in_arbitration) {      status = inb(port_base + TMC_Status);        /* Read adapter status */      if (!(status & 0x02)) {#if EVERY_ACCESS	 printk( " AFAIL " );#endif         spin_lock_irqsave(current_SC->device->host->host_lock, flags);	 my_done( DID_BUS_BUSY << 16 );         spin_unlock_irqrestore(current_SC->device->host->host_lock, flags);	 return IRQ_HANDLED;      }      current_SC->SCp.phase = in_selection;            outb(0x40 | FIFO_COUNT, port_base + Interrupt_Cntl);      outb(0x82, port_base + SCSI_Cntl); /* Bus Enable + Select */      outb(adapter_mask | (1 << current_SC->device->id), port_base + SCSI_Data_NoACK);            /* Stop arbitration and enable parity */      outb(0x10 | PARITY_MASK, port_base + TMC_Cntl);#if DEBUG_RACE      in_interrupt_flag = 0;#endif      return IRQ_HANDLED;   } else if (current_SC->SCp.phase & in_selection) {      status = inb(port_base + SCSI_Status);      if (!(status & 0x01)) {	 /* Try again, for slow devices */	 if (fdomain_select( current_SC->device->id )) {#if EVERY_ACCESS	    printk( " SFAIL " );#endif            spin_lock_irqsave(current_SC->device->host->host_lock, flags);	    my_done( DID_NO_CONNECT << 16 );            spin_unlock_irqrestore(current_SC->device->host->host_lock, flags);	    return IRQ_HANDLED;	 } else {#if EVERY_ACCESS	    printk( " AltSel " );#endif	    /* Stop arbitration and enable parity */	    outb(0x10 | PARITY_MASK, port_base + TMC_Cntl);	 }      }      current_SC->SCp.phase = in_other;      outb(0x90 | FIFO_COUNT, port_base + Interrupt_Cntl);      outb(0x80, port_base + SCSI_Cntl);#if DEBUG_RACE      in_interrupt_flag = 0;#endif      return IRQ_HANDLED;   }      /* current_SC->SCp.phase == in_other: this is the body of the routine */      status = inb(port_base + SCSI_Status);      if (status & 0x10) {	/* REQ */            switch (status & 0x0e) {             case 0x08:		/* COMMAND OUT */	 outb(current_SC->cmnd[current_SC->SCp.sent_command++],	      port_base + Write_SCSI_Data);#if EVERY_ACCESS	 printk( "CMD = %x,",		 current_SC->cmnd[ current_SC->SCp.sent_command - 1] );#endif	 break;      case 0x00:		/* DATA OUT -- tmc18c50/tmc18c30 only */	 if (chip != tmc1800 && !current_SC->SCp.have_data_in) {	    current_SC->SCp.have_data_in = -1;	    outb(0xd0 | PARITY_MASK, port_base + TMC_Cntl);	 }	 break;      case 0x04:		/* DATA IN -- tmc18c50/tmc18c30 only */	 if (chip != tmc1800 && !current_SC->SCp.have_data_in) {	    current_SC->SCp.have_data_in = 1;	    outb(0x90 | PARITY_MASK, port_base + TMC_Cntl);	 }	 break;      case 0x0c:		/* STATUS IN */	 current_SC->SCp.Status = inb(port_base + Read_SCSI_Data);#if EVERY_ACCESS	 printk( "Status = %x, ", current_SC->SCp.Status );#endif#if ERRORS_ONLY	 if (current_SC->SCp.Status	     && current_SC->SCp.Status != 2	     && current_SC->SCp.Status != 8) {	    printk( "scsi: <fdomain> target = %d, command = %x, status = %x\n",		    current_SC->device->id,		    current_SC->cmnd[0],		    current_SC->SCp.Status );	 }#endif	       break;      case 0x0a:		/* MESSAGE OUT */	 outb(MESSAGE_REJECT, port_base + Write_SCSI_Data); /* Reject */	 break;      case 0x0e:		/* MESSAGE IN */	 current_SC->SCp.Message = inb(port_base + Read_SCSI_Data);#if EVERY_ACCESS	 printk( "Message = %x, ", current_SC->SCp.Message );#endif	 if (!current_SC->SCp.Message) ++done;#if DEBUG_MESSAGES || EVERY_ACCESS	 if (current_SC->SCp.Message) {	    printk( "scsi: <fdomain> message = %x\n",		    current_SC->SCp.Message );	 }#endif	 break;      }   }   if (chip == tmc1800 && !current_SC->SCp.have_data_in       && (current_SC->SCp.sent_command >= current_SC->cmd_len)) {            if(current_SC->sc_data_direction == DMA_TO_DEVICE)      {	 current_SC->SCp.have_data_in = -1;	 outb(0xd0 | PARITY_MASK, port_base + TMC_Cntl);      }      else      {	 current_SC->SCp.have_data_in = 1;	 outb(0x90 | PARITY_MASK, port_base + TMC_Cntl);      }   }   if (current_SC->SCp.have_data_in == -1) { /* DATA OUT */      while ((data_count = FIFO_Size - inw(port_base + FIFO_Data_Count)) > 512) {#if EVERY_ACCESS	 printk( "DC=%d, ", data_count ) ;#endif	 if (data_count > current_SC->SCp.this_residual)	       data_count = current_SC->SCp.this_residual;	 if (data_count > 0) {#if EVERY_ACCESS	    printk( "%d OUT, ", data_count );#endif	    if (data_count == 1) {	       outb(*current_SC->SCp.ptr++, port_base + Write_FIFO);	       --current_SC->SCp.this_residual;	    } else {	       data_count >>= 1;	       outsw(port_base + Write_FIFO, current_SC->SCp.ptr, data_count);	       current_SC->SCp.ptr += 2 * data_count;	       current_SC->SCp.this_residual -= 2 * data_count;	    }	 }	 if (!current_SC->SCp.this_residual) {	    if (current_SC->SCp.buffers_residual) {	       --current_SC->SCp.buffers_residual;	       ++current_SC->SCp.buffer;	       current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset;	       current_SC->SCp.this_residual = current_SC->SCp.buffer->length;	    } else		  break;	 }      }   }      if (current_SC->SCp.have_data_in == 1) { /* DATA IN */      while ((data_count = inw(port_base + FIFO_Data_Count)) > 0) {#if EVERY_ACCESS	 printk( "DC=%d, ", data_count );#endif	 if (data_count > current_SC->SCp.this_residual)	       data_count = current_SC->SCp.this_residual;	 if (data_count) {#if EVERY_ACCESS	    printk( "%d IN, ", data_count );#endif	    if (data_count == 1) {	       *current_SC->SCp.ptr++ = inb(port_base + Read_FIFO);	       --current_SC->SCp.this_residual;	    } else {	       data_count >>= 1; /* Number of words */	       insw(port_base + Read_FIFO, current_SC->SCp.ptr, data_count);	       current_SC->SCp.ptr += 2 * data_count;	       current_SC->SCp.this_residual -= 2 * data_count;	    }	 }	 if (!current_SC->SCp.this_residual	     && current_SC->SCp.buffers_residual) {	    --current_SC->SCp.buffers_residual;	    ++current_SC->SCp.buffer;	    current_SC->SCp.ptr = page_address(current_SC->SCp.buffer->page) + current_SC->SCp.buffer->offset;	    current_SC->SCp.this_residual = current_SC->SCp.buffer->length;	 }      }   }      if (done) {#if EVERY_ACCESS      printk( " ** IN DONE %d ** ", current_SC->SCp.have_data_in );#endif#if ERRORS_ONLY      if (current_SC->cmnd[0] == REQUEST_SENSE && !current_SC->SCp.Status) {	 if ((unsigned char)(*((char *)current_SC->request_buffer+2)) & 0x0f) {	    unsigned char key;	    unsigned char code;	    unsigned char qualifier;	    key = (unsigned char)(*((char *)current_SC->request_buffer + 2))		  & 0x0f;	    code = (unsigned char)(*((char *)current_SC->request_buffer + 12));	    qualifier = (unsigned char)(*((char *)current_SC->request_buffer					  + 13));	    if (key != UNIT_ATTENTION		&& !(key == NOT_READY		     && code == 0x04		     && (!qualifier || qualifier == 0x02 || qualifier == 0x01))		&& !(key == ILLEGAL_REQUEST && (code == 0x25						|| code == 0x24						|| !code)))		  		  printk( "scsi: <fdomain> REQUEST SENSE"			  " Key = %x, Code = %x, Qualifier = %x\n",			  key, code, qualifier );	 }      }#endif#if EVERY_ACCESS      printk( "BEFORE MY_DONE. . ." );#endif      spin_lock_irqsave(current_SC->device->host->host_lock, flags);      my_done( (current_SC->SCp.Status & 0xff)	       | ((current_SC->SCp.Message & 0xff) << 8) | (DID_OK << 16) );      spin_unlock_irqrestore(current_SC->device->host->host_lock, flags);#if EVERY_ACCESS      printk( "RETURNING.\n" );#endif         } else {      if (current_SC->SCp.phase & disconnect) {	 outb(0xd0 | FIFO_COUNT, port_base + Interrupt_Cntl);	 outb(0x00, port_base + SCSI_Cntl);      } else {	 outb(0x90 | FIFO_COUNT, port_base + Interrupt_Cntl);      }   }#if DEBUG_RACE   in_interrupt_flag = 0;#endif   return IRQ_HANDLED;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/422c0d61d591cbfb70f029e13505fb437e169d68/fdomain.c/clean/drivers/scsi/fdomain.c