linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.13-rc5] reduce whitespace bloat in drivers/scsi/cpqfcTScontrol.c
@ 2005-08-05 10:02 Rolf Eike Beer
  2005-08-09 16:06 ` [PATCH 2.6.13-rc5] rewrite drivers/scsi/cpqfcTScontrol.c::CpqTsGetSFQEntry Rolf Eike Beer
  0 siblings, 1 reply; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-05 10:02 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds

This file is a ugly mess. But before anyone can go and do some real work it 
has to be cleaned up. This one is a rather straightforward cleanup:

First: s/[ ]+$//;s/memset\([ ]+/memset\(/;s/sizeof\([ ]+/sizeof\(/
Second: kill 2 comments saying that memset(foo, 0, bar) zeros out foo
Third: kill double, triple (and even more) and confusing newlines
Finally: remove some superfluous spaces when the line is changed anyway

It is a functional NOOP, it just shrinks the file by more than 1k.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

--- linux-2.6.13-rc5/drivers/scsi/cpqfcTScontrol.c	2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5/drivers/scsi/cpqfcTScontrol.c.eike	2005-08-05 11:46:56.000000000 +0200
@@ -1,6 +1,6 @@
-/* Copyright 2000, Compaq Computer Corporation 
- * Fibre Channel Host Bus Adapter 
- * 64-bit, 66MHz PCI 
+/* Copyright 2000, Compaq Computer Corporation
+ * Fibre Channel Host Bus Adapter
+ * 64-bit, 66MHz PCI
  * Originally developed and tested on:
  * (front): [chip] Tachyon TS HPFC-5166A/1.2  L2C1090 ...
  *          SP# P225CXCBFIEL6T, Rev XC
@@ -19,10 +19,10 @@
  * Written by Don Zimmerman
 */
 /* These functions control the host bus adapter (HBA) hardware.  The main chip
-   control takes place in the interrupt handler where we process the IMQ 
+   control takes place in the interrupt handler where we process the IMQ
    (Inbound Message Queue).  The IMQ is Tachyon's way of communicating FC link
    events and state information to the driver.  The Single Frame Queue (SFQ)
-   buffers incoming FC frames for processing by the driver.  References to 
+   buffers incoming FC frames for processing by the driver.  References to
    "TL/TS UG" are for:
    "HP HPFC-5100/5166 Tachyon TL/TS ICs User Guide", August 16, 1999, 1st Ed.
    Hewlitt Packard Manual Part Number 5968-1083E.
@@ -52,10 +52,10 @@
 //#define IMQ_DEBUG 1
 
 static void fcParseLinkStatusCounters(TACHYON * fcChip);
-static void CpqTsGetSFQEntry(TACHYON * fcChip, 
-	      USHORT pi, ULONG * buffr, BOOLEAN UpdateChip); 
+static void CpqTsGetSFQEntry(TACHYON * fcChip,
+	      USHORT pi, ULONG * buffr, BOOLEAN UpdateChip);
 
-static void 
+static void
 cpqfc_free_dma_consistent(CPQFCHBA *cpqfcHBAdata)
 {
   	// free up the primary EXCHANGES struct and Link Q
@@ -92,14 +92,13 @@ int CpqTsCreateTachLiteQues( void* pHBA,
   // DMA use.
   ENTER("CreateTachLiteQues");
 
-
   // Allocate primary EXCHANGES array...
   fcChip->Exchanges = NULL;
   cpqfcHBAdata->fcLQ = NULL;
-  
-  /* printk("Allocating %u for %u Exchanges ", 
+
+  /* printk("Allocating %u for %u Exchanges ",
 	  (ULONG)sizeof(FC_EXCHANGES), TACH_MAX_XID); */
-  fcChip->Exchanges = pci_alloc_consistent(cpqfcHBAdata->PciDev, 
+  fcChip->Exchanges = pci_alloc_consistent(cpqfcHBAdata->PciDev,
 			sizeof(FC_EXCHANGES), &fcChip->exch_dma_handle);
   /* printk("@ %p\n", fcChip->Exchanges); */
 
@@ -108,13 +107,11 @@ int CpqTsCreateTachLiteQues( void* pHBA,
     printk("pci_alloc_consistent failure on Exchanges: fatal error\n");
     return -1;
   }
-  // zero out the entire EXCHANGE space
-  memset( fcChip->Exchanges, 0, sizeof( FC_EXCHANGES));  
-
+  memset(fcChip->Exchanges, 0, sizeof(FC_EXCHANGES));
 
   /* printk("Allocating %u for LinkQ ", (ULONG)sizeof(FC_LINK_QUE)); */
   cpqfcHBAdata->fcLQ = pci_alloc_consistent(cpqfcHBAdata->PciDev,
-				 sizeof( FC_LINK_QUE), &cpqfcHBAdata->fcLQ_dma_handle);
+				 sizeof(FC_LINK_QUE), &cpqfcHBAdata->fcLQ_dma_handle);
   /* printk("@ %p (%u elements)\n", cpqfcHBAdata->fcLQ, FC_LINKQ_DEPTH); */
 
   if( cpqfcHBAdata->fcLQ == NULL ) // fatal error!!
@@ -123,10 +120,9 @@ int CpqTsCreateTachLiteQues( void* pHBA,
     printk("pci_alloc_consistent() failure on fc Link Que: fatal error\n");
     return -1;
   }
-  // zero out the entire EXCHANGE space
-  memset( cpqfcHBAdata->fcLQ, 0, sizeof( FC_LINK_QUE));  
-  
-  // Verify that basic Tach I/O registers are not NULL  
+  memset(cpqfcHBAdata->fcLQ, 0, sizeof(FC_LINK_QUE));
+
+  // Verify that basic Tach I/O registers are not NULL
   if( !fcChip->Registers.ReMapMemBase )
   {
     cpqfc_free_dma_consistent(cpqfcHBAdata);
@@ -134,17 +130,15 @@ int CpqTsCreateTachLiteQues( void* pHBA,
     return -1;
   }
 
-
   // Initialize the fcMemManager memory pairs (stores allocated/aligned
   // pairs for future freeing)
-  memset( cpqfcHBAdata->dynamic_mem, 0, sizeof(cpqfcHBAdata->dynamic_mem));
-  
+  memset(cpqfcHBAdata->dynamic_mem, 0, sizeof(cpqfcHBAdata->dynamic_mem));
 
   // Allocate Tach's Exchange Request Queue (each ERQ entry 32 bytes)
-  
-  fcChip->ERQ = fcMemManager( cpqfcHBAdata->PciDev, 
-			&cpqfcHBAdata->dynamic_mem[0], 
-			sizeof( TachLiteERQ ), 32*(ERQ_LEN), 0L, &ERQdma);
+
+  fcChip->ERQ = fcMemManager(cpqfcHBAdata->PciDev,
+			&cpqfcHBAdata->dynamic_mem[0],
+			sizeof(TachLiteERQ), 32*(ERQ_LEN), 0L, &ERQdma);
   if( !fcChip->ERQ )
   {
     cpqfc_free_dma_consistent(cpqfcHBAdata);
@@ -152,7 +146,7 @@ int CpqTsCreateTachLiteQues( void* pHBA,
     return -1;
   }
   fcChip->ERQ->length = ERQ_LEN-1;
-  ulAddr = (ULONG) ERQdma; 
+  ulAddr = (ULONG) ERQdma;
 #if BITS_PER_LONG > 32
   if( (ulAddr >> 32) )
   {
@@ -164,12 +158,11 @@ int CpqTsCreateTachLiteQues( void* pHBA,
 #endif
   fcChip->ERQ->base = (ULONG)ulAddr;  // copy for quick reference
 
-
   // Allocate Tach's Inbound Message Queue (32 bytes per entry)
-  
-  fcChip->IMQ = fcMemManager( cpqfcHBAdata->PciDev, 
+
+  fcChip->IMQ = fcMemManager(cpqfcHBAdata->PciDev,
 		  &cpqfcHBAdata->dynamic_mem[0],
-		  sizeof( TachyonIMQ ), 32*(IMQ_LEN), 0L, &IMQdma );
+		  sizeof(TachyonIMQ), 32*(IMQ_LEN), 0L, &IMQdma);
   if( !fcChip->IMQ )
   {
     cpqfc_free_dma_consistent(cpqfcHBAdata);
@@ -190,11 +183,10 @@ int CpqTsCreateTachLiteQues( void* pHBA,
 #endif
   fcChip->IMQ->base = (ULONG)ulAddr;  // copy for quick reference
 
-
   // Allocate Tach's  Single Frame Queue (64 bytes per entry)
-  fcChip->SFQ = fcMemManager( cpqfcHBAdata->PciDev, 
+  fcChip->SFQ = fcMemManager(cpqfcHBAdata->PciDev,
 		  &cpqfcHBAdata->dynamic_mem[0],
-		  sizeof( TachLiteSFQ ), 64*(SFQ_LEN),0L, &SPQdma );
+		  sizeof(TachLiteSFQ), 64*(SFQ_LEN),0L, &SPQdma);
   if( !fcChip->SFQ )
   {
     cpqfc_free_dma_consistent(cpqfcHBAdata);
@@ -203,7 +195,7 @@ int CpqTsCreateTachLiteQues( void* pHBA,
   }
   fcChip->SFQ->length = SFQ_LEN-1;      // i.e. Que length [# entries -
                                        // min. 32; max.  4096 (0xffff)]
-  
+
   ulAddr = SPQdma;
 #if BITS_PER_LONG > 32
   if( (ulAddr >> 32) )
@@ -216,12 +208,11 @@ int CpqTsCreateTachLiteQues( void* pHBA,
 #endif
   fcChip->SFQ->base = (ULONG)ulAddr;  // copy for quick reference
 
-
   // Allocate SCSI Exchange State Table; aligned nearest @sizeof
   // power-of-2 boundary
   // LIVE DANGEROUSLY!  Assume the boundary for SEST mem will
   // be on physical page (e.g. 4k) boundary.
-  /* printk("Allocating %u for TachSEST for %u Exchanges\n", 
+  /* printk("Allocating %u for TachSEST for %u Exchanges\n",
 		 (ULONG)sizeof(TachSEST), TACH_SEST_LEN); */
   fcChip->SEST = fcMemManager( cpqfcHBAdata->PciDev,
 		  &cpqfcHBAdata->dynamic_mem[0],
@@ -237,10 +228,10 @@ int CpqTsCreateTachLiteQues( void* pHBA,
   for( i=0; i < TACH_SEST_LEN; i++)  // for each exchange
       fcChip->SEST->sgPages[i] = NULL;
 
-  fcChip->SEST->length = TACH_SEST_LEN;  // e.g. DON'T subtract one 
+  fcChip->SEST->length = TACH_SEST_LEN;  // e.g. DON'T subtract one
                                        // (TL/TS UG, pg 153)
 
-  ulAddr = SESTdma; 
+  ulAddr = SESTdma;
 #if BITS_PER_LONG > 32
   if( (ulAddr >> 32) )
   {
@@ -252,28 +243,25 @@ int CpqTsCreateTachLiteQues( void* pHBA,
 #endif
   fcChip->SEST->base = (ULONG)ulAddr;  // copy for quick reference
 
-
 			      // Now that structures are defined,
 			      // fill in Tachyon chip registers...
 
 			      // EEEEEEEE  EXCHANGE REQUEST QUEUE
 
-  writel( fcChip->ERQ->base, 
+  writel(fcChip->ERQ->base,
     (fcChip->Registers.ReMapMemBase + TL_MEM_ERQ_BASE));
-      
+
   writel( fcChip->ERQ->length,
     (fcChip->Registers.ReMapMemBase + TL_MEM_ERQ_LENGTH));
-     
 
   fcChip->ERQ->producerIndex = 0L;
   writel( fcChip->ERQ->producerIndex,
     (fcChip->Registers.ReMapMemBase + TL_MEM_ERQ_PRODUCER_INDEX));
-      
 
 		// NOTE! write consumer index last, since the write
 		// causes Tachyon to process the other registers
 
-  ulAddr = ((unsigned long)&fcChip->ERQ->consumerIndex - 
+  ulAddr = ((unsigned long)&fcChip->ERQ->consumerIndex -
 		(unsigned long)fcChip->ERQ) + (unsigned long) ERQdma;
 
   // NOTE! Tachyon DMAs to the ERQ consumer Index host
@@ -281,15 +269,13 @@ int CpqTsCreateTachLiteQues( void* pHBA,
   writel( (ULONG)ulAddr,
     (fcChip->Registers.ReMapMemBase + TL_MEM_ERQ_CONSUMER_INDEX_ADR));
 
-
-
 				 // IIIIIIIIIIIII  INBOUND MESSAGE QUEUE
 				 // Tell Tachyon where the Que starts
 
   // set the Host's pointer for Tachyon to access
 
   /* printk("  cpqfcTS: writing IMQ BASE %Xh  ", fcChip->IMQ->base ); */
-  writel( fcChip->IMQ->base, 
+  writel(fcChip->IMQ->base,
     (fcChip->Registers.ReMapMemBase + IMQ_BASE));
 
   writel( fcChip->IMQ->length,
@@ -298,11 +284,10 @@ int CpqTsCreateTachLiteQues( void* pHBA,
   writel( fcChip->IMQ->consumerIndex,
     (fcChip->Registers.ReMapMemBase + IMQ_CONSUMER_INDEX));
 
-
 		// NOTE: TachLite DMAs to the producerIndex host address
 		// must be correctly aligned with address bits 1-0 cleared
     // Writing the BASE register clears the PI register, so write it last
-  ulAddr = ((unsigned long)&fcChip->IMQ->producerIndex - 
+  ulAddr = ((unsigned long)&fcChip->IMQ->producerIndex -
 		(unsigned long)fcChip->IMQ) + (unsigned long) IMQdma;
 
 #if BITS_PER_LONG > 32
@@ -317,43 +302,37 @@ int CpqTsCreateTachLiteQues( void* pHBA,
 #if DBG
   printk("  PI %Xh\n", (ULONG)ulAddr );
 #endif
-  writel( (ULONG)ulAddr, 
+  writel( (ULONG)ulAddr,
     (fcChip->Registers.ReMapMemBase + IMQ_PRODUCER_INDEX));
 
-
-
 				 // SSSSSSSSSSSSSSS SINGLE FRAME SEQUENCE
 				 // Tell TachLite where the Que starts
 
-  writel( fcChip->SFQ->base, 
+  writel(fcChip->SFQ->base,
     (fcChip->Registers.ReMapMemBase + TL_MEM_SFQ_BASE));
 
   writel( fcChip->SFQ->length,
     (fcChip->Registers.ReMapMemBase + TL_MEM_SFQ_LENGTH));
 
-
          // tell TachLite where SEST table is & how long
   writel( fcChip->SEST->base,
     (fcChip->Registers.ReMapMemBase + TL_MEM_SEST_BASE));
 
   /* printk("  cpqfcTS: SEST %p(virt): Wrote base %Xh @ %p\n",
-    fcChip->SEST, fcChip->SEST->base, 
+    fcChip->SEST, fcChip->SEST->base,
     fcChip->Registers.ReMapMemBase + TL_MEM_SEST_BASE); */
 
   writel( fcChip->SEST->length,
     (fcChip->Registers.ReMapMemBase + TL_MEM_SEST_LENGTH));
-      
+
   writel( (TL_EXT_SG_PAGE_COUNT-1),
     (fcChip->Registers.ReMapMemBase + TL_MEM_SEST_SG_PAGE));
 
-
   LEAVE("CreateTachLiteQues");
 
   return iStatus;
 }
 
-
-
 // function to return TachLite to Power On state
 // 1st - reset tachyon ('SOFT' reset)
 // others - future
@@ -366,15 +345,14 @@ int CpqTsResetTachLite(void *pHBA, int t
   int ret_status=0; // def. success
 
   ENTER("ResetTach");
-  
+
   switch(type)
   {
-
     case CLEAR_FCPORTS:
 
       // in case he was running previously, mask Tach's interrupt
       writeb( 0, (fcChip->Registers.ReMapMemBase + IINTEN));
-      
+
      // de-allocate mem for any Logged in ports
       // (e.g., our module is unloading)
       // search the forward linked list, de-allocating
@@ -405,20 +383,18 @@ int CpqTsResetTachLite(void *pHBA, int t
                               // However, CPQ 64-bit HBAs have a "health
                               // circuit" which keeps laser ON for a brief
                               // period after it is turned off ( < 1s)
-      
-      fcChip->LaserControl( fcChip->Registers.ReMapMemBase, 0);
-  
 
+      fcChip->LaserControl(fcChip->Registers.ReMapMemBase, 0);
 
             // soft reset timing constraints require:
             //   1. set RST to 1
-            //   2. read SOFTRST register 
+            //   2. read SOFTRST register
             //      (128 times per R. Callison code)
             //   3. clear PCI ints
             //   4. clear RST to 0
       writel( 0xff000001L,
         (fcChip->Registers.ReMapMemBase + TL_MEM_SOFTRST));
-        
+
       for( i=0; i<128; i++)
         ulBuff = readl( fcChip->Registers.ReMapMemBase + TL_MEM_SOFTRST);
 
@@ -426,15 +402,13 @@ int CpqTsResetTachLite(void *pHBA, int t
       for( i=0; i<8; i++)
   	writel( 0, (fcChip->Registers.ReMapMemBase + TL_MEM_SOFTRST));
 
-               
-
 			       // clear out our copy of Tach regs,
 			       // because they must be invalid now,
 			       // since TachLite reset all his regs.
       CpqTsDestroyTachLiteQues(cpqfcHBAdata,0); // remove Host-based Que structs
       cpqfcTSClearLinkStatusCounters(fcChip);  // clear our s/w accumulators
                                // lower bits give GBIC info
-      fcChip->Registers.TYstatus.value = 
+      fcChip->Registers.TYstatus.value =
 	              readl( fcChip->Registers.TYstatus.address );
       break;
 
@@ -454,11 +428,6 @@ int CpqTsResetTachLite(void *pHBA, int t
   return ret_status;
 }
 
-
-
-
-
-
 // 'addrBase' is IOBaseU for both TachLite and (older) Tachyon
 int CpqTsLaserControl( void* addrBase, int opcode )
 {
@@ -474,10 +443,6 @@ int CpqTsLaserControl( void* addrBase, i
   return 0;
 }
 
-
-
-
-
 // Use controller's "Options" field to determine loopback mode (if any)
 //   internal loopback (silicon - no GBIC)
 //   external loopback (GBIC - no FC loop)
@@ -497,17 +462,15 @@ int CpqTsInitializeFrameManager( void *p
   // TL/TS UG, pg. 184
   // 0x0065 = 100ms for RT_TOV
   // 0x01f5 = 500ms for ED_TOV
-  // 0x07D1 = 2000ms 
-  fcChip->Registers.ed_tov.value = 0x006507D1; 
+  // 0x07D1 = 2000ms
+  fcChip->Registers.ed_tov.value = 0x006507D1;
   writel( fcChip->Registers.ed_tov.value,
     (fcChip->Registers.ed_tov.address));
-      
 
   // Set LP_TOV to the FC-AL2 specified 2 secs.
   // TL/TS UG, pg. 185
   writel( 0x07d00010, fcChip->Registers.ReMapMemBase +TL_MEM_FM_TIMEOUT2);
 
-
   // Now try to read the WWN from the adapter's NVRAM
   iStatus = CpqTsReadWriteWWN( fcChip, 1); // '1' for READ
 
@@ -522,22 +485,20 @@ int CpqTsInitializeFrameManager( void *p
     fcChip->Registers.wwn_lo = 0x44556677L;
   }
 
-  
-  writel( fcChip->Registers.wwn_hi, 
+  writel(fcChip->Registers.wwn_hi,
 	  fcChip->Registers.ReMapMemBase + TL_MEM_FM_WWN_HI);
-  
-  writel( fcChip->Registers.wwn_lo, 
+
+  writel(fcChip->Registers.wwn_lo,
 	  fcChip->Registers.ReMapMemBase + TL_MEM_FM_WWN_LO);
-	  
 
   // readback for verification:
-  wwnHi = readl( fcChip->Registers.ReMapMemBase + TL_MEM_FM_WWN_HI ); 
-          
+  wwnHi = readl(fcChip->Registers.ReMapMemBase + TL_MEM_FM_WWN_HI );
+
   wwnLo = readl( fcChip->Registers.ReMapMemBase + TL_MEM_FM_WWN_LO);
   // test for correct chip register WRITE/READ
   DEBUG_PCI( printk("  WWN %08X%08X\n",
     fcChip->Registers.wwn_hi, fcChip->Registers.wwn_lo ) );
-    
+
   if( wwnHi != fcChip->Registers.wwn_hi ||
       wwnLo != fcChip->Registers.wwn_lo )
   {
@@ -545,8 +506,6 @@ int CpqTsInitializeFrameManager( void *p
     return -1; // FAILED!
   }
 
-
-
 			// set Frame Manager Initialize command
   fcChip->Registers.FMcontrol.value = 0x06;
 
@@ -570,32 +529,27 @@ int CpqTsInitializeFrameManager( void *p
 
   writel( fcChip->Registers.FMconfig.value,
     fcChip->Registers.FMconfig.address);
-    
 
 			       // issue INITIALIZE command to FM - ACTION!
   writel( fcChip->Registers.FMcontrol.value,
     fcChip->Registers.FMcontrol.address);
-    
+
   LEAVE("InitializeFrameManager");
-  
+
   return 0;
 }
 
-
-
-
-
 // This "look ahead" function examines the IMQ for occurrence of
 // "type".  Returns 1 if found, 0 if not.
 static int PeekIMQEntry( PTACHYON fcChip, ULONG type)
 {
   ULONG CI = fcChip->IMQ->consumerIndex;
   ULONG PI = fcChip->IMQ->producerIndex; // snapshot of IMQ indexes
-  
+
   while( CI != PI )
   {                             // proceed with search
     if( (++CI) >= IMQ_LEN ) CI = 0; // rollover check
-    
+
     switch( type )
     {
       case ELS_LILP_FRAME:
@@ -604,17 +558,17 @@ static int PeekIMQEntry( PTACHYON fcChip
       // If we find it, check the incoming frame payload (1st word)
       // for LILP frame
         if( (fcChip->IMQ->QEntry[CI].type & 0x1FF) == 0x104 )
-        { 
+        {
           TachFCHDR_GCMND* fchs;
 #error This is too much stack
           ULONG ulFibreFrame[2048/4];  // max DWORDS in incoming FC Frame
 	  USHORT SFQpi = (USHORT)(fcChip->IMQ->QEntry[CI].word[0] & 0x0fffL);
 
 	  CpqTsGetSFQEntry( fcChip,
-            SFQpi,        // SFQ producer ndx         
+            SFQpi,        // SFQ producer ndx
 	    ulFibreFrame, // contiguous dest. buffer
 	    FALSE);       // DON'T update chip--this is a "lookahead"
-          
+
 	  fchs = (TachFCHDR_GCMND*)&ulFibreFrame;
           if( fchs->pl[0] == ELS_LILP_FRAME)
 	  {
@@ -624,22 +578,19 @@ static int PeekIMQEntry( PTACHYON fcChip
 	  {
 	    // keep looking...
 	  }
-	}  
+	}
       }
       break;
 
       case OUTBOUND_COMPLETION:
         if( (fcChip->IMQ->QEntry[CI].type & 0x1FF) == 0x00 )
 	{
-
           // any OCM errors?
           if( fcChip->IMQ->QEntry[CI].word[2] & 0x7a000000L )
             return 1;   	    // found OCM error
 	}
       break;
 
-
-      
       default:
       break;
     }
@@ -647,11 +598,10 @@ static int PeekIMQEntry( PTACHYON fcChip
   return 0; // failed to find "type"
 }
 
-			
 static void SetTachTOV( CPQFCHBA* cpqfcHBAdata)
 {
-  PTACHYON fcChip = &cpqfcHBAdata->fcChip; 
-  
+  PTACHYON fcChip = &cpqfcHBAdata->fcChip;
+
   // TL/TS UG, pg. 184
   // 0x0065 = 100ms for RT_TOV
   // 0x01f5 = 500ms for ED_TOV
@@ -662,26 +612,26 @@ static void SetTachTOV( CPQFCHBA* cpqfcH
   // initialization_timeout.fcal.SANMark-1.fc)
   // We have to use 2sec, 24sec, then 128sec when login/
   // port discovery processes fail to complete.
-  
+
   // when port discovery completes (logins done), we set
   // ED_TOV to 500ms -- this is the normal operational case
   // On the first Link Down, we'll move to 2 secs (7D1 ms)
   if( (fcChip->Registers.ed_tov.value &0xFFFF) <= 0x1f5)
-    fcChip->Registers.ed_tov.value = 0x006507D1; 
-  
+    fcChip->Registers.ed_tov.value = 0x006507D1;
+
   // If we get another LST after we moved TOV to 2 sec,
   // increase to 24 seconds (5DC1 ms) per SANMark!
   else if( (fcChip->Registers.ed_tov.value &0xFFFF) <= 0x7D1)
-    fcChip->Registers.ed_tov.value = 0x00655DC1; 
+    fcChip->Registers.ed_tov.value = 0x00655DC1;
 
   // If we get still another LST, set the max TOV (Tachyon
   // has only 16 bits for ms timer, so the max is 65.5 sec)
   else if( (fcChip->Registers.ed_tov.value &0xFFFF) <= 0x5DC1)
-    fcChip->Registers.ed_tov.value = 0x0065FFFF; 
+    fcChip->Registers.ed_tov.value = 0x0065FFFF;
 
   writel( fcChip->Registers.ed_tov.value,
     (fcChip->Registers.ed_tov.address));
-  // keep the same 2sec LP_TOV 
+  // keep the same 2sec LP_TOV
   writel( 0x07D00010, fcChip->Registers.ReMapMemBase +TL_MEM_FM_TIMEOUT2);
 }	
 
@@ -706,12 +656,11 @@ static void SetTachTOV( CPQFCHBA* cpqfcH
 //   2. all IMQ messages should be processed before writing the
 //      IMQ consumer index.
 
-
 int CpqTsProcessIMQEntry(void *host)
 {
   struct Scsi_Host *HostAdapter = (struct Scsi_Host *)host;
   CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
-  PTACHYON fcChip = &cpqfcHBAdata->fcChip; 
+  PTACHYON fcChip = &cpqfcHBAdata->fcChip;
   FC_EXCHANGES *Exchanges = fcChip->Exchanges;
   int iStatus;
   USHORT i, RPCset, DPCset;
@@ -723,7 +672,6 @@ int CpqTsProcessIMQEntry(void *host)
   UCHAR ucInboundMessageType;  // Inbound CM, dword 3 "type" field
 
   ENTER("ProcessIMQEntry");
-   
 
 				// check TachLite's IMQ producer index -
 				// is a new message waiting for us?
@@ -732,12 +680,11 @@ int CpqTsProcessIMQEntry(void *host)
   if( fcChip->IMQ->producerIndex != fcChip->IMQ->consumerIndex )
   {                             // need to process message
 
-
 #ifdef IMQ_DEBUG
-    printk("PI %X, CI %X  type: %X\n", 
+    printk("PI %X, CI %X  type: %X\n",
       fcChip->IMQ->producerIndex,fcChip->IMQ->consumerIndex,
       fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].type);
-#endif                                
+#endif
     // Examine Completion Messages in IMQ
     // what CM_Type?
     switch( (UCHAR)(fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].type
@@ -758,14 +705,11 @@ int CpqTsProcessIMQEntry(void *host)
       //   call fcComplete (to App)
       // ...
 
-
       ulBuff = fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].word[1];
       x_ID = ulBuff & 0x7fffL;     // lower 14 bits SEST_Index/Trans_ID
                                      // Range check CM OX/RX_ID value...
       if( x_ID < TACH_MAX_XID )   // don't go beyond array space
       {
-
-
 	if( ulBuff & 0x20000000L ) // RPC -Response Phase Complete?
           RPCset = 1;              // (SEST transactions only)
         else
@@ -794,8 +738,7 @@ int CpqTsProcessIMQEntry(void *host)
           if( ulBuff & 0x02000000L )
             dwStatus |= ABORTSEQ_NOTIFY;  // ASN
         }
-
-	  
+	
 	if( dwStatus )          // any errors?
         {
                   // set the Outbound Completion status
@@ -805,12 +748,10 @@ int CpqTsProcessIMQEntry(void *host)
           // reque it in the case of LINKFAIL (it will restart on PDISC)
           if( x_ID < TACH_SEST_LEN )
           {
-
-            printk(" #OCM error %Xh x_ID %X# ", 
+            printk(" #OCM error %Xh x_ID %X# ",
 		    dwStatus, x_ID);
 
 	    Exchanges->fcExchange[x_ID].timeOut = 30000; // seconds default
-                                                 
 
 	    // We Q ABTS for each exchange.
 	    // NOTE: We can get FRAME_TO on bad alpa (device gone).  Since
@@ -821,9 +762,9 @@ int CpqTsProcessIMQEntry(void *host)
 	    if( dwStatus & FRAME_TO ) // check for device removed...
 	    {
 	      if( !(Exchanges->fcExchange[x_ID].status & DEVICE_REMOVED) )
-	      { 
+	      {
 		// presumes device is still there: send ABTS.
-  
+
                 cpqfcTSPutLinkQue( cpqfcHBAdata, BLS_ABTS, &x_ID);
 	      }
 	    }
@@ -842,12 +783,11 @@ int CpqTsProcessIMQEntry(void *host)
         }
           // NOTE: we don't necessarily care about ALL completion messages...
                                       // SCSI resp. complete OR
-        if( ((x_ID < TACH_SEST_LEN) && RPCset)|| 
+        if( ((x_ID < TACH_SEST_LEN) && RPCset)||
              (x_ID >= TACH_SEST_LEN) )  // non-SCSI command
         {
               // exchange done; complete to upper levels with status
               // (if necessary) and free the exchange slot
-            
 
           if( x_ID >= TACH_SEST_LEN ) // Link Service Outbound frame?
                                     // A Request or Reply has been sent
@@ -866,49 +806,40 @@ int CpqTsProcessIMQEntry(void *host)
       }
       else  // ERROR CONDITION!  bogus x_ID in completion message
       {
-
         printk(" ProcessIMQ (OBCM) x_id out of range %Xh\n", x_ID);
-
       }
 
-
-
           // Load the Frame Manager's error counters.  We check them here
           // because presumably the link is up and healthy enough for the
           // counters to be meaningful (i.e., don't check them while loop
           // is initializing).
       fcChip->Registers.FMLinkStatus1.value =    // get TL's counter
         readl(fcChip->Registers.FMLinkStatus1.address);
-                  
+
       fcChip->Registers.FMLinkStatus2.value =    // get TL's counter
         readl(fcChip->Registers.FMLinkStatus2.address);
-            
 
       fcParseLinkStatusCounters( fcChip); // load into 6 s/w accumulators
     break;
 
-
-
     case ERROR_IDLE_COMPLETION:  // TachLite Error Idle...
-    
+
     // We usually get this when the link goes down during heavy traffic.
     // For now, presume that if SEST Exchanges are open, we will
     // get this as our cue to INVALIDATE all SEST entries
     // (and we OWN all the SEST entries).
     // See TL/TS UG, pg. 53
-    
+
       for( x_ID = 0; x_ID < TACH_SEST_LEN; x_ID++)
       {
-
         // Does this VALid SEST entry need to be invalidated for Abort?
-        fcChip->SEST->u[ x_ID].IWE.Hdr_Len &= 0x7FFFFFFF; 
+        fcChip->SEST->u[ x_ID].IWE.Hdr_Len &= 0x7FFFFFFF;
       }
-      
+
       CpqTsUnFreezeTachlite( fcChip, 2); // unfreeze Tachyon, if Link OK
 
     break;
 
-
     case INBOUND_SFS_COMPLETION:  //0x04
           // NOTE! we must process this SFQ message to avoid SFQ filling
           // up and stopping TachLite.  Incoming commands are placed here,
@@ -921,17 +852,15 @@ int CpqTsProcessIMQEntry(void *host)
           //       3 - Unkown Frame
           //       4-F reserved
 
-
       fcChip->SFQ->producerIndex = (USHORT)
         (fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].word[0] & 0x0fffL);
 
-
       ucInboundMessageType = 0;  // default to useless frame
 
         // we can only process two Types: 1, Unassisted FCP, and 3, Unknown
         // Also, we aren't interested in processing frame fragments
         // so don't Que anything with 'LKF' bit set
-      if( !(fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].word[2] 
+      if (!(fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].word[2]
         & 0x40000000) )  // 'LKF' link failure bit clear?
       {
         ucInboundMessageType = (UCHAR)  // ICM DWord3, "Type"
@@ -946,26 +875,26 @@ int CpqTsProcessIMQEntry(void *host)
           // clears SFQ entry from Tachyon buffer; copies to contiguous ulBuff
       CpqTsGetSFQEntry(
         fcChip,                  // i.e. this Device Object
-        (USHORT)fcChip->SFQ->producerIndex,  // SFQ producer ndx         
+        (USHORT)fcChip->SFQ->producerIndex,  // SFQ producer ndx
         ulFibreFrame, TRUE);    // contiguous destination buffer, update chip
-                     
+
         // analyze the incoming frame outside the INT handler...
         // (i.e., Worker)
 
       if( ucInboundMessageType == 1 )
       {
         fchs = (TachFCHDR_GCMND*)ulFibreFrame; // cast to examine IB frame
-        // don't fill up our Q with garbage - only accept FCP-CMND  
+        // don't fill up our Q with garbage - only accept FCP-CMND
         // or XRDY frames
         if( (fchs->d_id & 0xFF000000) == 0x06000000 ) // CMND
         {
 	  // someone sent us a SCSI command
-	  
-//          fcPutScsiQue( cpqfcHBAdata, 
-//                        SFQ_UNASSISTED_FCP, ulFibreFrame); 
+	
+//          fcPutScsiQue(cpqfcHBAdata,
+//                        SFQ_UNASSISTED_FCP, ulFibreFrame);
 	}
 	else if( ((fchs->d_id & 0xFF000000) == 0x07000000) || // RSP (status)
-            (fchs->d_id & 0xFF000000) == 0x05000000 )  // XRDY  
+            (fchs->d_id & 0xFF000000) == 0x05000000 )  // XRDY
 	{
 	  ULONG x_ID;
 	  // Unfortunately, ABTS requires a Freeze on the chip so
@@ -978,77 +907,67 @@ int CpqTsProcessIMQEntry(void *host)
 	  // exchange to complete with errors before the timeout
 	  // expires.  We use a Linux Scsi Cmnd result code that
 	  // causes immediate retry.
-	  
 
 	  // Do we have an open exchange that matches this s_id
 	  // and ox_id?
 	  for( x_ID = 0; x_ID < TACH_SEST_LEN; x_ID++)
 	  {
-            if( (fchs->s_id & 0xFFFFFF) == 
-                 (Exchanges->fcExchange[x_ID].fchs.d_id & 0xFFFFFF) 
+            if( (fchs->s_id & 0xFFFFFF) ==
+                 (Exchanges->fcExchange[x_ID].fchs.d_id & 0xFFFFFF)
 		       &&
-                (fchs->ox_rx_id & 0xFFFF0000) == 
+                (fchs->ox_rx_id & 0xFFFF0000) ==
                  (Exchanges->fcExchange[x_ID].fchs.ox_rx_id & 0xFFFF0000) )
 	    {
     //          printk(" #R/X frame x_ID %08X# ", fchs->ox_rx_id );
               // simulate the anticipated error - since the
 	      // SEST was frozen, frames were lost...
               Exchanges->fcExchange[ x_ID ].status |= SFQ_FRAME;
-              
+
 	      // presumes device is still there: send ABTS.
               cpqfcTSPutLinkQue( cpqfcHBAdata, BLS_ABTS, &x_ID);
 	      break;  // done
 	    }
 	  }
 	}
-	  
+	
       }
-          
       else if( ucInboundMessageType == 3)
       {
-        // FC Link Service frames (e.g. PLOGI, ACC) come in here.  
-        cpqfcTSPutLinkQue( cpqfcHBAdata, SFQ_UNKNOWN, ulFibreFrame); 
-                          
-      }
+        // FC Link Service frames (e.g. PLOGI, ACC) come in here.
+        cpqfcTSPutLinkQue( cpqfcHBAdata, SFQ_UNKNOWN, ulFibreFrame);
 
+      }
       else if( ucInboundMessageType == 2 ) // "bad FCP"?
       {
 #ifdef IMQ_DEBUG
         printk("Bad FCP incoming frame discarded\n");
 #endif
       }
-
       else // don't know this type
       {
-#ifdef IMQ_DEBUG 
+#ifdef IMQ_DEBUG
         printk("Incoming frame discarded, type: %Xh\n", ucInboundMessageType);
 #endif
       }
-        
+
         // Check the Frame Manager's error counters.  We check them here
         // because presumably the link is up and healthy enough for the
         // counters to be meaningful (i.e., don't check them while loop
         // is initializing).
       fcChip->Registers.FMLinkStatus1.value =    // get TL's counter
         readl(fcChip->Registers.FMLinkStatus1.address);
-                  
 
       fcChip->Registers.FMLinkStatus2.value =    // get TL's counter
         readl(fcChip->Registers.FMLinkStatus2.address);
-                
 
       break;
 
-
-
-
                     // We get this CM because we issued a freeze
                     // command to stop outbound frames.  We issue the
                     // freeze command at Link Up time; when this message
                     // is received, the ERQ base can be switched and PDISC
                     // frames can be sent.
 
-      
     case ERQ_FROZEN_COMPLETION:  // note: expect ERQ followed immediately
                                  // by FCP when freezing TL
       fcChip->Registers.TYstatus.value =         // read what's frozen
@@ -1056,43 +975,37 @@ int CpqTsProcessIMQEntry(void *host)
       // (do nothing; wait for FCP frozen message)
       break;
     case FCP_FROZEN_COMPLETION:
-      
+
       fcChip->Registers.TYstatus.value =         // read what's frozen
         readl(fcChip->Registers.TYstatus.address);
-      
+
       // Signal the kernel thread to proceed with SEST modification
       up( cpqfcHBAdata->TachFrozen);
 
       break;
 
-
-
     case INBOUND_C1_TIMEOUT:
     case MFS_BUF_WARN:
     case IMQ_BUF_WARN:
     break;
 
-
-
-
-
         // In older Tachyons, we 'clear' the internal 'core' interrupt state
         // by reading the FMstatus register.  In newer TachLite (Tachyon),
         // we must WRITE the register
         // to clear the condition (TL/TS UG, pg 179)
     case FRAME_MGR_INTERRUPT:
     {
-      PFC_LOGGEDIN_PORT pLoggedInPort; 
+      PFC_LOGGEDIN_PORT pLoggedInPort;
 
-      fcChip->Registers.FMstatus.value = 
+      fcChip->Registers.FMstatus.value =
         readl( fcChip->Registers.FMstatus.address );
-                
+
       // PROBLEM: It is possible, especially with "dumb" hubs that
       // don't automatically LIP on by-pass of ports that are going
-      // away, for the hub by-pass process to destroy critical 
+      // away, for the hub by-pass process to destroy critical
       // ordered sets of a frame.  The result of this is a hung LPSM
       // (Loop Port State Machine), which on Tachyon results in a
-      // (default 2 sec) Loop State Timeout (LST) FM message.  We 
+      // (default 2 sec) Loop State Timeout (LST) FM message.  We
       // want to avoid this relatively huge timeout by detecting
       // likely scenarios which will result in LST.
       // To do this, we could examine FMstatus for Loss of Synchronization
@@ -1103,7 +1016,7 @@ int CpqTsProcessIMQEntry(void *host)
       // of the LST states: ARBITRATING, OPEN, OPENED, XMITTED CLOSE,
       // or RECEIVED CLOSE.  (See TL/TS UG, pg. 181)
       // If any of these LPSM states are detected
-      // in combination with the LIP while LDn is not set, 
+      // in combination with the LIP while LDn is not set,
       // send an FM init (LIP F7,F7 for loops)!
       // It is critical to the physical link stability NOT to reset (LIP)
       // more than absolutely necessary; this is a basic premise of the
@@ -1128,7 +1041,6 @@ int CpqTsProcessIMQEntry(void *host)
 	      // re-init the loop before it hangs itself!
               printk(" #req FMinit on E-S: LPSM %Xh# ",Lpsm);
 
-
 	      fcChip->fcStats.FMinits++;
               writel( 6, fcChip->Registers.FMcontrol.address); // LIP
 	    }
@@ -1137,69 +1049,61 @@ int CpqTsProcessIMQEntry(void *host)
 	else if( fcChip->Registers.FMstatus.value & 0x40000 ) // LST?
 	{
           printk(" #req FMinit on LST, LPSM %Xh# ",Lpsm);
-	 
+	
           fcChip->fcStats.FMinits++;
           writel( 6, fcChip->Registers.FMcontrol.address);  // LIP
-	}  
+	}
       }
 
-
       // clear only the 'interrupting' type bits for this REG read
       writel( (fcChip->Registers.FMstatus.value & 0xff3fff00L),
         fcChip->Registers.FMstatus.address);
-                          
 
                // copy frame manager status to unused ULONG slot
       fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].word[0] =
           fcChip->Registers.FMstatus.value; // (for debugging)
 
-
           // Load the Frame Manager's error counters.  We check them here
           // because presumably the link is up and healthy enough for the
           // counters to be meaningful (i.e., don't check them while loop
           // is initializing).
       fcChip->Registers.FMLinkStatus1.value =   // get TL's counter
         readl(fcChip->Registers.FMLinkStatus1.address);
-            
+
       fcChip->Registers.FMLinkStatus2.value =   // get TL's counter
         readl(fcChip->Registers.FMLinkStatus2.address);
-          
+
           // Get FM BB_Credit Zero Reg - does not clear on READ
       fcChip->Registers.FMBB_CreditZero.value =   // get TL's counter
         readl(fcChip->Registers.FMBB_CreditZero.address);
-            
-
 
       fcParseLinkStatusCounters( fcChip); // load into 6 s/w accumulators
 
-
                // LINK DOWN
 
       if( fcChip->Registers.FMstatus.value & 0x100L ) // Link DOWN bit
-      {                                 
+      {
 	
 #ifdef IMQ_DEBUG
         printk("LinkDn\n");
 #endif
         printk(" #LDn# ");
-        
+
         fcChip->fcStats.linkDown++;
-        
+
 	SetTachTOV( cpqfcHBAdata);  // must set according to SANMark
 
 	// Check the ERQ - force it to be "empty" to prevent Tach
 	// from sending out frames before we do logins.
 
-
   	if( fcChip->ERQ->producerIndex != fcChip->ERQ->consumerIndex)
 	{
 //	  printk("#ERQ PI != CI#");
-          CpqTsFreezeTachlite( fcChip, 1); // freeze ERQ only	  
+          CpqTsFreezeTachlite(fcChip, 1); // freeze ERQ only	
 	  fcChip->ERQ->producerIndex = fcChip->ERQ->consumerIndex = 0;
- 	  writel( fcChip->ERQ->base, 
+ 	  writel(fcChip->ERQ->base,
 	    (fcChip->Registers.ReMapMemBase + TL_MEM_ERQ_BASE));
           // re-writing base forces ERQ PI to equal CI
-  
 	}
 		
 	// link down transition occurred -- port_ids can change
@@ -1207,12 +1111,11 @@ int CpqTsProcessIMQEntry(void *host)
         // (and any I/O in progress) until PDISC or PLOGI/PRLI
         // completes
         {
-          pLoggedInPort = &fcChip->fcPorts; 
+          pLoggedInPort = &fcChip->fcPorts;
           while( pLoggedInPort ) // for all ports which are expecting
                                  // PDISC after the next LIP, set the
                                  // logoutTimer
           {
-
 	    if( pLoggedInPort->pdisc) // expecting PDISC within 2 sec?
             {
               pLoggedInPort->LOGO_timer = 3;  // we want 2 seconds
@@ -1222,11 +1125,11 @@ int CpqTsProcessIMQEntry(void *host)
                                 // suspend any I/O in progress until
                                 // PDISC received...
             pLoggedInPort->prli = FALSE;   // block FCP-SCSI commands
-	    
+	
             pLoggedInPort = pLoggedInPort->pNextPort;
           }  // ... all Previously known ports checked
         }
-        
+
 	// since any hot plugging device may NOT support LILP frames
 	// (such as early Tachyon chips), clear this flag indicating
 	// we shouldn't use (our copy of) a LILP map.
@@ -1253,7 +1156,7 @@ int CpqTsProcessIMQEntry(void *host)
         {                     // looking for Extended Link Serv.Exchanges
           if( Exchanges->fcExchange[i].type == ELS_PDISC ||
               Exchanges->fcExchange[i].type == ELS_PLOGI ||
-              Exchanges->fcExchange[i].type == ELS_PRLI ) 
+              Exchanges->fcExchange[i].type == ELS_PRLI)
           {
               // ABORT the exchange!
 #ifdef IMQ_DEBUG
@@ -1266,7 +1169,6 @@ int CpqTsProcessIMQEntry(void *host)
             cpqfcTSCompleteExchange( cpqfcHBAdata->PciDev, fcChip, i); // abort on LDn
           }
         }
-
       }
 
              // ################   LINK UP   ##################
@@ -1276,7 +1178,7 @@ int CpqTsProcessIMQEntry(void *host)
           // We need the following code, duplicated from LinkDn condition,
           // because it's possible for the Tachyon to re-initialize (hard
           // reset) without ever getting a LinkDn indication.
-        pLoggedInPort = &fcChip->fcPorts; 
+        pLoggedInPort = &fcChip->fcPorts;
         while( pLoggedInPort )   // for all ports which are expecting
                                  // PDISC after the next LIP, set the
                                  // logoutTimer
@@ -1286,31 +1188,29 @@ int CpqTsProcessIMQEntry(void *host)
             pLoggedInPort->LOGO_timer = 3;  // we want 2 seconds
                                               // but Timer granularity
                                               // is 1 second
-             
+
                                   // suspend any I/O in progress until
                                   // PDISC received...
-
           }
           pLoggedInPort = pLoggedInPort->pNextPort;
         }  // ... all Previously known ports checked
- 
+
           // CpqTs acquired AL_PA in register AL_PA (ACQ_ALPA)
-        fcChip->Registers.rcv_al_pa.value = 
+        fcChip->Registers.rcv_al_pa.value =
           readl(fcChip->Registers.rcv_al_pa.address);
- 
+
 	// Now, if our acquired address is DIFFERENT from our
         // previous one, we are not allow to do PDISC - we
         // must go back to PLOGI, which will terminate I/O in
         // progress for ALL logged in FC devices...
 	// (This is highly unlikely).
 
-	if( (fcChip->Registers.my_al_pa & 0xFF) != 
+	if( (fcChip->Registers.my_al_pa & 0xFF) !=
 	    ((fcChip->Registers.rcv_al_pa.value >> 16) &0xFF) )
 	{
-
 //	  printk(" #our HBA port_id changed!# "); // FC port_id changed!!	
 
-	  pLoggedInPort = &fcChip->fcPorts; 
+	  pLoggedInPort = &fcChip->fcPorts;
           while( pLoggedInPort ) // for all ports which are expecting
                                  // PDISC after the next LIP, set the
                                  // logoutTimer
@@ -1323,9 +1223,8 @@ int CpqTsProcessIMQEntry(void *host)
 	  // when the port_id changes, we must terminate
 	  // all open exchanges.
           cpqfcTSTerminateExchange( cpqfcHBAdata, NULL, PORTID_CHANGED);
-
 	}
-	               
+	
 	// Replace the entire 24-bit port_id.  We only know the
 	// lower 8 bits (alpa) from Tachyon; if a FLOGI is done,
 	// we'll get the upper 16-bits from the FLOGI ACC frame.
@@ -1338,7 +1237,6 @@ int CpqTsProcessIMQEntry(void *host)
         fcChip->Registers.my_al_pa =
           (fcChip->Registers.rcv_al_pa.value >> 16) & 0xFF;
 
-              
               // copy frame manager status to unused ULONG slot
         fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].word[1] =
           fcChip->Registers.my_al_pa; // (for debugging)
@@ -1354,10 +1252,9 @@ int CpqTsProcessIMQEntry(void *host)
         fcChip->Registers.FMconfig.value = ulBuff; // copy it back
         writel( fcChip->Registers.FMconfig.value,  // put in TachLite
           fcChip->Registers.FMconfig.address);
-            
 
 #ifdef IMQ_DEBUG
-        printk("#LUp %Xh, FMstat 0x%08X#", 
+        printk("#LUp %Xh, FMstat 0x%08X#",
 		fcChip->Registers.my_al_pa, fcChip->Registers.FMstatus.value);
 #endif
 
@@ -1365,7 +1262,6 @@ int CpqTsProcessIMQEntry(void *host)
               // initialization)
         writel( fcChip->Registers.my_al_pa,
           fcChip->Registers.ReMapMemBase +TL_MEM_TACH_My_ID);
-          
 
         fcChip->fcStats.linkUp++;
 
@@ -1374,17 +1270,12 @@ int CpqTsProcessIMQEntry(void *host)
                                      // while link is down)
         ulBuff =                     // just reset TL's counter
                  readl( fcChip->Registers.FMLinkStatus1.address);
-          
+
         ulBuff =                     // just reset TL's counter
                  readl( fcChip->Registers.FMLinkStatus2.address);
 
           // for initiator, need to start verifying ports (e.g. PDISC)
 
-
-
-         
-      
-      
 	CpqTsUnFreezeTachlite( fcChip, 2); // unfreeze Tachlite, if Link OK
 	
 	// Tachyon creates an interesting problem for us on LILP frames.
@@ -1399,16 +1290,13 @@ int CpqTsProcessIMQEntry(void *host)
 	// Processing LILP is required by SANMark
 	udelay( 1000);  // microsec delay waiting for LILP (if it comes)
         if( PeekIMQEntry( fcChip, ELS_LILP_FRAME) )
-	{  // found SFQ LILP, which will post LINKACTIVE	  
+	{  // found SFQ LILP, which will post LINKACTIVE	
 //	  printk("skipping LINKACTIVE post\n");
-
 	}
 	else
-          cpqfcTSPutLinkQue( cpqfcHBAdata, LINKACTIVE, ulFibreFrame);  
+          cpqfcTSPutLinkQue(cpqfcHBAdata, LINKACTIVE, ulFibreFrame);
       }
 
-
-
       // ******* Set Fabric Login indication ********
       if( fcChip->Registers.FMstatus.value & 0x2000 )
       {
@@ -1418,20 +1306,18 @@ int CpqTsProcessIMQEntry(void *host)
       else
         fcChip->Options.fabric = 0;
 
-      
-      
                              // ******* LIP(F8,x) or BAD AL_PA? ********
       if( fcChip->Registers.FMstatus.value & 0x30000L )
       {
                         // copy the error AL_PAs
-        fcChip->Registers.rcv_al_pa.value = 
+        fcChip->Registers.rcv_al_pa.value =
           readl(fcChip->Registers.rcv_al_pa.address);
-            
+
                         // Bad AL_PA?
         if( fcChip->Registers.FMstatus.value & 0x10000L )
         {
           PFC_LOGGEDIN_PORT pLoggedInPort;
-        
+
                        // copy "BAD" al_pa field
           fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].word[1] =
               (fcChip->Registers.rcv_al_pa.value & 0xff00L) >> 8;
@@ -1441,18 +1327,18 @@ int CpqTsProcessIMQEntry(void *host)
             fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].word[1], // port id
             NULL,     // DON'T search linked list for FC WWN
             NULL);    // DON'T care about end of list
- 
+
 	  if( pLoggedInPort )
 	  {
             // Just in case we got this BAD_ALPA because a device
-	    // quietly disappeared (can happen on non-managed hubs such 
+	    // quietly disappeared (can happen on non-managed hubs such
 	    // as the Vixel Rapport 1000),
 	    // do an Implicit Logout.  We never expect this on a Logged
 	    // in port (but do expect it on port discovery).
-	    // (As a reasonable alternative, this could be changed to 
+	    // (As a reasonable alternative, this could be changed to
 	    // simply start the implicit logout timer, giving the device
 	    // several seconds to "come back".)
-	    // 
+	    //
 	    printk(" #BAD alpa %Xh# ",
 		   fcChip->IMQ->QEntry[fcChip->IMQ->consumerIndex].word[1]);
             cpqfcTSImplicitLogout( cpqfcHBAdata, pLoggedInPort);
@@ -1475,12 +1361,10 @@ int CpqTsProcessIMQEntry(void *host)
             // don't count e-s if loop is down!
         if( !(USHORT)(fcChip->Registers.FMstatus.value & 0x80) )
           fcChip->fcStats.e_stores++;
-          
       }
     }
     break;
 
-
     case INBOUND_FCP_XCHG_COMPLETION:  // 0x0C
 
     // Remarks:
@@ -1489,7 +1373,7 @@ int CpqTsProcessIMQEntry(void *host)
     // was received with OX_ID 0, we might respond with XFER_RDY with
     // RX_ID 8001.  This would start the SEST controlled data phases.  When
     // all data frames are received, we get this inbound completion. This means
-    // we should send a status frame to complete the status phase of the 
+    // we should send a status frame to complete the status phase of the
     // FCP-SCSI exchange, using the same OX_ID,RX_ID that we used for data
     // frames.
     // See Outbound CM discussion of x_IDs
@@ -1509,7 +1393,7 @@ int CpqTsProcessIMQEntry(void *host)
 
 //#define FCP_COMPLETION_DBG 1
 #ifdef FCP_COMPLETION_DBG
-        printk(" FCP_CM x_ID %Xh, status %Xh, Cmnd %p\n", 
+        printk(" FCP_CM x_ID %Xh, status %Xh, Cmnd %p\n",
           x_ID, ulBuff, Exchanges->fcExchange[x_ID].Cmnd);
 #endif
         if( ulBuff & 0x08000000L ) // RPC -Response Phase Complete - or -
@@ -1521,17 +1405,15 @@ int CpqTsProcessIMQEntry(void *host)
         dwStatus = 0L;
         if( ulBuff & 0x70000000L ) // any errs?
         {
-          
           if( ulBuff & 0x40000000L )
             dwStatus |= LINKFAIL_RX;
-          
+
 	  if( ulBuff & 0x20000000L )
             dwStatus |= COUNT_ERROR;
-          
+
           if( ulBuff & 0x10000000L )
             dwStatus |= OVERFLOW;
         }
-      
 	
 	  // FCP transaction done - copy status
         Exchanges->fcExchange[ x_ID ].status = dwStatus;
@@ -1546,11 +1428,10 @@ int CpqTsProcessIMQEntry(void *host)
           cpqfcTSCompleteExchange( cpqfcHBAdata->PciDev,fcChip, x_ID);
 
         }  // end "RPCset"
-	
         else  // ("target" logic)
         {
             // Tachlite says all data frames have been received - now it's time
-            // to analyze data transfer (successful?), then send a response 
+            // to analyze data transfer (successful?), then send a response
             // frame for this exchange
 
           ulFibreFrame[0] = x_ID; // copy for later reference
@@ -1558,7 +1439,7 @@ int CpqTsProcessIMQEntry(void *host)
           // if this was a TWE, we have to send satus response
           if( Exchanges->fcExchange[ x_ID].type == SCSI_TWE )
 	  {
-//            fcPutScsiQue( cpqfcHBAdata, 
+//            fcPutScsiQue(cpqfcHBAdata,
 //                NEED_FCP_RSP, ulFibreFrame);  // (ulFibreFrame not used here)
 	  }
         }
@@ -1570,9 +1451,6 @@ int CpqTsProcessIMQEntry(void *host)
 
     break;
 
-
-
-
     case INBOUND_SCSI_DATA_COMMAND:
     case BAD_SCSI_FRAME:
     case INB_SCSI_STATUS_COMPLETION:
@@ -1590,28 +1468,25 @@ int CpqTsProcessIMQEntry(void *host)
     if( fcChip->IMQ->producerIndex == fcChip->IMQ->consumerIndex )
     {                           // all Messages are processed -
       iStatus = 0;              // no more messages to process
-
     }
     else
       iStatus = 1;              // more messages to process
 
     // update TachLite's ConsumerIndex... (clears INTA_L)
-    // NOTE: according to TL/TS UG, the 
+    // NOTE: according to TL/TS UG, the
     // "host must return completion messages in sequential order".
     // Does this mean one at a time, in the order received?  We
     // presume so.
 
     writel( fcChip->IMQ->consumerIndex,
       (fcChip->Registers.ReMapMemBase + IMQ_CONSUMER_INDEX));
-		    
+		
 #if IMQ_DEBUG
-    printk("Process IMQ: writing consumer ndx %d\n ", 
+    printk("Process IMQ: writing consumer ndx %d\n",
       fcChip->IMQ->consumerIndex);
-    printk("PI %X, CI %X\n", 
+    printk("PI %X, CI %X\n",
     fcChip->IMQ->producerIndex,fcChip->IMQ->consumerIndex );
 #endif
-  
-
 
   }
   else
@@ -1619,21 +1494,17 @@ int CpqTsProcessIMQEntry(void *host)
    // hmmm... why did we get interrupted/called with no message?
     iStatus = -1;               // nothing to process
 #if IMQ_DEBUG
-    printk("Process IMQ: no message PI %Xh  CI %Xh", 
+    printk("Process IMQ: no message PI %Xh  CI %Xh",
       fcChip->IMQ->producerIndex,
       fcChip->IMQ->consumerIndex);
 #endif
   }
 
   LEAVE("ProcessIMQEntry");
-  
+
   return iStatus;
 }
 
-
-
-
-
 // This routine initializes Tachyon according to the following
 // options (opcode1):
 // 1 - RESTART Tachyon, simulate power on condition by shutting
@@ -1664,20 +1535,17 @@ int CpqTsInitializeTachLite( void *pHBA,
   if( !fcChip->Registers.ReMapMemBase)                // NULL address for card?
     return -1;                         // FATAL error!
 
-
-
   switch( opcode1 )
   {
     case 1:       // restore hardware to power-on (hard) restart
 
 
-      iStatus = fcChip->ResetTachyon( 
+      iStatus = fcChip->ResetTachyon(
 		  cpqfcHBAdata, opcode2); // laser off, reset hardware
 				      // de-allocate aligned buffers
 
-
 /* TBD      // reset FC link Q (producer and consumer = 0)
-      fcLinkQReset(cpqfcHBAdata); 
+      fcLinkQReset(cpqfcHBAdata);
 
 */
 
@@ -1686,7 +1554,7 @@ int CpqTsInitializeTachLite( void *pHBA,
 
     case 2:       // Config PCI/Tachyon registers
       // NOTE: For Tach TL/TS, bit 31 must be set to 1.  For TS chips, a read
-      // of bit 31 indicates state of M66EN signal; if 1, chip may run at 
+      // of bit 31 indicates state of M66EN signal; if 1, chip may run at
       // 33-66MHz  (see TL/TS UG, pg 159)
 
       ulBuff = 0x80000000;  // TachLite Configuration Register
@@ -1700,21 +1568,21 @@ int CpqTsInitializeTachLite( void *pHBA,
 //                           fcChip->Backplane.slot, TLCFGCMD, &ulBuff, 4);
 
       // read back for reference...
-      fcChip->Registers.TYconfig.value = 
+      fcChip->Registers.TYconfig.value =
          readl( fcChip->Registers.TYconfig.address );
 
       // what is the PCI bus width?
       pci_read_config_byte( cpqfcHBAdata->PciDev,
                                 0x43, // PCIMCTR offset
                                 &bBuff);
-      
+
       fcChip->Registers.PCIMCTR = bBuff;
 
       // set string identifying the chip on the circuit board
 
       fcChip->Registers.TYstatus.value =
         readl( fcChip->Registers.TYstatus.address);
-      
+
       {
 // Now that we are supporting multiple boards, we need to change
 // this logic to check for PCI vendor/device IDs...
@@ -1723,12 +1591,11 @@ int CpqTsInitializeTachLite( void *pHBA,
 	ULONG RevId = (fcChip->Registers.TYstatus.value &0x3E0)>>5;
 	UCHAR Minor = (UCHAR)(RevId & 0x3);
 	UCHAR Major = (UCHAR)((RevId & 0x1C) >>2);
-  
+
 	/* printk("  HBA Tachyon RevId %d.%d\n", Major, Minor); */
   	if( (Major == 1) && (Minor == 2) )
         {
 	  sprintf( cpqfcHBAdata->fcChip.Name, STACHLITE66_TS12);
-
 	}
 	else if( (Major == 1) && (Minor == 3) )
         {
@@ -1742,8 +1609,6 @@ int CpqTsInitializeTachLite( void *pHBA,
 	  sprintf( cpqfcHBAdata->fcChip.Name, STACHLITE_UNKNOWN);
       }
 
-
-
     case 3:       // allocate mem, set Tachyon Que registers
       iStatus = CpqTsCreateTachLiteQues( cpqfcHBAdata, opcode2);
 
@@ -1771,18 +1636,14 @@ int CpqTsInitializeTachLite( void *pHBA,
       break;
   }
   LEAVE("InitializeTachLite");
-  
+
   return iStatus;
 }
 
-
-
-
 // Depending on the type of platform memory allocation (e.g. dynamic),
 // it's probably best to free memory in opposite order as it was allocated.
 // Order of allocation: see other function
 
-
 int CpqTsDestroyTachLiteQues( void *pHBA, int opcode)
 {
   CPQFCHBA *cpqfcHBAdata = (CPQFCHBA*)pHBA;
@@ -1804,8 +1665,8 @@ int CpqTsDestroyTachLiteQues( void *pHBA
       // It's possible that extended S/G pages were allocated, mapped, and
       // not cleared due to error conditions or O/S driver termination.
       // Make sure they're all gone.
-      if (Exchanges->fcExchange[i].Cmnd != NULL) 
-      	cpqfc_pci_unmap(cpqfcHBAdata->PciDev, Exchanges->fcExchange[i].Cmnd, 
+      if (Exchanges->fcExchange[i].Cmnd != NULL)
+      	cpqfc_pci_unmap(cpqfcHBAdata->PciDev, Exchanges->fcExchange[i].Cmnd,
 			fcChip, i); // undo DMA mappings.
 
       for (j=fcChip->SEST->sgPages[i] ; j != NULL ; j = next) {
@@ -1815,7 +1676,7 @@ int CpqTsDestroyTachLiteQues( void *pHBA
       fcChip->SEST->sgPages[i] = NULL;
     }
     ulPtr = (unsigned long)fcChip->SEST;
-    vPtr = fcMemManager( cpqfcHBAdata->PciDev, 
+    vPtr = fcMemManager(cpqfcHBAdata->PciDev,
 		    &cpqfcHBAdata->dynamic_mem[0],
 		    0,0, (ULONG)ulPtr, NULL ); // 'free' mem
     fcChip->SEST = 0L;  // null invalid ptr
@@ -1828,9 +1689,8 @@ int CpqTsDestroyTachLiteQues( void *pHBA
 
   if( fcChip->SFQ )
   {
-
     ulPtr = (unsigned long)fcChip->SFQ;
-    vPtr = fcMemManager( cpqfcHBAdata->PciDev, 
+    vPtr = fcMemManager(cpqfcHBAdata->PciDev,
 		    &cpqfcHBAdata->dynamic_mem[0],
 		    0,0, (ULONG)ulPtr, NULL ); // 'free' mem
     fcChip->SFQ = 0L;  // null invalid ptr
@@ -1841,7 +1701,6 @@ int CpqTsDestroyTachLiteQues( void *pHBA
     }
   }
 
-
   if( fcChip->IMQ )
   {
       // clear Indexes to show empty Queue
@@ -1871,19 +1730,15 @@ int CpqTsDestroyTachLiteQues( void *pHBA
       iStatus = -4;
     }
   }
-    
+
   // free up the primary EXCHANGES struct and Link Q
   cpqfc_free_dma_consistent(cpqfcHBAdata);
-  
+
   LEAVE("DestroyTachLiteQues");
-  
+
   return iStatus;     // non-zero (failed) if any memory not freed
 }
 
-
-
-
-
 // The SFQ is an array with SFQ_LEN length, each element (QEntry)
 // with eight 32-bit words.  TachLite places incoming FC frames (i.e.
 // a valid FC frame with our AL_PA ) in contiguous SFQ entries
@@ -1905,7 +1760,7 @@ static void CpqTsGetSFQEntry(
 {
   ULONG total_bytes=0;
   ULONG consumerIndex = fcChip->SFQ->consumerIndex;
-  
+
 				// check passed copy of SFQ producer index -
 				// is a new message waiting for us?
 				// equal indexes means SFS is copied
@@ -1916,7 +1771,7 @@ static void CpqTsGetSFQEntry(
                    // don't allow copies over Fibre Channel defined length!
     if( total_bytes <= 2048 )
     {
-      memcpy( ulDestPtr, 
+      memcpy(ulDestPtr,
               &fcChip->SFQ->QEntry[consumerIndex],
               64 );  // each SFQ entry is 64 bytes
       ulDestPtr += 16;   // advance pointer to next 64 byte block
@@ -1937,10 +1792,8 @@ static void CpqTsGetSFQEntry(
   }
 }
 
-
-
 // TachLite routinely freezes it's core ques - Outbound FIFO, Inbound FIFO,
-// and Exchange Request Queue (ERQ) on error recover - 
+// and Exchange Request Queue (ERQ) on error recover -
 // (e.g. whenever a LIP occurs).  Here
 // we routinely RESUME by clearing these bits, but only if the loop is up
 // to avoid ERROR IDLE messages forever.
@@ -1948,9 +1801,9 @@ static void CpqTsGetSFQEntry(
 void CpqTsUnFreezeTachlite( void *pChip, int type )
 {
   PTACHYON fcChip = (PTACHYON)pChip;
-  fcChip->Registers.TYcontrol.value = 
+  fcChip->Registers.TYcontrol.value =
     readl(fcChip->Registers.TYcontrol.address);
-            
+
   // (bit 4 of value is GBIC LASER)
   // if we 'unfreeze' the core machines before the loop is healthy
   // (i.e. FLT, OS, LS failure bits set in FMstatus)
@@ -1976,14 +1829,13 @@ void CpqTsUnFreezeTachlite( void *pChip,
 
     writel( fcChip->Registers.TYcontrol.value,
       fcChip->Registers.TYcontrol.address);
-              
+
   }
           // readback for verify (TachLite still frozen?)
-  fcChip->Registers.TYstatus.value = 
+  fcChip->Registers.TYstatus.value =
     readl(fcChip->Registers.TYstatus.address);
 }
 
-
 // Whenever an FC Exchange Abort is required, we must manipulate the
 // Host/Tachyon shared memory SEST table.  Before doing this, we
 // must freeze Tachyon, which flushes certain buffers and ensure we
@@ -1994,22 +1846,19 @@ void CpqTsUnFreezeTachlite( void *pChip,
 void CpqTsFreezeTachlite( void *pChip, int type )
 {
   PTACHYON fcChip = (PTACHYON)pChip;
-  fcChip->Registers.TYcontrol.value = 
+  fcChip->Registers.TYcontrol.value =
     readl(fcChip->Registers.TYcontrol.address);
-    
+
                      //set FFA, FEQ - freezes SCSI assist and ERQ
   if( type == 1)    // freeze ERQ only
     fcChip->Registers.TYcontrol.value |= 0x100L; // (bit 4 is laser)
   else              // freeze both FCP assists (SEST) and ERQ
     fcChip->Registers.TYcontrol.value |= 0x300L; // (bit 4 is laser)
-  
+
   writel( fcChip->Registers.TYcontrol.value,
     fcChip->Registers.TYcontrol.address);
-              
-}
-
-
 
+}
 
 // TL has two Frame Manager Link Status Registers, with three 8-bit
 // fields each. These eight bit counters are cleared after each read,
@@ -2022,7 +1871,6 @@ void fcParseLinkStatusCounters(PTACHYON 
   UCHAR bBuff;
   ULONG ulBuff;
 
-
 // The BB0 timer usually increments when TL is initialized, resulting
 // in an initially bogus count.  If our own counter is ZERO, it means we
 // are reading this thing for the first time, so we ignore the first count.
@@ -2032,7 +1880,7 @@ void fcParseLinkStatusCounters(PTACHYON 
   if( fcChip->fcStats.lastBB0timer == 0L)  // TL was reset? (ignore 1st values)
   {
                            // get TL's register counter - the "last" count
-    fcChip->fcStats.lastBB0timer = 
+    fcChip->fcStats.lastBB0timer =
       fcChip->Registers.FMBB_CreditZero.value & 0x00ffffffL;
   }
   else  // subsequent pass - check for rollover
@@ -2045,7 +1893,6 @@ void fcParseLinkStatusCounters(PTACHYON 
       fcChip->fcStats.BB0_Timer += (0x00FFFFFFL - fcChip->fcStats.lastBB0timer);
       fcChip->fcStats.BB0_Timer += ulBuff;  // plus some more
 
-
     }
     else // no rollover -- more counts or no change
     {
@@ -2056,8 +1903,6 @@ void fcParseLinkStatusCounters(PTACHYON 
     fcChip->fcStats.lastBB0timer = ulBuff;
   }
 
-
-
   bBuff = (UCHAR)(fcChip->Registers.FMLinkStatus1.value >> 24);
   fcChip->fcStats.LossofSignal += bBuff;
 
@@ -2067,7 +1912,6 @@ void fcParseLinkStatusCounters(PTACHYON 
   bBuff = (UCHAR)(fcChip->Registers.FMLinkStatus1.value >> 8);
   fcChip->fcStats.LossofSync += bBuff;
 
-
   bBuff = (UCHAR)(fcChip->Registers.FMLinkStatus2.value >> 24);
   fcChip->fcStats.Rx_EOFa += bBuff;
 
@@ -2078,18 +1922,14 @@ void fcParseLinkStatusCounters(PTACHYON 
   fcChip->fcStats.Bad_CRC += bBuff;
 }
 
-
 void cpqfcTSClearLinkStatusCounters(PTACHYON fcChip)
 {
   ENTER("ClearLinkStatusCounters");
-  memset( &fcChip->fcStats, 0, sizeof( FCSTATS));
+  memset(&fcChip->fcStats, 0, sizeof(FCSTATS));
   LEAVE("ClearLinkStatusCounters");
 
 }
 
-
-
-
 // The following function reads the I2C hardware to get the adapter's
 // World Wide Name (WWN).
 // If the WWN is "500805f1fadb43e8" (as printed on the card), the
@@ -2097,7 +1937,7 @@ void cpqfcTSClearLinkStatusCounters(PTAC
 // is fadb43e8.
 // In the NVRAM, the bytes appear as:
 // [2d] ..
-// [2e] .. 
+// [2e] ..
 // [2f] 50
 // [30] 08
 // [31] 05
@@ -2133,7 +1973,7 @@ int CpqTsReadWriteWWN( PVOID pChip, int 
     if( ulBuff )   // NVRAM read successful?
     {
       iStatus = 0; // success!
-      
+
                    // for engineering/ prototype boards, the data may be
                    // invalid (GIGO, usually all "FF"); this prevents the
                    // parse routine from working correctly, which means
@@ -2147,7 +1987,7 @@ int CpqTsReadWriteWWN( PVOID pChip, int 
         for( i= 0; i < 8; i++)
           WWNbuf[i] = nvRam[i +0x2f]; // dangerous! some formats won't work
       }
-      
+
       fcChip->Registers.wwn_hi = 0L;
       fcChip->Registers.wwn_lo = 0L;
       for( i=0; i<4; i++)  // WWN bytes are big endian in NVRAM
@@ -2165,30 +2005,21 @@ int CpqTsReadWriteWWN( PVOID pChip, int 
     }  // done reading
     else
     {
-
       printk( "cpqfcTS: NVRAM read failed\n");
-
     }
   }
-
   else  // WRITE
   {
-
     // NOTE: WRITE not supported & not used in released driver.
 
-   
     printk("ReadWriteNRAM: can't write NVRAM; aborting write\n");
   }
-  
+
   LEAVE("ReadWriteWWN");
   return iStatus;
 }
 
-
-
-
-
-// The following function reads or writes the entire "NVRAM" contents of 
+// The following function reads or writes the entire "NVRAM" contents of
 // the I2C hardware (i.e. the NM24C03).  Note that HP's 5121A (TS 66Mhz)
 // adapter does not use the NM24C03 chip, so this function only works on
 // Compaq's adapters.
@@ -2201,7 +2032,7 @@ int CpqTsReadWriteNVRAM( PVOID pChip, PV
   UCHAR *ucPtr = buf; // cast caller's void ptr to UCHAR array
   int iStatus=-1;  // assume failure
 
-     
+
   if( Read )  // READing NVRAM?
   {
     ulBuff = cpqfcTS_ReadNVRAM(   // TRUE on success
@@ -2210,7 +2041,6 @@ int CpqTsReadWriteNVRAM( PVOID pChip, PV
                 256,            // bytes to write
                 ucPtr );        // source ptr
 
-
     if( ulBuff )
       iStatus = 0; // success
     else
@@ -2220,12 +2050,10 @@ int CpqTsReadWriteNVRAM( PVOID pChip, PV
 #endif
     }
   }  // done reading
-
-  else  // WRITING NVRAM 
+  else  // WRITING NVRAM
   {
-
     printk("cpqfcTS: WRITE of FC Controller's NVRAM disabled\n");
   }
-    
+
   return iStatus;
 }

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc5] rewrite drivers/scsi/cpqfcTScontrol.c::CpqTsGetSFQEntry
  2005-08-05 10:02 [PATCH 2.6.13-rc5] reduce whitespace bloat in drivers/scsi/cpqfcTScontrol.c Rolf Eike Beer
@ 2005-08-09 16:06 ` Rolf Eike Beer
  2005-08-16  9:11   ` [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver Rolf Eike Beer
  0 siblings, 1 reply; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-09 16:06 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds

This patch applies on top of my previous one that removed the whitespace
bloat.

This patch now fixes the type horror in CpqTsGetSFQEntry():
-the destination buffer is now void* instead of ULONG*
-the offset is now done by a int (former ULONG) variable and not
 adding bytes to the pointer address
-the last argument is not int, not boolean
-the second argument is compared to ULONG but is USHORT. And one (of two)
 callers passes a ULONG casted to USHORT. Use ULONG instead.
-remove some of the comments
-don't use argument names in functions forward declaration: they don't match
 the actual names anyway

While I'm at it, I fixed the coding style of this function. The rest of the
file is is still horror, but this no excuse for not fixing this function.

This shrinks the file by another 500 bytes and should not make any difference
in function.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

--- 2.6.13-rc6/drivers/scsi/cpqfcTScontrol.c	2005-08-09 17:39:49.000000000 +0200
+++ b/drivers/scsi/cpqfcTScontrol.c	2005-08-09 17:49:41.000000000 +0200
@@ -52,8 +52,7 @@
 //#define IMQ_DEBUG 1
 
 static void fcParseLinkStatusCounters(TACHYON * fcChip);
-static void CpqTsGetSFQEntry(TACHYON * fcChip,
-	      USHORT pi, ULONG * buffr, BOOLEAN UpdateChip);
+static void CpqTsGetSFQEntry(TACHYON *, ULONG, void*, int);
 
 static void
 cpqfc_free_dma_consistent(CPQFCHBA *cpqfcHBAdata)
@@ -562,12 +561,11 @@ static int PeekIMQEntry( PTACHYON fcChip
           TachFCHDR_GCMND* fchs;
 #error This is too much stack
           ULONG ulFibreFrame[2048/4];  // max DWORDS in incoming FC Frame
-	  USHORT SFQpi = (USHORT)(fcChip->IMQ->QEntry[CI].word[0] & 0x0fffL);
+	  ULONG SFQpi = (fcChip->IMQ->QEntry[CI].word[0] & 0x0fffL);
 
 	  CpqTsGetSFQEntry( fcChip,
             SFQpi,        // SFQ producer ndx
-	    ulFibreFrame, // contiguous dest. buffer
-	    FALSE);       // DON'T update chip--this is a "lookahead"
+		ulFibreFrame, 0);	// DON'T update chip--this is a "lookahead"
 
 	  fchs = (TachFCHDR_GCMND*)&ulFibreFrame;
           if( fchs->pl[0] == ELS_LILP_FRAME)
@@ -875,8 +873,8 @@ int CpqTsProcessIMQEntry(void *host)
           // clears SFQ entry from Tachyon buffer; copies to contiguous ulBuff
       CpqTsGetSFQEntry(
         fcChip,                  // i.e. this Device Object
-        (USHORT)fcChip->SFQ->producerIndex,  // SFQ producer ndx
-        ulFibreFrame, TRUE);    // contiguous destination buffer, update chip
+		fcChip->SFQ->producerIndex,  // SFQ producer ndx
+		ulFibreFrame, 1);    // contiguous destination buffer, update chip
 
         // analyze the incoming frame outside the INT handler...
         // (i.e., Worker)
@@ -1739,57 +1737,54 @@ int CpqTsDestroyTachLiteQues( void *pHBA
   return iStatus;     // non-zero (failed) if any memory not freed
 }
 
-// The SFQ is an array with SFQ_LEN length, each element (QEntry)
-// with eight 32-bit words.  TachLite places incoming FC frames (i.e.
-// a valid FC frame with our AL_PA ) in contiguous SFQ entries
-// and sends a completion message telling the host where the frame is
-// in the que.
-// This function copies the current (or oldest not-yet-processed) QEntry to
-// a caller's contiguous buffer and updates the Tachyon chip's consumer index
-//
-// NOTE:
-//   An FC frame may consume one or many SFQ entries.  We know the total
-//   length from the completion message.  The caller passes a buffer large
-//   enough for the complete message (max 2k).
-
-static void CpqTsGetSFQEntry(
-         PTACHYON fcChip,
-         USHORT producerNdx,
-         ULONG *ulDestPtr,            // contiguous destination buffer
-	 BOOLEAN UpdateChip)
+/**
+ * CpqTsGetSFQEntry
+ * @dest: contiguous destination buffer
+ *
+ *The SFQ is an array with SFQ_LEN length, each element (QEntry)
+ * with eight 32-bit words.  TachLite places incoming FC frames (i.e.
+ * a valid FC frame with our AL_PA ) in contiguous SFQ entries
+ * and sends a completion message telling the host where the frame is
+ * in the queue.
+ * This function copies the current (or oldest not-yet-processed) QEntry to
+ * a caller's contiguous buffer and updates the Tachyon chip's consumer index
+ *
+ * NOTE:
+ *   An FC frame may consume one or many SFQ entries.  We know the total
+ *   length from the completion message.  The caller passes a buffer large
+ *   enough for the complete message (max 2k).
+ */
+static void
+CpqTsGetSFQEntry(PTACHYON fcChip, ULONG producerNdx, void *ulDestPtr,
+	int UpdateChip)
 {
-  ULONG total_bytes=0;
-  ULONG consumerIndex = fcChip->SFQ->consumerIndex;
-
-				// check passed copy of SFQ producer index -
-				// is a new message waiting for us?
-				// equal indexes means SFS is copied
+	int total_bytes = 0;
+	ULONG consumerIndex = fcChip->SFQ->consumerIndex;
 
-  while( producerNdx != consumerIndex )
-  {                             // need to process message
-    total_bytes += 64;   // maintain count to prevent writing past buffer
-                   // don't allow copies over Fibre Channel defined length!
-    if( total_bytes <= 2048 )
-    {
-      memcpy(ulDestPtr,
-              &fcChip->SFQ->QEntry[consumerIndex],
-              64 );  // each SFQ entry is 64 bytes
-      ulDestPtr += 16;   // advance pointer to next 64 byte block
-    }
-		         // Tachyon is producing,
-                         // and we are consuming
-
-    if( ++consumerIndex >= SFQ_LEN)// check for rollover
-      consumerIndex = 0L;        // reset it
-  }
+	/* check passed copy of SFQ producer index -
+	 * is a new message waiting for us?
+	 * equal indexes means SFS is copied */
+
+	while (producerNdx != consumerIndex) {
+		/* need to process message */
+		if(total_bytes < 2048) {
+			memcpy(ulDestPtr + total_bytes,
+				&fcChip->SFQ->QEntry[consumerIndex], 64);
+		}
+		/* each SFQ entry is 64 bytes */
+		total_bytes += 64;
+
+		/* check for rollover */
+		if(++consumerIndex >= SFQ_LEN)
+			consumerIndex = 0;
+	}
 
-  // if specified, update the Tachlite chip ConsumerIndex...
-  if( UpdateChip )
-  {
-    fcChip->SFQ->consumerIndex = consumerIndex;
-    writel( fcChip->SFQ->consumerIndex,
-      fcChip->Registers.SFQconsumerIndex.address);
-  }
+	/* if specified, update the Tachlite chip ConsumerIndex */
+	if(UpdateChip) {
+		fcChip->SFQ->consumerIndex = consumerIndex;
+		writel(fcChip->SFQ->consumerIndex,
+			fcChip->Registers.SFQconsumerIndex.address);
+	}
 }
 
 // TachLite routinely freezes it's core ques - Outbound FIFO, Inbound FIFO,

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver
  2005-08-09 16:06 ` [PATCH 2.6.13-rc5] rewrite drivers/scsi/cpqfcTScontrol.c::CpqTsGetSFQEntry Rolf Eike Beer
@ 2005-08-16  9:11   ` Rolf Eike Beer
  2005-08-16  9:11     ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for " Rolf Eike Beer
  2005-08-16  9:17     ` [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver Christoph Hellwig
  0 siblings, 2 replies; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16  9:11 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds,
	Bolke de Bruin

cpqfcTS_reset() is never referenced from anywhere. By using the nonexistent 
constant SCSI_RESET_ERROR it causes just another unneeded compile error.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

--- a/drivers/scsi/cpqfcTSinit.c	2005-08-13 09:34:20.000000000 +0200
+++ b/drivers/scsi/cpqfcTSinit.c	2005-08-13 10:36:19.000000000 +0200
@@ -1693,16 +1695,6 @@ int cpqfcTS_eh_device_reset(Scsi_Cmnd *C
   return retval;
 }
 
-	
-int cpqfcTS_reset(Scsi_Cmnd *Cmnd, unsigned int reset_flags)
-{
-
-  ENTER("cpqfcTS_reset");
-
-  LEAVE("cpqfcTS_reset");
-  return SCSI_RESET_ERROR;      /* Bus Reset Not supported */
-}
-
 /* This function determines the bios parameters for a given
    harddisk. These tend to be numbers that are made up by the
    host adapter.  Parameters:
--- a/drivers/scsi/cpqfcTS.h	2005-08-07 20:18:56.000000000 +0200
+++ b/drivers/scsi/cpqfcTS.h	2005-08-13 14:02:44.000000000 +0200
@@ -9,7 +9,6 @@ extern const char * cpqfcTS_info(struct 
 extern int cpqfcTS_proc_info(struct Scsi_Host *, char *, char **, off_t, int, 
int);
 extern int cpqfcTS_queuecommand(Scsi_Cmnd *, void (* done)(Scsi_Cmnd *));
 extern int cpqfcTS_abort(Scsi_Cmnd *);
-extern int cpqfcTS_reset(Scsi_Cmnd *, unsigned int);
 extern int cpqfcTS_eh_abort(Scsi_Cmnd *Cmnd);
 extern int cpqfcTS_eh_device_reset(Scsi_Cmnd *);
 extern int cpqfcTS_biosparam(struct scsi_device *, struct block_device *,

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver
  2005-08-16  9:11   ` [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver Rolf Eike Beer
@ 2005-08-16  9:11     ` Rolf Eike Beer
  2005-08-16  9:12       ` [PATCH 2.6.13-rc6] remove 2.4 compat code from " Rolf Eike Beer
                         ` (2 more replies)
  2005-08-16  9:17     ` [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver Christoph Hellwig
  1 sibling, 3 replies; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16  9:11 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds,
	Bolke de Bruin

cpqfcTSinit has a static array of PCI device and vendor ids supported by the 
driver. Sounds familiar, doesn't it? Use pci_device_id as type for the 
entries of this array and declare the array as MODULE_DEVICE_TABLE. Also use 
pci_get_device() instead of pci_find_device() and remove some superfluos 
defines for device scanning.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

--- a/drivers/scsi/cpqfcTSstructs.h	2005-08-14 10:56:41.000000000 +0200
+++ b/drivers/scsi/cpqfcTSstructs.h	2005-08-14 10:57:32.000000000 +0200
@@ -95,12 +95,6 @@
 
 #define DEV_NAME "cpqfcTS"
 
-struct SupportedPCIcards
-{
-  __u16 vendor_id;
-  __u16 device_id;
-};
-			 
 // nn:nn denotes bit field
                             // TachyonHeader struct def.
                             // the fields shared with ODB
--- a/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:20:40.000000000 +0200
+++ b/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:25:33.000000000 +0200
@@ -264,18 +264,14 @@ static void launch_FCworker_thread(struc
  * Agilent XL2 
  * HP Tachyon
  */
-#define HBA_TYPES 3
-
-#ifndef PCI_DEVICE_ID_COMPAQ_
-#define PCI_DEVICE_ID_COMPAQ_TACHYON	0xa0fc
-#endif
-
-static struct SupportedPCIcards cpqfc_boards[] __initdata = {
-	{PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TACHYON},
-	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHLITE},
-	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHYON},
+static struct pci_device_id cpqfc_boards[] __initdata = {
+	{PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TACHYON, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHLITE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHYON, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{0, }
 };
 
+MODULE_DEVICE_TABLE(pci, cpqfc_boards);
 
 int cpqfcTS_detect(Scsi_Host_Template *ScsiHostTemplate)
 {
@@ -294,14 +290,9 @@ int cpqfcTS_detect(Scsi_Host_Template *S
   ScsiHostTemplate->proc_name = "cpqfcTS";
 #endif
 
-  for( i=0; i < HBA_TYPES; i++)
-  {
-    // look for all HBAs of each type
-
-    while((PciDev = pci_find_device(cpqfc_boards[i].vendor_id,
-				    cpqfc_boards[i].device_id, PciDev)))
-    {
-
+  for(i = 0; cpqfc_boards[i]; i++) {
+    while((PciDev = pci_get_device(cpqfc_boards[i].vendor,
+				    cpqfc_boards[i].device, PciDev))) {
       if (pci_enable_device(PciDev)) {
 	printk(KERN_ERR
 		"cpqfc: can't enable PCI device at %s\n", pci_name(PciDev));

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] remove 2.4 compat code from cpqfcTS driver
  2005-08-16  9:11     ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for " Rolf Eike Beer
@ 2005-08-16  9:12       ` Rolf Eike Beer
  2005-08-16  9:13         ` [PATCH 2.6.13-rc6] more whitespace cleanups for cpqfcTS Rolf Eike Beer
  2005-08-16 14:28         ` [PATCH 2.6.13-rc6] remove 2.4 compat code from cpqfcTS driver, take 2 Rolf Eike Beer
  2005-08-16 12:53       ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver Jiri Slaby
  2005-08-16 14:36       ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver, take 2 Rolf Eike Beer
  2 siblings, 2 replies; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16  9:12 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds,
	Bolke de Bruin

Remove compat code for Linux 2.4 and earlier.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

--- a/drivers/scsi/cpqfcTScontrol.c	2005-08-13 19:00:35.000000000 +0200
+++ b/drivers/scsi/cpqfcTScontrol.c	2005-08-14 11:02:09.000000000 +0200
@@ -28,8 +28,6 @@
    Hewlitt Packard Manual Part Number 5968-1083E.
 */
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
-
 #include <linux/blkdev.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
--- a/drivers/scsi/cpqfcTSstructs.h	2005-08-14 11:11:52.000000000 +0200
+++ b/drivers/scsi/cpqfcTSstructs.h	2005-08-14 11:12:54.000000000 +0200
@@ -88,7 +88,6 @@
 #define CPQFCTS_CMD_PER_LUN 15 // power of 2 -1, must be >0 
 #define CPQFCTS_REQ_QUEUE_LEN (TACH_SEST_LEN/2) // must be < TACH_SEST_LEN
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
 #ifndef DECLARE_MUTEX_LOCKED
 #define DECLARE_MUTEX_LOCKED(sem) struct semaphore sem = MUTEX_LOCKED
 #endif
--- a/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:56:41.000000000 +0200
+++ b/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:57:27.000000000 +0200
@@ -29,8 +29,6 @@
 */
 
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
-
 #include <linux/config.h>  
 #include <linux/interrupt.h>  
 #include <linux/module.h>
@@ -72,31 +70,10 @@ int cpqfcTS_TargetDeviceReset( Scsi_Devi
 // few fields...
 // NOTE: proc_fs changes in 2.4 kernel
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
-static struct proc_dir_entry proc_scsi_cpqfcTS =
-{
-  PROC_SCSI_CPQFCTS,           // ushort low_ino (enumerated list)
-  7,                           // ushort namelen
-  DEV_NAME,                    // const char* name
-  S_IFDIR | S_IRUGO | S_IXUGO, // mode_t mode
-  2                            // nlink_t nlink
-	                       // etc. ...
-};
-
-
-#endif
-
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,7)
-#  define CPQFC_DECLARE_COMPLETION(x) DECLARE_COMPLETION(x)
-#  define CPQFC_WAITING waiting
-#  define CPQFC_COMPLETE(x) complete(x)
-#  define CPQFC_WAIT_FOR_COMPLETION(x) wait_for_completion(x);
-#else
-#  define CPQFC_DECLARE_COMPLETION(x) DECLARE_MUTEX_LOCKED(x)
-#  define CPQFC_WAITING sem
-#  define CPQFC_COMPLETE(x) up(x)
-#  define CPQFC_WAIT_FOR_COMPLETION(x) down(x)
-#endif
+#define CPQFC_DECLARE_COMPLETION(x) DECLARE_COMPLETION(x)
+#define CPQFC_WAITING waiting
+#define CPQFC_COMPLETE(x) complete(x)
+#define CPQFC_WAIT_FOR_COMPLETION(x) wait_for_completion(x);
 
 static int cpqfc_alloc_private_data_pool(CPQFCHBA *hba);
 
@@ -284,12 +261,6 @@ int cpqfcTS_detect(Scsi_Host_Template *S
 
   ENTER("cpqfcTS_detect");
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
-  ScsiHostTemplate->proc_dir = &proc_scsi_cpqfcTS;
-#else
-  ScsiHostTemplate->proc_name = "cpqfcTS";
-#endif
-
   for(i = 0; cpqfc_boards[i]; i++) {
     while((PciDev = pci_get_device(cpqfc_boards[i].vendor,
 				    cpqfc_boards[i].device, PciDev))) {
@@ -2059,6 +2030,7 @@ void* fcMemManager( struct pci_dev *pdev
 
 
 static Scsi_Host_Template driver_template = {
+	.procname               = DEV_NAME;
 	.detect                 = cpqfcTS_detect,
 	.release                = cpqfcTS_release,
 	.info                   = cpqfcTS_info,

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] more whitespace cleanups for cpqfcTS
  2005-08-16  9:12       ` [PATCH 2.6.13-rc6] remove 2.4 compat code from " Rolf Eike Beer
@ 2005-08-16  9:13         ` Rolf Eike Beer
  2005-08-16  9:14           ` [PATCH 2.6.13-rc6] remove superfluos ioctls from cpqfcTS Rolf Eike Beer
  2005-08-16 14:28         ` [PATCH 2.6.13-rc6] remove 2.4 compat code from cpqfcTS driver, take 2 Rolf Eike Beer
  1 sibling, 1 reply; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16  9:13 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds,
	Bolke de Bruin

More whitespace cleanups:
-remove trailing whitespace
-remove brakets around return statements
-remove some double (or more) newlines

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

--- a/drivers/scsi/cpqfcTSi2c.c	2005-08-07 20:18:56.000000000 +0200
+++ b/drivers/scsi/cpqfcTSi2c.c	2005-08-14 15:47:35.000000000 +0200
@@ -1,6 +1,6 @@
-/* Copyright(c) 2000, Compaq Computer Corporation 
- * Fibre Channel Host Bus Adapter 
- * 64-bit, 66MHz PCI 
+/* Copyright(c) 2000, Compaq Computer Corporation
+ * Fibre Channel Host Bus Adapter
+ * 64-bit, 66MHz PCI
  * Originally developed and tested on:
  * (front): [chip] Tachyon TS HPFC-5166A/1.2  L2C1090 ...
  *          SP# P225CXCBFIEL6T, Rev XC
@@ -18,16 +18,15 @@
  * General Public License for more details.
  * Written by Don Zimmerman
 */
-// These functions control the NVRAM I2C hardware on 
+// These functions control the NVRAM I2C hardware on
 // non-intelligent Fibre Host Adapters.
-// The primary purpose is to read the HBA's NVRAM to get adapter's 
+// The primary purpose is to read the HBA's NVRAM to get adapter's
 // manufactured WWN to copy into Tachyon chip registers
 // Orignal source author unknown
 
 #include <linux/types.h>
 enum boolean { FALSE, TRUE } ;
 
-
 #ifndef UCHAR
 typedef __u8 UCHAR;
 #endif
@@ -41,7 +40,6 @@ typedef __u16 USHORT;
 typedef __u32 ULONG;
 #endif
 
-
 #include <linux/string.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
@@ -61,7 +59,7 @@ static void tl_i2c_tx_byte( void* GPIOou
 // Tachlite GPIO2, GPIO3 (I2C) DEFINES
 // The NVRAM chip NM24C03 defines SCL (serial clock) and SDA (serial data)
 // GPIO2 drives SDA, and GPIO3 drives SCL
-// 
+//
 // Since Tachlite inverts the state of the GPIO 0-3 outputs, SET writes 0
 // and clear writes 1. The input lines (read in TL status) is NOT inverted
 // This really helps confuse the code and debugging.
@@ -78,7 +76,6 @@ static void tl_i2c_tx_byte( void* GPIOou
 
 #define SLAVE_READ_ADDRESS    0xA1
 #define SLAVE_WRITE_ADDRESS   0xA0
-					      
 
 static void i2c_delay(ULONG mstime);
 static void tl_i2c_clock_pulse( UCHAR , void* GPIOout);
@@ -102,9 +99,9 @@ static unsigned short tl_i2c_rx_ack( voi
 	// slave must drive data low for acknowledge
   value = tl_read_i2c_data( GPIOin);
   if (value & SENSE_DATA_HI )
-    return( FALSE );
+    return FALSE;
 
-  return( TRUE );
+  return TRUE;
 }
 //-----------------------------------------------------------------------------
 //
@@ -116,7 +113,7 @@ static unsigned short tl_i2c_rx_ack( voi
 //-----------------------------------------------------------------------------
 static UCHAR tl_read_i2c_data( void* gpioreg )
 {
-  return( (UCHAR)(readl( gpioreg ) & 0x08L) ); // GPIO3
+  return (UCHAR)(readl( gpioreg ) & 0x08L); // GPIO3
 }
 //-----------------------------------------------------------------------------
 //
@@ -171,16 +168,15 @@ static unsigned short tl_i2c_tx_start( v
 		// if he's still driving data low after 10 clocks, abort
     value = tl_read_i2c_data( GPIOin ); // read status
     if (!(value & 0x08) )
-      return( FALSE );
+      return FALSE;
   }
 
-
 	// To START, bring data low while clock high
   tl_write_i2c_reg(  GPIOout, SET_CLOCK_HI | SET_DATA_LO );
 
   i2c_delay(0);
 
-  return( TRUE );                           // TX start successful
+  return TRUE;                           // TX start successful
 }
 //-----------------------------------------------------------------------------
 //
@@ -194,7 +190,7 @@ static unsigned short tl_i2c_tx_stop( vo
 {
   int i;
 
-  for (i = 0; i < 10; i++) 
+  for (i = 0; i < 10; i++)
   {
   // Send clock pulse, drive data line low
     tl_i2c_clock_pulse( SET_DATA_LO, GPIOout );
@@ -207,10 +203,10 @@ static unsigned short tl_i2c_tx_stop( vo
 
   // If slave is driving data line low, there's a problem; retry
     if ( tl_read_i2c_data(GPIOin) & SENSE_DATA_HI )
-      return( TRUE );  // TX STOP successful!
+      return TRUE;  // TX STOP successful!
   }
 
-  return( FALSE );                      // error
+  return FALSE;                      // error
 }
 //-----------------------------------------------------------------------------
 //
@@ -229,7 +225,7 @@ static void tl_i2c_tx_byte( void* GPIOou
       tl_i2c_clock_pulse( (UCHAR)SET_DATA_HI, GPIOout);
     else
       tl_i2c_clock_pulse( (UCHAR)SET_DATA_LO, GPIOout);
-  }  
+  }
 }
 //-----------------------------------------------------------------------------
 //
@@ -243,7 +239,6 @@ static UCHAR tl_i2c_rx_byte( void* GPIOi
   UCHAR bit;
   UCHAR data = 0;
 
-
   for (bit = 0x80; bit; bit >>= 1) {
     // do clock pulse, let data line float high
     tl_i2c_clock_pulse( SET_DATA_HI, GPIOout );
@@ -253,7 +248,7 @@ static UCHAR tl_i2c_rx_byte( void* GPIOi
       data |= bit;
   }
 
-  return (data);
+  return data;
 }
 //*****************************************************************************
 //*****************************************************************************
@@ -275,12 +270,12 @@ unsigned long cpqfcTS_ReadNVRAM( void* G
   // Select the NVRAM for "dummy" write, to set the address
   tl_i2c_tx_byte( GPIOout , SLAVE_WRITE_ADDRESS );
   if ( !tl_i2c_rx_ack(GPIOin, GPIOout ) )
-    return( FALSE );
+    return FALSE;
 
-  // Now send the address where we want to start reading  
+  // Now send the address where we want to start reading
   tl_i2c_tx_byte( GPIOout , 0 );
   if ( !tl_i2c_rx_ack(GPIOin, GPIOout ) )
-    return( FALSE );
+    return FALSE;
 
   // Send a repeated start condition and select the
   //  slave for reading now.
@@ -288,11 +283,11 @@ unsigned long cpqfcTS_ReadNVRAM( void* G
     tl_i2c_tx_byte( GPIOout, SLAVE_READ_ADDRESS );
 
   if ( !tl_i2c_rx_ack(GPIOin, GPIOout) )
-    return( FALSE );
+    return FALSE;
 
   // this loop will now read out the data and store it
   //  in the buffer pointed to by buf
-  for ( i=0; i<count; i++) 
+  for (i = 0; i < count; i++)
   {
     *buf++ = tl_i2c_rx_byte(GPIOin, GPIOout);
 
@@ -307,7 +302,7 @@ unsigned long cpqfcTS_ReadNVRAM( void* G
 
   tl_i2c_tx_stop(GPIOin, GPIOout);
 
-  return( TRUE );
+  return TRUE;
 }
 
 //****************************************************************
@@ -354,7 +349,6 @@ static void tl_i2c_clock_pulse( UCHAR va
 
   i2c_delay(0);
 
-
   // read the port to preserve non-I2C bits
   ret_val = readl( GPIOout );
 
@@ -369,14 +363,10 @@ static void tl_i2c_clock_pulse( UCHAR va
 
   i2c_delay(0);
 
-
   //set clock bit
   tl_set_clock( GPIOout);
 }
 
-
-
-
 //*****************************************************************
 //
 //
@@ -397,18 +387,16 @@ int cpqfcTS_GetNVRAM_data( UCHAR *wwnbuf
   UCHAR  sub_name;
   UCHAR  done;
   int iReturn=0;  // def. 0 offset is failure to find WWN field
-  
-
-	  
+	
   data_ptr = (UCHAR *)buf;
 
   done = FALSE;
   i = 0;
 
-  while ( (i < 128) && (!done) ) 
+  while ( (i < 128) && (!done) )
   {
     z = data_ptr[i];\
-    if ( !(z & 0x80) )  
+    if ( !(z & 0x80) )
     {	
       len  = 1 + (z & 0x07);
 
@@ -416,12 +404,12 @@ int cpqfcTS_GetNVRAM_data( UCHAR *wwnbuf
       if (name == 0x0F)
         done = TRUE;
     }
-    else 
+    else
     {
       name = z & 0x7F;
       len  = 3 + data_ptr[i+1] + (data_ptr[i+2] << 8);
-           
-      switch (name) 
+
+      switch (name)
       {
       case 0x0D:
 	//
@@ -434,10 +422,10 @@ int cpqfcTS_GetNVRAM_data( UCHAR *wwnbuf
 
 	  while ( j<(i+len) ) {
 	    sub_name = (data_ptr[j] & 0x3f);
-	    sub_len  = data_ptr[j+1] + 
+	    sub_len  = data_ptr[j+1] +
 	               (data_ptr[j+2] << 8);
-            ptr_inc  = sub_len + 3; 
-	    switch (sub_name) 
+            ptr_inc  = sub_len + 3;
+	    switch (sub_name)
 	    {
 	    case 0x3C:
               memcpy( wwnbuf, &data_ptr[j+3], 8);
@@ -451,27 +439,23 @@ int cpqfcTS_GetNVRAM_data( UCHAR *wwnbuf
 	  break;
         default:
 	  break;
-      }  
-    }  
+      }
+    }
   //
     i += len;
-  }  // end while 
+  }  // end while
   return iReturn;
 }
 
-
-
-
-
 // define a short 5 micro sec delay, and longer (ms) delay
 
 static void i2c_delay(ULONG mstime)
 {
   ULONG i;
-  
+
 // NOTE: we only expect to use these delays when reading
 // our adapter's NVRAM, which happens only during adapter reset.
-// Delay technique from "Linux Device Drivers", A. Rubini 
+// Delay technique from "Linux Device Drivers", A. Rubini
 // (1st Ed.) pg 137.
 
 //  printk(" delay %lx  ", mstime);
@@ -483,11 +467,8 @@ static void i2c_delay(ULONG mstime)
 	
   }
   else  // 5 micro sec delay
-  
+
     udelay( 5 ); // micro secs
-  
+
 //  printk("done\n");
 }
-
-
-
--- a/drivers/scsi/cpqfcTSinit.c	2005-08-14 15:05:20.000000000 +0200
+++ b/drivers/scsi/cpqfcTSinit.c	2005-08-14 15:05:57.000000000 +0200
@@ -1,6 +1,6 @@
-/* Copyright(c) 2000, Compaq Computer Corporation 
- * Fibre Channel Host Bus Adapter 
- * 64-bit, 66MHz PCI 
+/* Copyright(c) 2000, Compaq Computer Corporation
+ * Fibre Channel Host Bus Adapter
+ * 64-bit, 66MHz PCI
  * Originally developed and tested on:
  * (front): [chip] Tachyon TS HPFC-5166A/1.2  L2C1090 ...
  *          SP# P225CXCBFIEL6T, Rev XC
@@ -24,15 +24,15 @@
  * QLogic CPQFCTS SCSI-FCP
  * Written by Erik H. Moe, ehm@cris.com
  * Copyright 1995, Erik H. Moe
- * Renamed and updated to 1.3.x by Michael Griffith <grif@cs.ucr.edu> 
+ * Renamed and updated to 1.3.x by Michael Griffith <grif@cs.ucr.edu>
  * Chris Loveland <cwl@iol.unh.edu> to support the isp2100 and isp2200
 */
 
 
-#include <linux/config.h>  
-#include <linux/interrupt.h>  
+#include <linux/config.h>
+#include <linux/interrupt.h>
 #include <linux/module.h>
-#include <linux/version.h> 
+#include <linux/version.h>
 #include <linux/blkdev.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
@@ -61,10 +61,10 @@
 MODULE_AUTHOR("Compaq Computer Corporation");
 MODULE_DESCRIPTION("Driver for Compaq 64-bit/66Mhz PCI Fibre Channel HBA v. 2.5.4");
 MODULE_LICENSE("GPL");
-  
+
 int cpqfcTS_TargetDeviceReset( Scsi_Device *ScsiDev, unsigned int reset_flags);
 
-// This struct was originally defined in 
+// This struct was originally defined in
 // /usr/src/linux/include/linux/proc_fs.h
 // since it's only partially implemented, we only use first
 // few fields...
@@ -86,91 +86,91 @@ static int cpqfc_alloc_private_data_pool
 */
 static void Cpqfc_initHBAdata(CPQFCHBA *cpqfcHBAdata, struct pci_dev *PciDev )
 {
-             
+
   cpqfcHBAdata->PciDev = PciDev; // copy PCI info ptr
 
   // since x86 port space is 64k, we only need the lower 16 bits
-  cpqfcHBAdata->fcChip.Registers.IOBaseL = 
+  cpqfcHBAdata->fcChip.Registers.IOBaseL =
     PciDev->resource[1].start & PCI_BASE_ADDRESS_IO_MASK;
-  
-  cpqfcHBAdata->fcChip.Registers.IOBaseU = 
+
+  cpqfcHBAdata->fcChip.Registers.IOBaseU =
     PciDev->resource[2].start & PCI_BASE_ADDRESS_IO_MASK;
-  
+
   // 32-bit memory addresses
-  cpqfcHBAdata->fcChip.Registers.MemBase = 
+  cpqfcHBAdata->fcChip.Registers.MemBase =
     PciDev->resource[3].start & PCI_BASE_ADDRESS_MEM_MASK;
 
-  cpqfcHBAdata->fcChip.Registers.ReMapMemBase = 
+  cpqfcHBAdata->fcChip.Registers.ReMapMemBase =
     ioremap( PciDev->resource[3].start & PCI_BASE_ADDRESS_MEM_MASK,
              0x200);
-  
-  cpqfcHBAdata->fcChip.Registers.RAMBase = 
+
+  cpqfcHBAdata->fcChip.Registers.RAMBase =
     PciDev->resource[4].start;
-  
+
   cpqfcHBAdata->fcChip.Registers.SROMBase =  // NULL for HP TS adapter
     PciDev->resource[5].start;
-  
+
   // now the Tachlite chip registers
   // the REGISTER struct holds both the physical address & last
   // written value (some TL registers are WRITE ONLY)
 
-  cpqfcHBAdata->fcChip.Registers.SFQconsumerIndex.address = 
+  cpqfcHBAdata->fcChip.Registers.SFQconsumerIndex.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_SFQ_CONSUMER_INDEX;
 
-  cpqfcHBAdata->fcChip.Registers.ERQproducerIndex.address = 
+  cpqfcHBAdata->fcChip.Registers.ERQproducerIndex.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_ERQ_PRODUCER_INDEX;
-      
+
   // TL Frame Manager
-  cpqfcHBAdata->fcChip.Registers.FMconfig.address = 
+  cpqfcHBAdata->fcChip.Registers.FMconfig.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_FM_CONFIG;
-  cpqfcHBAdata->fcChip.Registers.FMcontrol.address = 
+  cpqfcHBAdata->fcChip.Registers.FMcontrol.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_FM_CONTROL;
-  cpqfcHBAdata->fcChip.Registers.FMstatus.address = 
+  cpqfcHBAdata->fcChip.Registers.FMstatus.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_FM_STATUS;
-  cpqfcHBAdata->fcChip.Registers.FMLinkStatus1.address = 
+  cpqfcHBAdata->fcChip.Registers.FMLinkStatus1.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_FM_LINK_STAT1;
-  cpqfcHBAdata->fcChip.Registers.FMLinkStatus2.address = 
+  cpqfcHBAdata->fcChip.Registers.FMLinkStatus2.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_FM_LINK_STAT2;
-  cpqfcHBAdata->fcChip.Registers.FMBB_CreditZero.address = 
+  cpqfcHBAdata->fcChip.Registers.FMBB_CreditZero.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_FM_BB_CREDIT0;
-      
+
       // TL Control Regs
-  cpqfcHBAdata->fcChip.Registers.TYconfig.address = 
+  cpqfcHBAdata->fcChip.Registers.TYconfig.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_TACH_CONFIG;
-  cpqfcHBAdata->fcChip.Registers.TYcontrol.address = 
+  cpqfcHBAdata->fcChip.Registers.TYcontrol.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_TACH_CONTROL;
-  cpqfcHBAdata->fcChip.Registers.TYstatus.address = 
+  cpqfcHBAdata->fcChip.Registers.TYstatus.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_TACH_STATUS;
-  cpqfcHBAdata->fcChip.Registers.rcv_al_pa.address = 
+  cpqfcHBAdata->fcChip.Registers.rcv_al_pa.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_FM_RCV_AL_PA;
-  cpqfcHBAdata->fcChip.Registers.ed_tov.address = 
+  cpqfcHBAdata->fcChip.Registers.ed_tov.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + TL_MEM_FM_ED_TOV;
 
 
-  cpqfcHBAdata->fcChip.Registers.INTEN.address = 
+  cpqfcHBAdata->fcChip.Registers.INTEN.address =
 	        cpqfcHBAdata->fcChip.Registers.ReMapMemBase + IINTEN;
-  cpqfcHBAdata->fcChip.Registers.INTPEND.address = 
+  cpqfcHBAdata->fcChip.Registers.INTPEND.address =
 	        cpqfcHBAdata->fcChip.Registers.ReMapMemBase + IINTPEND;
-  cpqfcHBAdata->fcChip.Registers.INTSTAT.address = 
+  cpqfcHBAdata->fcChip.Registers.INTSTAT.address =
         cpqfcHBAdata->fcChip.Registers.ReMapMemBase + IINTSTAT;
 
   DEBUG_PCI(printk("  cpqfcHBAdata->fcChip.Registers. :\n"));
-  DEBUG_PCI(printk("    IOBaseL = %x\n", 
+  DEBUG_PCI(printk("    IOBaseL = %x\n",
     cpqfcHBAdata->fcChip.Registers.IOBaseL));
-  DEBUG_PCI(printk("    IOBaseU = %x\n", 
+  DEBUG_PCI(printk("    IOBaseU = %x\n",
     cpqfcHBAdata->fcChip.Registers.IOBaseU));
-  
+
   /* printk(" ioremap'd Membase: %p\n", cpqfcHBAdata->fcChip.Registers.ReMapMemBase); */
-  
-  DEBUG_PCI(printk("    SFQconsumerIndex.address = %p\n", 
+
+  DEBUG_PCI(printk("    SFQconsumerIndex.address = %p\n",
     cpqfcHBAdata->fcChip.Registers.SFQconsumerIndex.address));
-  DEBUG_PCI(printk("    ERQproducerIndex.address = %p\n", 
+  DEBUG_PCI(printk("    ERQproducerIndex.address = %p\n",
     cpqfcHBAdata->fcChip.Registers.ERQproducerIndex.address));
-  DEBUG_PCI(printk("    TYconfig.address = %p\n", 
+  DEBUG_PCI(printk("    TYconfig.address = %p\n",
     cpqfcHBAdata->fcChip.Registers.TYconfig.address));
-  DEBUG_PCI(printk("    FMconfig.address = %p\n", 
+  DEBUG_PCI(printk("    FMconfig.address = %p\n",
     cpqfcHBAdata->fcChip.Registers.FMconfig.address));
-  DEBUG_PCI(printk("    FMcontrol.address = %p\n", 
+  DEBUG_PCI(printk("    FMcontrol.address = %p\n",
     cpqfcHBAdata->fcChip.Registers.FMcontrol.address));
 
   // set default options for FC controller (chip)
@@ -190,15 +190,15 @@ static void Cpqfc_initHBAdata(CPQFCHBA *
   cpqfcHBAdata->fcChip.UnFreezeTachyon = CpqTsUnFreezeTachlite;
   cpqfcHBAdata->fcChip.CreateTachyonQues = CpqTsCreateTachLiteQues;
   cpqfcHBAdata->fcChip.DestroyTachyonQues = CpqTsDestroyTachLiteQues;
-  cpqfcHBAdata->fcChip.InitializeTachyon = CpqTsInitializeTachLite;  
-  cpqfcHBAdata->fcChip.LaserControl = CpqTsLaserControl;  
+  cpqfcHBAdata->fcChip.InitializeTachyon = CpqTsInitializeTachLite;
+  cpqfcHBAdata->fcChip.LaserControl = CpqTsLaserControl;
   cpqfcHBAdata->fcChip.ProcessIMQEntry = CpqTsProcessIMQEntry;
   cpqfcHBAdata->fcChip.InitializeFrameManager = CpqTsInitializeFrameManager;
   cpqfcHBAdata->fcChip.ReadWriteWWN = CpqTsReadWriteWWN;
   cpqfcHBAdata->fcChip.ReadWriteNVRAM = CpqTsReadWriteNVRAM;
 
       if (cpqfc_alloc_private_data_pool(cpqfcHBAdata) != 0) {
-		printk(KERN_WARNING 
+		printk(KERN_WARNING
 			"cpqfc: unable to allocate pool for passthru ioctls.  "
 			"Passthru ioctls disabled.\n");
       }
@@ -213,12 +213,12 @@ static void launch_FCworker_thread(struc
   CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
 
   ENTER("launch_FC_worker_thread");
-             
+
   cpqfcHBAdata->notify_wt = &sem;
 
   /* must unlock before kernel_thread(), for it may cause a reschedule. */
   spin_unlock_irq(HostAdapter->host_lock);
-  kernel_thread((int (*)(void *))cpqfcTSWorkerThread, 
+  kernel_thread((int (*)(void *))cpqfcTSWorkerThread,
                           (void *) HostAdapter, 0);
   /*
    * Now wait for the kernel error thread to initialize itself
@@ -229,16 +229,16 @@ static void launch_FCworker_thread(struc
   cpqfcHBAdata->notify_wt = NULL;
 
   LEAVE("launch_FC_worker_thread");
- 
+
 }
 
 
-/* "Entry" point to discover if any supported PCI 
+/* "Entry" point to discover if any supported PCI
    bus adapter can be found
 */
 /* We're supporting:
  * Compaq 64-bit, 66MHz HBA with Tachyon TS
- * Agilent XL2 
+ * Agilent XL2
  * HP Tachyon
  */
 static struct pci_device_id cpqfc_boards[] __initdata = {
@@ -255,7 +255,7 @@ int cpqfcTS_detect(Scsi_Host_Template *S
   int NumberOfAdapters=0; // how many of our PCI adapters are found?
   struct pci_dev *PciDev = NULL;
   struct Scsi_Host *HostAdapter = NULL;
-  CPQFCHBA *cpqfcHBAdata = NULL; 
+  CPQFCHBA *cpqfcHBAdata = NULL;
   struct timer_list *cpqfcTStimer = NULL;
   int i;
 
@@ -271,7 +271,7 @@ int cpqfcTS_detect(Scsi_Host_Template *S
       }
 
       if (pci_set_dma_mask(PciDev, CPQFCTS_DMA_MASK) != 0) {
-	printk(KERN_WARNING 
+	printk(KERN_WARNING
 		"cpqfc: HBA cannot support required DMA mask, skipping.\n");
 	goto err_disable_dev;
       }
@@ -281,7 +281,7 @@ int cpqfcTS_detect(Scsi_Host_Template *S
 		      (ULONG)sizeof(CPQFCHBA)); */
 
       HostAdapter = scsi_register( ScsiHostTemplate, sizeof( CPQFCHBA ) );
-      
+
       if(HostAdapter == NULL) {
 	printk(KERN_WARNING
 		"cpqfc: can't register SCSI HBA, skipping.\n");
@@ -289,34 +289,34 @@ int cpqfcTS_detect(Scsi_Host_Template *S
       }
       DEBUG_PCI( printk("  HBA found!\n"));
       DEBUG_PCI( printk("  HostAdapter->PciDev->irq = %u\n", PciDev->irq) );
-      DEBUG_PCI(printk("  PciDev->baseaddress[0]= %lx\n", 
+      DEBUG_PCI(printk("  PciDev->baseaddress[0]= %lx\n",
 				PciDev->resource[0].start));
-      DEBUG_PCI(printk("  PciDev->baseaddress[1]= %lx\n", 
+      DEBUG_PCI(printk("  PciDev->baseaddress[1]= %lx\n",
 				PciDev->resource[1].start));
-      DEBUG_PCI(printk("  PciDev->baseaddress[2]= %lx\n", 
+      DEBUG_PCI(printk("  PciDev->baseaddress[2]= %lx\n",
 				PciDev->resource[2].start));
-      DEBUG_PCI(printk("  PciDev->baseaddress[3]= %lx\n", 
+      DEBUG_PCI(printk("  PciDev->baseaddress[3]= %lx\n",
 				PciDev->resource[3].start));
 
       HostAdapter->irq = PciDev->irq;  // copy for Scsi layers
-      
+
       // HP Tachlite uses two (255-byte) ranges of Port I/O (lower & upper),
       // for a total I/O port address space of 512 bytes.
       // mask out the I/O port address (lower) & record
       HostAdapter->io_port = (unsigned int)
 	     PciDev->resource[1].start & PCI_BASE_ADDRESS_IO_MASK;
       HostAdapter->n_io_port = 0xff;
-      
+
       // i.e., expect 128 targets (arbitrary number), while the
       //  RA-4000 supports 32 LUNs
-      HostAdapter->max_id =  0;   // incremented as devices log in    
+      HostAdapter->max_id =  0;   // incremented as devices log in
       HostAdapter->max_lun = CPQFCTS_MAX_LUN;         // LUNs per FC device
       HostAdapter->max_channel = CPQFCTS_MAX_CHANNEL; // multiple busses?
-      
+
       // get the pointer to our HBA specific data... (one for
       // each HBA on the PCI bus(ses)).
       cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
-      
+
       // make certain our data struct is clear
       memset( cpqfcHBAdata, 0, sizeof( CPQFCHBA ) );
 
@@ -326,7 +326,7 @@ int cpqfcTS_detect(Scsi_Host_Template *S
 
       cpqfcHBAdata->HostAdapter = HostAdapter; // back ptr
       Cpqfc_initHBAdata( cpqfcHBAdata, PciDev ); // fill MOST fields
-     
+
       cpqfcHBAdata->HBAnum = NumberOfAdapters;
       spin_lock_init(&cpqfcHBAdata->hba_spinlock);
 
@@ -350,7 +350,7 @@ int cpqfcTS_detect(Scsi_Host_Template *S
 			cpqfcHBAdata->fcChip.Registers.IOBaseU);
 	goto err_free_irq;
       }	
-      
+
       if( !request_region( cpqfcHBAdata->fcChip.Registers.IOBaseL,
       			   0xff, DEV_NAME ) )
       {
@@ -358,15 +358,15 @@ int cpqfcTS_detect(Scsi_Host_Template *S
 	      			cpqfcHBAdata->fcChip.Registers.IOBaseL);
 	goto err_release_region_U;
       }	
-      
+
       // OK, we have grabbed everything we need now.
       DEBUG_PCI(printk("  Reserved 255 I/O addresses @ %x\n",
         cpqfcHBAdata->fcChip.Registers.IOBaseL ));
       DEBUG_PCI(printk("  Reserved 255 I/O addresses @ %x\n",
         cpqfcHBAdata->fcChip.Registers.IOBaseU ));
 
-     
- 
+
+
       // start our kernel worker thread
 
       spin_lock_irq(HostAdapter->host_lock);
@@ -392,7 +392,7 @@ int cpqfcTS_detect(Scsi_Host_Template *S
       }
 
       cpqfcHBAdata->fcStatsTime = jiffies;  // (for FC Statistics delta)
-      
+
       // give our HBA time to initialize and login current devices...
       {
 	// The Brocade switch (e.g. 2400, 2010, etc.) as of March 2000,
@@ -411,13 +411,13 @@ int cpqfcTS_detect(Scsi_Host_Template *S
 
 	spin_unlock_irq(HostAdapter->host_lock);
 	stop_time = jiffies + 4*HZ;
-        while ( time_before(jiffies, stop_time) ) 
+        while ( time_before(jiffies, stop_time) )
 	  	schedule();  // (our worker task needs to run)
 
       }
-      
+
       spin_lock_irq(HostAdapter->host_lock);
-      NumberOfAdapters++; 
+      NumberOfAdapters++;
       spin_unlock_irq(HostAdapter->host_lock);
 
       continue;
@@ -438,7 +438,7 @@ err_continue:
   }
 
   LEAVE("cpqfcTS_detect");
- 
+
   return NumberOfAdapters;
 }
 
@@ -446,22 +446,22 @@ err_continue:
 static void my_ioctl_done (Scsi_Cmnd * SCpnt)
 {
     struct request * req;
-    
+
     req = SCpnt->request;
     req->rq_status = RQ_SCSI_DONE; /* Busy, but indicate request done */
-  
+
     if (req->CPQFC_WAITING != NULL)
 	CPQFC_COMPLETE(req->CPQFC_WAITING);
-}   
+}
 #endif
 
 static int cpqfc_alloc_private_data_pool(CPQFCHBA *hba)
 {
 	hba->private_data_bits = NULL;
 	hba->private_data_pool = NULL;
-	hba->private_data_bits = 
+	hba->private_data_bits =
 		kmalloc(((CPQFC_MAX_PASSTHRU_CMDS+BITS_PER_LONG-1) /
-				BITS_PER_LONG)*sizeof(unsigned long), 
+				BITS_PER_LONG)*sizeof(unsigned long),
 				GFP_KERNEL);
 	if (hba->private_data_bits == NULL)
 		return -1;
@@ -496,10 +496,10 @@ int is_private_data_of_cpqfc(CPQFCHBA *h
 	   forged to be somewhere in our pool..., though they'd
 	   normally have to be root already to do this.  */
 
-	return (pointer != NULL && 
-		pointer >= (void *) hba->private_data_pool && 
-		pointer < (void *) hba->private_data_pool + 
-			sizeof(*hba->private_data_pool) * 
+	return (pointer != NULL &&
+		pointer >= (void *) hba->private_data_pool &&
+		pointer < (void *) hba->private_data_pool +
+			sizeof(*hba->private_data_pool) *
 				CPQFC_MAX_PASSTHRU_CMDS);
 }
 
@@ -508,11 +508,11 @@ cpqfc_passthru_private_t *cpqfc_alloc_pr
 	int i;
 
 	do {
-		i = find_first_zero_bit(hba->private_data_bits, 
+		i = find_first_zero_bit(hba->private_data_bits,
 			CPQFC_MAX_PASSTHRU_CMDS);
 		if (i == CPQFC_MAX_PASSTHRU_CMDS)
 			return NULL;
-	} while ( test_and_set_bit(i & (BITS_PER_LONG - 1), 
+	} while ( test_and_set_bit(i & (BITS_PER_LONG - 1),
 			hba->private_data_bits+(i/BITS_PER_LONG)) != 0);
 	return &hba->private_data_pool[i];
 }
@@ -521,7 +521,7 @@ void cpqfc_free_private_data(CPQFCHBA *h
 {
 	int i;
 	i = data - hba->private_data_pool;
-	clear_bit(i&(BITS_PER_LONG-1), 
+	clear_bit(i&(BITS_PER_LONG-1),
 			hba->private_data_bits+(i/BITS_PER_LONG));
 }
 
@@ -584,7 +584,7 @@ int cpqfcTS_ioctl( struct scsi_device *S
 		kfree(buf);
 		return -ENOMEM;
 	}
-	ScsiPassThruReq->upper_private_data = 
+	ScsiPassThruReq->upper_private_data =
 			cpqfc_alloc_private_data(cpqfcHBAdata);
 	if (ScsiPassThruReq->upper_private_data == NULL) {
 		kfree(buf);
@@ -594,22 +594,22 @@ int cpqfcTS_ioctl( struct scsi_device *S
 
 	if (vendor_cmd->rw_flag == VENDOR_WRITE_OPCODE) {
 		if (vendor_cmd->len) { // Need data from user?
-        		if (copy_from_user(buf, vendor_cmd->bufp, 
+        		if (copy_from_user(buf, vendor_cmd->bufp,
 						vendor_cmd->len)) {
 				kfree(buf);
-				cpqfc_free_private_data(cpqfcHBAdata, 
+				cpqfc_free_private_data(cpqfcHBAdata,
 					ScsiPassThruReq->upper_private_data);
 				scsi_release_request(ScsiPassThruReq);
 				return( -EFAULT);
 			}
 		}
-		ScsiPassThruReq->sr_data_direction = DMA_TO_DEVICE; 
+		ScsiPassThruReq->sr_data_direction = DMA_TO_DEVICE;
 	} else if (vendor_cmd->rw_flag == VENDOR_READ_OPCODE) {
 		ScsiPassThruReq->sr_data_direction = DMA_FROM_DEVICE;
 	} else
 		// maybe this means a bug in the user app
 		ScsiPassThruReq->sr_data_direction = DMA_BIDIRECTIONAL;
-	    
+	
 	ScsiPassThruReq->sr_cmd_len = 0; // set correctly by scsi_do_req()
 	ScsiPassThruReq->sr_sense_buffer[0] = 0;
 	ScsiPassThruReq->sr_sense_buffer[2] = 0;
@@ -625,8 +625,8 @@ int cpqfcTS_ioctl( struct scsi_device *S
 	privatedata->pdrive = vendor_cmd->pdrive;
 	
         // eventually gets us to our own _quecommand routine
-	scsi_wait_req(ScsiPassThruReq, 
-		&vendor_cmd->cdb[0], buf, vendor_cmd->len, 
+	scsi_wait_req(ScsiPassThruReq,
+		&vendor_cmd->cdb[0], buf, vendor_cmd->len,
 		10*HZ,  // timeout
 		1);	// retries
         result = ScsiPassThruReq->sr_result;
@@ -635,12 +635,12 @@ int cpqfcTS_ioctl( struct scsi_device *S
         if( result != 0 )
 	{
 	  memcpy( vendor_cmd->sense_data, // see struct def - size=40
-		  ScsiPassThruReq->sr_sense_buffer, 
+		  ScsiPassThruReq->sr_sense_buffer,
 		  sizeof(ScsiPassThruReq->sr_sense_buffer) <
                   sizeof(vendor_cmd->sense_data)           ?
                   sizeof(ScsiPassThruReq->sr_sense_buffer) :
                   sizeof(vendor_cmd->sense_data)
-                ); 
+                );
 	}
         SDpnt = ScsiPassThruReq->sr_device;
 	/* upper_private_data is already freed in call_scsi_done() */
@@ -653,12 +653,12 @@ int cpqfcTS_ioctl( struct scsi_device *S
         if(  copy_to_user( vendor_cmd->bufp, buf, vendor_cmd->len))
 		result = -EFAULT;
 
-        if( buf) 
+        if( buf)
 	  kfree( buf);
 
         return result;
       }
-      
+
       case CPQFCTS_GETPCIINFO:
       {
 	cpqfc_pci_info_struct pciinfo;
@@ -669,10 +669,10 @@ int cpqfcTS_ioctl( struct scsi_device *S
          	
 	
         pciinfo.bus = cpqfcHBAdata->PciDev->bus->number;
-        pciinfo.dev_fn = cpqfcHBAdata->PciDev->devfn;  
+        pciinfo.dev_fn = cpqfcHBAdata->PciDev->devfn;
 	pciinfo.board_id = cpqfcHBAdata->PciDev->device |
-			  (cpqfcHBAdata->PciDev->vendor <<16); 
-	      
+			  (cpqfcHBAdata->PciDev->vendor <<16);
+	
         if(copy_to_user( arg, &pciinfo, sizeof(cpqfc_pci_info_struct)))
 		return( -EFAULT);
         return 0;
@@ -680,7 +680,7 @@ int cpqfcTS_ioctl( struct scsi_device *S
 
       case CPQFCTS_GETDRIVVER:
       {
-	DriverVer_type DriverVer = 
+	DriverVer_type DriverVer =
 		CPQFCTS_DRIVER_VER( VER_MAJOR,VER_MINOR,VER_SUBMINOR);
 	
 	if( !arg)
@@ -715,21 +715,21 @@ int cpqfcTS_ioctl( struct scsi_device *S
 	}
 	result = access_ok(VERIFY_WRITE, arg, sizeof(Scsi_FCTargAddress)) ? 0 : -EFAULT;
 	if (result) break;
- 
+
       put_user(pLoggedInPort->port_id,
 		&((Scsi_FCTargAddress *) arg)->host_port_id);
- 
+
       for( i=3,j=0; i>=0; i--)   	// copy the LOGIN port's WWN
-        put_user(pLoggedInPort->u.ucWWN[i], 
+        put_user(pLoggedInPort->u.ucWWN[i],
 		&((Scsi_FCTargAddress *) arg)->host_wwn[j++]);
       for( i=7; i>3; i--)		// copy the LOGIN port's WWN
-        put_user(pLoggedInPort->u.ucWWN[i], 
+        put_user(pLoggedInPort->u.ucWWN[i],
 		&((Scsi_FCTargAddress *) arg)->host_wwn[j++]);
         break;
 
 
       case CPQFC_IOCTL_FC_TDR:
-          
+
         result = cpqfcTS_TargetDeviceReset( ScsiDev, 0);
 
         break;
@@ -753,14 +753,14 @@ int cpqfcTS_ioctl( struct scsi_device *S
 
 int cpqfcTS_release(struct Scsi_Host *HostAdapter)
 {
-  CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata; 
+  CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
 
 
   ENTER("cpqfcTS_release");
 	
   DEBUG_PCI( printk(" cpqfcTS: delete timer...\n"));
-  del_timer( &cpqfcHBAdata->cpqfcTStimer);  
-    
+  del_timer( &cpqfcHBAdata->cpqfcTStimer);
+
   // disable the hardware...
   DEBUG_PCI( printk(" disable hardware, destroy queues, free mem\n"));
   cpqfcHBAdata->fcChip.ResetTachyon( cpqfcHBAdata, CLEAR_FCPORTS);
@@ -775,7 +775,7 @@ int cpqfcTS_release(struct Scsi_Host *Ho
     send_sig( SIGKILL, cpqfcHBAdata->worker_thread, 1);
     down( &sem);
     cpqfcHBAdata->notify_wt = NULL;
-    
+
   }
 
   cpqfc_free_private_data_pool(cpqfcHBAdata);
@@ -785,7 +785,7 @@ int cpqfcTS_release(struct Scsi_Host *Ho
   scsi_unregister( HostAdapter);
   release_region( cpqfcHBAdata->fcChip.Registers.IOBaseL, 0xff);
   release_region( cpqfcHBAdata->fcChip.Registers.IOBaseU, 0xff);
- /* we get "vfree: bad address" executing this - need to investigate... 
+ /* we get "vfree: bad address" executing this - need to investigate...
   if( (void*)((unsigned long)cpqfcHBAdata->fcChip.Registers.MemBase) !=
       cpqfcHBAdata->fcChip.Registers.ReMapMemBase)
     vfree( cpqfcHBAdata->fcChip.Registers.ReMapMemBase);
@@ -802,8 +802,8 @@ const char * cpqfcTS_info(struct Scsi_Ho
   static char buf[300];
   CPQFCHBA *cpqfcHBA;
   int BusSpeed, BusWidth;
-  
-  // get the pointer to our Scsi layer HBA buffer  
+
+  // get the pointer to our Scsi layer HBA buffer
   cpqfcHBA = (CPQFCHBA *)HostAdapter->hostdata;
 
   BusWidth = (cpqfcHBA->fcChip.Registers.PCIMCTR &0x4) > 0 ?
@@ -814,13 +814,13 @@ const char * cpqfcTS_info(struct Scsi_Ho
   else
     BusSpeed = 33;
 
-  sprintf(buf, 
+  sprintf(buf,
 "%s: WWN %08X%08X\n on PCI bus %d device 0x%02x irq %d IObaseL 0x%x, MEMBASE 0x%x\nPCI bus width %d bits, bus speed %d MHz\nFCP-SCSI Driver v%d.%d.%d",
-      cpqfcHBA->fcChip.Name, 
+      cpqfcHBA->fcChip.Name,
       cpqfcHBA->fcChip.Registers.wwn_hi,
       cpqfcHBA->fcChip.Registers.wwn_lo,
       cpqfcHBA->PciDev->bus->number,
-      cpqfcHBA->PciDev->device,  
+      cpqfcHBA->PciDev->device,
       HostAdapter->irq,
       cpqfcHBA->fcChip.Registers.IOBaseL,
       cpqfcHBA->fcChip.Registers.MemBase,
@@ -829,7 +829,7 @@ const char * cpqfcTS_info(struct Scsi_Ho
       VER_MAJOR, VER_MINOR, VER_SUBMINOR
 );
 
-  
+
   cpqfcTSDecodeGBICtype( &cpqfcHBA->fcChip, &buf[ strlen(buf)]);
   cpqfcTSGetLPSM( &cpqfcHBA->fcChip, &buf[ strlen(buf)]);
   return buf;
@@ -839,16 +839,16 @@ const char * cpqfcTS_info(struct Scsi_Ho
 // /proc/scsi support. The following routines allow us to do 'normal'
 // sprintf like calls to return the currently requested piece (buflenght
 // chars, starting at bufoffset) of the file. Although procfs allows for
-// a 1 Kb bytes overflow after te supplied buffer, I consider it bad 
+// a 1 Kb bytes overflow after te supplied buffer, I consider it bad
 // programming to use it to make programming a little simpler. This piece
-// of coding is borrowed from ncr53c8xx.c with some modifications 
+// of coding is borrowed from ncr53c8xx.c with some modifications
 //
 struct info_str
 {
         char *buffer;			// Pointer to output buffer
         int buflength;			// It's length
         int bufoffset;			// File offset corresponding with buf[0]
-	int buffillen;			// Current filled length 
+	int buffillen;			// Current filled length
         int filpos;			// Current file offset
 };
 
@@ -895,7 +895,7 @@ static int copy_info(struct info_str *in
 
 // Routine to get data for /proc RAM filesystem
 //
-int cpqfcTS_proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, 
+int cpqfcTS_proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length,
 		       int inout)
 {
   struct scsi_cmnd *DumCmnd;
@@ -909,10 +909,10 @@ int cpqfcTS_proc_info (struct Scsi_Host 
 
   if (inout) return -EINVAL;
 
-  // get the pointer to our Scsi layer HBA buffer  
+  // get the pointer to our Scsi layer HBA buffer
   cpqfcHBA = (CPQFCHBA *)host->hostdata;
   fcChip = &cpqfcHBA->fcChip;
-  
+
   *start 	  = buffer;
 
   info.buffer     = buffer;
@@ -920,15 +920,15 @@ int cpqfcTS_proc_info (struct Scsi_Host 
   info.bufoffset  = offset;
   info.filpos     = 0;
   info.buffillen  = 0;
-  copy_info(&info, "Driver version = %d.%d.%d", VER_MAJOR, VER_MINOR, VER_SUBMINOR); 
+  copy_info(&info, "Driver version = %d.%d.%d", VER_MAJOR, VER_MINOR, VER_SUBMINOR);
   cpqfcTSDecodeGBICtype( &cpqfcHBA->fcChip, &buf[0]);
   cpqfcTSGetLPSM( &cpqfcHBA->fcChip, &buf[ strlen(buf)]);
-  copy_info(&info, "%s\n", buf); 
+  copy_info(&info, "%s\n", buf);
 
 #define DISPLAY_WWN_INFO
 #ifdef DISPLAY_WWN_INFO
   ScsiDev = scsi_get_host_dev (host);
-  if (!ScsiDev) 
+  if (!ScsiDev)
     return -ENOMEM;
   DumCmnd = scsi_get_command (ScsiDev, GFP_KERNEL);
   if (!DumCmnd) {
@@ -951,7 +951,7 @@ int cpqfcTS_proc_info (struct Scsi_Host 
           copy_info(&info, "%02X", pLoggedInPort->u.ucWWN[i]);
         for( i=7; i>3; i--)             // copy the LOGIN port's WWN
           copy_info(&info, "%02X", pLoggedInPort->u.ucWWN[i]);
-	copy_info(&info, " port_id: %06X\n", pLoggedInPort->port_id); 
+	copy_info(&info, " port_id: %06X\n", pLoggedInPort->port_id);
       }
     }
   }
@@ -962,18 +962,18 @@ int cpqfcTS_proc_info (struct Scsi_Host 
 
 
 
-  
-  
+
+
 // Unfortunately, the proc_info buffer isn't big enough
 // for everything we would like...
-// For FC stats, compile this and turn off WWN stuff above  
+// For FC stats, compile this and turn off WWN stuff above
 //#define DISPLAY_FC_STATS
 #ifdef DISPLAY_FC_STATS
 // get the Fibre Channel statistics
   {
     int DeltaSecs = (jiffies - cpqfcHBA->fcStatsTime) / HZ;
     int days,hours,minutes,secs;
-    
+
     days = DeltaSecs / (3600*24); // days
     hours = (DeltaSecs% (3600*24)) / 3600; // hours
     minutes = (DeltaSecs%3600 /60); // minutes
@@ -981,21 +981,21 @@ int cpqfcTS_proc_info (struct Scsi_Host 
 copy_info( &info, "Fibre Channel Stats (time dd:hh:mm:ss %02u:%02u:%02u:%02u\n",
       days, hours, minutes, secs);
   }
-    
+
   cpqfcHBA->fcStatsTime = jiffies;  // (for next delta)
 
   copy_info( &info, "  LinkUp           %9u     LinkDown      %u\n",
         fcChip->fcStats.linkUp, fcChip->fcStats.linkDown);
-        
+
   copy_info( &info, "  Loss of Signal   %9u     Loss of Sync  %u\n",
     fcChip->fcStats.LossofSignal, fcChip->fcStats.LossofSync);
-		  
+		
   copy_info( &info, "  Discarded Frames %9u     Bad CRC Frame %u\n",
     fcChip->fcStats.Dis_Frm, fcChip->fcStats.Bad_CRC);
 
   copy_info( &info, "  TACH LinkFailTX  %9u     TACH LinkFailRX     %u\n",
     fcChip->fcStats.linkFailTX, fcChip->fcStats.linkFailRX);
-  
+
   copy_info( &info, "  TACH RxEOFa      %9u     TACH Elastic Store  %u\n",
     fcChip->fcStats.Rx_EOFa, fcChip->fcStats.e_stores);
 
@@ -1003,11 +1003,11 @@ copy_info( &info, "Fibre Channel Stats (
     fcChip->fcStats.BB0_Timer*10, fcChip->fcStats.FMinits );
 	
   copy_info( &info, "  FC-2 Timeouts    %9u     FC-2 Logouts  %u\n",
-    fcChip->fcStats.timeouts, fcChip->fcStats.logouts); 
-        
+    fcChip->fcStats.timeouts, fcChip->fcStats.logouts);
+
   copy_info( &info, "  FC-2 Aborts      %9u     FC-4 Aborts   %u\n",
     fcChip->fcStats.FC2aborted, fcChip->fcStats.FC4aborted);
-   
+
   // clear the counters
   cpqfcTSClearLinkStatusCounters( fcChip);
 #endif
@@ -1172,7 +1172,7 @@ Original code from M. McGowen, Compaq
 void cpqfcTS_print_scsi_cmd(Scsi_Cmnd * cmd)
 {
 
-printk("cpqfcTS: (%s) chnl 0x%02x, trgt = 0x%02x, lun = 0x%02x, cmd_len = 0x%02x\n", 
+printk("cpqfcTS: (%s) chnl 0x%02x, trgt = 0x%02x, lun = 0x%02x, cmd_len = 0x%02x\n",
     ScsiToAscii( cmd->cmnd[0]), cmd->channel, cmd->target, cmd->lun, cmd->cmd_len);
 
 if( cmd->cmnd[0] == 0)   // Test Unit Ready?
@@ -1248,7 +1248,7 @@ static void QueLinkDownCmnd( CPQFCHBA *c
 
 // The file <scsi/scsi_host.h> says not to call scsi_done from
 // inside _queuecommand, so we'll do it from the heartbeat timer
-// (clarification: Turns out it's ok to call scsi_done from queuecommand 
+// (clarification: Turns out it's ok to call scsi_done from queuecommand
 // for cases that don't go to the hardware like scsi cmds destined
 // for LUNs we know don't exist, so this code might be simplified...)
 
@@ -1278,7 +1278,7 @@ int cpqfcTS_queuecommand(Scsi_Cmnd *Cmnd
   struct Scsi_Host *HostAdapter = Cmnd->device->host;
   CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
   PTACHYON fcChip = &cpqfcHBAdata->fcChip;
-  TachFCHDR_GCMND fchs;  // only use for FC destination id field  
+  TachFCHDR_GCMND fchs;  // only use for FC destination id field
   PFC_LOGGEDIN_PORT pLoggedInPort;
   ULONG ulStatus, SESTtype;
   LONG ExchangeID;
@@ -1287,23 +1287,23 @@ int cpqfcTS_queuecommand(Scsi_Cmnd *Cmnd
 
 
   ENTER("cpqfcTS_queuecommand");
-      
+
   PCI_TRACEO( (ULONG)Cmnd, 0x98)
-      
-  
+
+
   Cmnd->scsi_done = done;
-#ifdef DEBUG_CMND  
+#ifdef DEBUG_CMND
   cpqfcTS_print_scsi_cmd( Cmnd);
 #endif
 
-  // prevent board contention with kernel thread...  
-  
+  // prevent board contention with kernel thread...
+
    if( cpqfcHBAdata->BoardLock )
   {
 //    printk(" @BrdLck Hld@ ");
     QueCmndOnBoardLock( cpqfcHBAdata, Cmnd);
   }
-  
+
   else
   {
 
@@ -1312,20 +1312,20 @@ int cpqfcTS_queuecommand(Scsi_Cmnd *Cmnd
     // we might have something pending in the LinkQ, which
     // might cause the WorkerTask to run.  In case that
     // happens, make sure we lock it out.
-    
-    
-    
-    PCI_TRACE( 0x98) 
+
+
+
+    PCI_TRACE( 0x98)
     CPQ_SPINLOCK_HBA( cpqfcHBAdata)
-    PCI_TRACE( 0x98) 
-	    
+    PCI_TRACE( 0x98)
+	
   // can we find an FC device mapping to this SCSI target?
     pLoggedInPort = fcFindLoggedInPort( fcChip,
       Cmnd,     // search Scsi Nexus
       0,        // DON'T search linked list for FC port id
       NULL,     // DON'T search linked list for FC WWN
       NULL);    // DON'T care about end of list
- 
+
     if( pLoggedInPort == NULL )      // not found!
     {
 //    printk(" @Q bad targ cmnd %p@ ", Cmnd);
@@ -1335,7 +1335,7 @@ int cpqfcTS_queuecommand(Scsi_Cmnd *Cmnd
     {
       printk(KERN_WARNING "cpqfc: Invalid LUN: %d\n", Cmnd->device->lun);
       QueBadTargetCmnd( cpqfcHBAdata, Cmnd);
-    } 
+    }
 
     else  // we know what FC device to send to...
     {
@@ -1352,7 +1352,7 @@ int cpqfcTS_queuecommand(Scsi_Cmnd *Cmnd
 
     // In this case (previous login OK), the device is temporarily
     // unavailable waiting for re-login, in which case we expect it
-    // to be back in between 25 - 500ms.  
+    // to be back in between 25 - 500ms.
     // If the FC port doesn't log back in within several seconds
     // (i.e. implicit "logout"), or we get an explicit logout,
     // we set "device_blocked" in Scsi_Device struct; in this
@@ -1376,15 +1376,15 @@ int cpqfcTS_queuecommand(Scsi_Cmnd *Cmnd
 
         if( Cmnd->cmnd[0] == WRITE_10 ||
   	  Cmnd->cmnd[0] == WRITE_6 ||
-	  Cmnd->cmnd[0] == WRITE_BUFFER ||      
-	  Cmnd->cmnd[0] == VENDOR_WRITE_OPCODE ||  // CPQ specific 
+	  Cmnd->cmnd[0] == WRITE_BUFFER ||
+	  Cmnd->cmnd[0] == VENDOR_WRITE_OPCODE ||  // CPQ specific
 	  Cmnd->cmnd[0] == MODE_SELECT )
         {
           SESTtype = SCSI_IWE; // data from HBA to Device
         }
         else
           SESTtype = SCSI_IRE; // data from Device to HBA
-    	  
+    	
         ulStatus = cpqfcTSBuildExchange(
           cpqfcHBAdata,
           SESTtype,     // e.g. Initiator Read Entry (IRE)
@@ -1393,7 +1393,7 @@ int cpqfcTS_queuecommand(Scsi_Cmnd *Cmnd
           &ExchangeID );// fcController->fcExchanges index, -1 if failed
 
         if( !ulStatus ) // Exchange setup?
-   
+
         {
           if( cpqfcHBAdata->BoardLock )
           {
@@ -1404,7 +1404,7 @@ int cpqfcTS_queuecommand(Scsi_Cmnd *Cmnd
 	  ulStatus = cpqfcTSStartExchange( cpqfcHBAdata, ExchangeID );
 	  if( !ulStatus )
           {
-            PCI_TRACEO( ExchangeID, 0xB8) 
+            PCI_TRACEO( ExchangeID, 0xB8)
           // submitted to Tach's Outbound Que (ERQ PI incremented)
           // waited for completion for ELS type (Login frames issued
           // synchronously)
@@ -1416,7 +1416,7 @@ int cpqfcTS_queuecommand(Scsi_Cmnd *Cmnd
             printk("quecommand: cpqfcTSStartExchange failed: %Xh\n", ulStatus );
           }
         }            // end good BuildExchange status
-        
+
         else  // SEST table probably full  -- why? hardware hang?
         {
 	  printk("quecommand: cpqfcTSBuildExchange faild: %Xh\n", ulStatus);
@@ -1427,10 +1427,10 @@ int cpqfcTS_queuecommand(Scsi_Cmnd *Cmnd
     CPQ_SPINUNLOCK_HBA( cpqfcHBAdata)
   }
 	
-  PCI_TRACEO( (ULONG)Cmnd, 0x9C) 
+  PCI_TRACEO( (ULONG)Cmnd, 0x9C)
   LEAVE("cpqfcTS_queuecommand");
   return 0;
-}    
+}
 
 
 // Entry point for upper Scsi layer intiated abort.  Typically
@@ -1449,12 +1449,12 @@ int cpqfcTS_abort(Scsi_Cmnd *Cmnd)
 //	printk(" cpqfcTS_abort called?? \n");
  	return 0;
 }
- 
+
 int cpqfcTS_eh_abort(Scsi_Cmnd *Cmnd)
 {
 
   struct Scsi_Host *HostAdapter = Cmnd->device->host;
-  // get the pointer to our Scsi layer HBA buffer  
+  // get the pointer to our Scsi layer HBA buffer
   CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
   PTACHYON fcChip = &cpqfcHBAdata->fcChip;
   FC_EXCHANGES *Exchanges = fcChip->Exchanges;
@@ -1481,15 +1481,15 @@ int cpqfcTS_eh_abort(Scsi_Cmnd *Cmnd)
   {
     if( Exchanges->fcExchange[i].Cmnd == Cmnd )
     {
-      
+
       // found it!
       printk(" x_ID %Xh, type %Xh\n", i, Exchanges->fcExchange[i].type);
 
       Exchanges->fcExchange[i].status = INITIATOR_ABORT; // seconds default
       Exchanges->fcExchange[i].timeOut = 10; // seconds default (changed later)
 
-      // Since we need to immediately return the aborted Cmnd to Scsi 
-      // upper layers, we can't make future reference to any of its 
+      // Since we need to immediately return the aborted Cmnd to Scsi
+      // upper layers, we can't make future reference to any of its
       // fields (e.g the Nexus).
 
       cpqfcTSPutLinkQue( cpqfcHBAdata, BLS_ABTS, &i);
@@ -1502,10 +1502,10 @@ int cpqfcTS_eh_abort(Scsi_Cmnd *Cmnd)
   {
     // now search our non-SEST buffers (i.e. Cmnd waiting to
     // start on the HBA or waiting to complete with error for retry).
-    
+
     // first check BadTargetCmnd
     for( i=0; i< CPQFCTS_MAX_TARGET_ID; i++)
-    { 
+    {
       if( cpqfcHBAdata->BadTargetCmnd[i] == Cmnd )
       {
         cpqfcHBAdata->BadTargetCmnd[i] = NULL;
@@ -1518,7 +1518,7 @@ int cpqfcTS_eh_abort(Scsi_Cmnd *Cmnd)
 
     for( i=0; i < CPQFCTS_REQ_QUEUE_LEN; i++)
     {
-      if( cpqfcHBAdata->LinkDnCmnd[i] == Cmnd ) 
+      if( cpqfcHBAdata->LinkDnCmnd[i] == Cmnd )
       {
 	cpqfcHBAdata->LinkDnCmnd[i] = NULL;
 	printk("in LinkDnCmnd Q\n");
@@ -1536,18 +1536,18 @@ int cpqfcTS_eh_abort(Scsi_Cmnd *Cmnd)
 	goto Done;
       }
     }
-    
+
     Cmnd->result = DID_ERROR <<16;  // Hmmm...
     printk("Not found! ");
 //    panic("_abort");
   }
-  
+
 Done:
-  
+
 //    panic("_abort");
   LEAVE("cpqfcTS_eh_abort");
   return 0;  // (see scsi.h)
-}    
+}
 
 
 // FCP-SCSI Target Device Reset
@@ -1556,7 +1556,7 @@ Done:
 
 #ifdef SUPPORT_RESET
 
-int cpqfcTS_TargetDeviceReset( Scsi_Device *ScsiDev, 
+int cpqfcTS_TargetDeviceReset( Scsi_Device *ScsiDev,
                                unsigned int reset_flags)
 {
   int timeout = 10*HZ;
@@ -1566,9 +1566,9 @@ int cpqfcTS_TargetDeviceReset( Scsi_Devi
   Scsi_Cmnd * SCpnt;
   Scsi_Device * SDpnt;
 
-// FIXME, cpqfcTS_TargetDeviceReset needs to be fixed 
-// similarly to how the passthrough ioctl was fixed 
-// around the 2.5.30 kernel.  Scsi_Cmnd replaced with 
+// FIXME, cpqfcTS_TargetDeviceReset needs to be fixed
+// similarly to how the passthrough ioctl was fixed
+// around the 2.5.30 kernel.  Scsi_Cmnd replaced with
 // Scsi_Request, etc.
 // For now, so people don't fall into a hole...
 
@@ -1583,7 +1583,7 @@ int cpqfcTS_TargetDeviceReset( Scsi_Devi
   SCpnt = scsi_get_command(ScsiDev, GFP_KERNEL);
   {
     CPQFC_DECLARE_COMPLETION(wait);
-    
+
     SCpnt->SCp.buffers_residual = FCP_TARGET_RESET;
 
 	// FIXME: this would panic, SCpnt->request would be NULL.
@@ -1592,7 +1592,7 @@ int cpqfcTS_TargetDeviceReset( Scsi_Devi
 	CPQFC_WAIT_FOR_COMPLETION(&wait);
 	SCpnt->request->CPQFC_WAITING = NULL;
   }
-    
+
 
       if(driver_byte(SCpnt->result) != 0)
 	  switch(SCpnt->sense_buffer[2] & 0xf) {
@@ -1600,7 +1600,7 @@ int cpqfcTS_TargetDeviceReset( Scsi_Devi
 	    if(cmd[0] == ALLOW_MEDIUM_REMOVAL) dev->lockable = 0;
 	    else printk("SCSI device (ioctl) reports ILLEGAL REQUEST.\n");
 	    break;
-	case NOT_READY: // This happens if there is no disc in drive 
+	case NOT_READY: // This happens if there is no disc in drive
 	    if(dev->removable && (cmd[0] != TEST_UNIT_READY)){
 		printk(KERN_INFO "Device not ready.  Make sure there is a disc in the drive.\n");
 		break;
@@ -1609,8 +1609,8 @@ int cpqfcTS_TargetDeviceReset( Scsi_Devi
 	    if (dev->removable){
 		dev->changed = 1;
 		SCpnt->result = 0; // This is no longer considered an error
-		// gag this error, VFS will log it anyway /axboe 
-		// printk(KERN_INFO "Disc change detected.\n"); 
+		// gag this error, VFS will log it anyway /axboe
+		// printk(KERN_INFO "Disc change detected.\n");
 		break;
 	    };
 	default: // Fall through for non-removable media
@@ -1623,7 +1623,7 @@ int cpqfcTS_TargetDeviceReset( Scsi_Devi
 		   sense_class(SCpnt->sense_buffer[0]),
 		   sense_error(SCpnt->sense_buffer[0]),
 		   SCpnt->sense_buffer[2] & 0xf);
-	    
+	
       };
   result = SCpnt->result;
 
@@ -1636,7 +1636,7 @@ int cpqfcTS_TargetDeviceReset( Scsi_Devi
 }
 
 #else
-int cpqfcTS_TargetDeviceReset( Scsi_Device *ScsiDev, 
+int cpqfcTS_TargetDeviceReset( Scsi_Device *ScsiDev,
                                unsigned int reset_flags)
 {
 	return -ENOTSUPP;
@@ -1666,12 +1666,12 @@ int cpqfcTS_biosparam(struct scsi_device
 		sector_t capacity, int ip[])
 {
   int size = capacity;
-  
+
   ENTER("cpqfcTS_biosparam");
   ip[0] = 64;
   ip[1] = 32;
   ip[2] = size >> 11;
-  
+
   if( ip[2] > 1024 )
   {
     ip[0] = 255;
@@ -1681,12 +1681,12 @@ int cpqfcTS_biosparam(struct scsi_device
 
   LEAVE("cpqfcTS_biosparam");
   return 0;
-}    
+}
 
 
 
-irqreturn_t cpqfcTS_intr_handler( int irq, 
-		void *dev_id, 
+irqreturn_t cpqfcTS_intr_handler( int irq,
+		void *dev_id,
 		struct pt_regs *regs)
 {
 
@@ -1713,7 +1713,7 @@ irqreturn_t cpqfcTS_intr_handler( int ir
 
     if( IntPending & 0x4) // "INT" - Tach wrote to IMQ
     {
-      while( (++InfLoopBrk < INFINITE_IMQ_BREAK) && (MoreMessages ==1) ) 
+      while( (++InfLoopBrk < INFINITE_IMQ_BREAK) && (MoreMessages ==1) )
       {
         MoreMessages = CpqTsProcessIMQEntry( HostAdapter); // ret 0 when done
       }
@@ -1725,7 +1725,7 @@ irqreturn_t cpqfcTS_intr_handler( int ir
 
       else  // working normally - re-enable INTs and continue
         writeb( 0x1F, cpqfcHBA->fcChip.Registers.INTEN.address);
-    
+
     }  // (...ProcessIMQEntry() clears INT by writing IMQ consumer)
     else  // indications of errors or problems...
           // these usually indicate critical system hardware problems.
@@ -1753,11 +1753,11 @@ irqreturn_t cpqfcTS_intr_handler( int ir
 		if (pcistat & 0x0800) printk("Signalled Target Abort\n");
 	}
 	if (IntStat & 0x4) printk("(INT)\n");
-	if (IntStat & 0x8) 
+	if (IntStat & 0x8)
 		printk("CRS: PCI master address crossed 46 bit bouandary\n");
 	if (IntStat & 0x10) printk("MRE: external memory parity error.\n");
       }
-    }      
+    }
   }
   spin_unlock_irqrestore( HostAdapter->host_lock, flags);
   LEAVE("intr_handler");
@@ -1774,22 +1774,22 @@ int cpqfcTSDecodeGBICtype( PTACHYON fcCh
         // GPIO1, GPIO0, GPIO4 for MD2, MD1, MD0.  The input states appear
         // to be inverted -- i.e., a setting of 111 is read when there is NO
         // GBIC present.  The Module Def (MD) spec says 000 is "no GBIC"
-        // Hard code the bit states to detect Copper, 
+        // Hard code the bit states to detect Copper,
         // Long wave (single mode), Short wave (multi-mode), and absent GBIC
 
   ULONG ulBuff;
 
   sprintf( cErrorString, "\nGBIC detected: ");
 
-  ulBuff = fcChip->Registers.TYstatus.value & 0x13; 
+  ulBuff = fcChip->Registers.TYstatus.value & 0x13;
   switch( ulBuff )
   {
   case 0x13:  // GPIO4, GPIO1, GPIO0 = 111; no GBIC!
     sprintf( &cErrorString[ strlen( cErrorString)],
             "NONE! ");
-    return FALSE;          
-          
-       
+    return FALSE;
+
+
   case 0x11:   // Copper GBIC detected
     sprintf( &cErrorString[ strlen( cErrorString)],
             "Copper. ");
@@ -1806,7 +1806,7 @@ int cpqfcTSDecodeGBICtype( PTACHYON fcCh
   default:     // unknown GBIC - presumably it will work (?)
     sprintf( &cErrorString[ strlen( cErrorString)],
             "Unknown. ");
-          
+
     break;
   }  // end switch GBIC detection
 
@@ -1826,13 +1826,13 @@ int cpqfcTSGetLPSM( PTACHYON fcChip, cha
 
   int LinkUp;
 
-  if( fcChip->Registers.FMstatus.value & 0x80 ) 
+  if( fcChip->Registers.FMstatus.value & 0x80 )
     LinkUp = FALSE;
   else
     LinkUp = TRUE;
 
   sprintf( &cErrorString[ strlen( cErrorString)],
-    " LPSM %Xh ", 
+    " LPSM %Xh ",
      (fcChip->Registers.FMstatus.value >>4) & 0xf );
 
 
@@ -1940,7 +1940,7 @@ int cpqfcTSGetLPSM( PTACHYON fcChip, cha
 // we need about 8 allocations per HBA.  Figuring at most 10 HBAs per server
 // size the dynamic_mem array at 80.
 
-void* fcMemManager( struct pci_dev *pdev, ALIGNED_MEM *dynamic_mem, 
+void* fcMemManager( struct pci_dev *pdev, ALIGNED_MEM *dynamic_mem,
 		   ULONG n_alloc, ULONG ab, ULONG u32_AlignedAddress,
 			dma_addr_t *dma_handle)
 {
@@ -1964,8 +1964,8 @@ void* fcMemManager( struct pci_dev *pdev
       if( dynamic_mem[i].AlignedAddress == u32_AlignedAddress )
       {
         alloc_address = dynamic_mem[i].BaseAllocated; // 'success' status
-	pci_free_consistent(pdev,dynamic_mem[i].size, 
-				alloc_address, 
+	pci_free_consistent(pdev,dynamic_mem[i].size,
+				alloc_address,
 				dynamic_mem[i].dma_handle);
         dynamic_mem[i].BaseAllocated = 0;   // clear for next use
         dynamic_mem[i].AlignedAddress = 0;
@@ -1980,9 +1980,9 @@ void* fcMemManager( struct pci_dev *pdev
     t_alloc = n_alloc + (ab - allocBoundary); // pad bytes for alignment
 //    printk("pci_alloc_consistent() for Tach alignment: %ld bytes\n", t_alloc);
 
-// (would like to) allow thread block to free pages 
+// (would like to) allow thread block to free pages
     alloc_address =                  // total bytes (NumberOfBytes)
-      pci_alloc_consistent(pdev, t_alloc, &handle); 
+      pci_alloc_consistent(pdev, t_alloc, &handle);
 
                                   // now mask off least sig. bits of address
     if( alloc_address )           // (only if non-NULL)
@@ -1998,11 +1998,11 @@ void* fcMemManager( struct pci_dev *pdev
         {
           dynamic_mem[i].BaseAllocated = alloc_address;// address from O/S
           dynamic_mem[i].dma_handle = handle;
-	  if (dma_handle != NULL) 
+	  if (dma_handle != NULL)
 	  {
-//             printk("handle = %p, ab=%d, boundary = %d, mask=0x%08x\n", 
+//             printk("handle = %p, ab=%d, boundary = %d, mask=0x%08x\n",
 //			handle, ab, allocBoundary, mask);
-	    *dma_handle = (dma_addr_t) 
+	    *dma_handle = (dma_addr_t)
 		((((ULONG)handle) + (ab - allocBoundary)) & mask);
 	  }
           dynamic_mem[i].size = t_alloc;
@@ -2010,12 +2010,12 @@ void* fcMemManager( struct pci_dev *pdev
         }
       }
       ulAddress = (unsigned long)alloc_address;
-      
+
       ulAddress += (ab - allocBoundary);    // add the alignment bytes-
                                             // then truncate address...
       alloc_address = (void*)(ulAddress & mask);
-      
-      dynamic_mem[i].AlignedAddress = 
+
+      dynamic_mem[i].AlignedAddress =
 	(ULONG)(ulAddress & mask); // 32bit Tach address
       memset( alloc_address, 0, n_alloc );  // clear new memory
     }
@@ -2038,11 +2038,11 @@ static Scsi_Host_Template driver_templat
 	.ioctl                  = cpqfcTS_ioctl,
 	.queuecommand           = cpqfcTS_queuecommand,
 	.eh_device_reset_handler   = cpqfcTS_eh_device_reset,
-	.eh_abort_handler       = cpqfcTS_eh_abort, 
-	.bios_param             = cpqfcTS_biosparam, 
+	.eh_abort_handler       = cpqfcTS_eh_abort,
+	.bios_param             = cpqfcTS_biosparam,
 	.can_queue              = CPQFCTS_REQ_QUEUE_LEN,
-	.this_id                = -1, 
-	.sg_tablesize           = SG_ALL, 
+	.this_id                = -1,
+	.sg_tablesize           = SG_ALL,
 	.cmd_per_lun            = CPQFCTS_CMD_PER_LUN,
 	.use_clustering         = ENABLE_CLUSTERING,
 };

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] remove superfluos ioctls from cpqfcTS
  2005-08-16  9:13         ` [PATCH 2.6.13-rc6] more whitespace cleanups for cpqfcTS Rolf Eike Beer
@ 2005-08-16  9:14           ` Rolf Eike Beer
  2005-08-16 14:58             ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver Rolf Eike Beer
  0 siblings, 1 reply; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16  9:14 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds,
	Bolke de Bruin

Remove ioctls to get PCI information and driver version. These information 
can be found via lspci or dmesg. Also remove two typedefs already commented 
out.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

--- a/drivers/scsi/cpqfcTSioctl.h	2005-08-07 20:18:56.000000000 +0200
+++ b/drivers/scsi/cpqfcTSioctl.h	2005-08-14 16:39:04.000000000 +0200
@@ -4,47 +4,6 @@
 
 #define CCPQFCTS_IOC_MAGIC 'Z'
 
-typedef struct 
-{
-  __u8 bus;
-  __u8 dev_fn;
-  __u32 board_id;
-} cpqfc_pci_info_struct;
-
-typedef __u32 DriverVer_type;
-/*
-typedef union
-{
-  struct  // Peripheral Unit Device
-  { 
-    __u8 Bus:6;
-    __u8 Mode:2;  // b00
-    __u8 Dev;
-  } PeripDev;
-  struct  // Volume Set Address
-  { 
-    __u8 DevMSB:6;
-    __u8 Mode:2;  // b01
-    __u8 DevLSB;
-  } LogDev;
-  struct  // Logical Unit Device (SCSI-3, SCC-2 defined)
-  { 
-    __u8 Targ:6;
-    __u8 Mode:2;  // b10
-    __u8 Dev:5;
-    __u8 Bus:3;
-
-  } LogUnit;
-} SCSI3Addr_struct;
-
-
-typedef struct
-{
-  SCSI3Addr_struct FCP_Nexus;
-  __u8 cdb[16];
-} PassThru_Command_struct;
-*/
-
 /* this is nearly duplicated in idashare.h */
 typedef struct {
   int	lc;    		/* Controller number */
@@ -73,9 +32,6 @@
 #define VENDOR_READ_OPCODE			0x26
 #define VENDOR_WRITE_OPCODE			0x27
 
-#define CPQFCTS_GETPCIINFO _IOR( CCPQFCTS_IOC_MAGIC, 1, cpqfc_pci_info_struct)
-#define CPQFCTS_GETDRIVVER _IOR( CCPQFCTS_IOC_MAGIC, 9, DriverVer_type)
-
 #define CPQFCTS_SCSI_PASSTHRU _IOWR( CCPQFCTS_IOC_MAGIC,11, VENDOR_IOCTL_REQ)
 
 /* We would rather have equivalent generic, low-level driver agnostic 
@@ -91,4 +47,3 @@
 /* Used to invoke Target Defice Reset for Fibre Channel */
 // #define CPQFC_IOCTL_FC_TDR 0x5388
 #define CPQFC_IOCTL_FC_TDR _IO( CCPQFCTS_IOC_MAGIC, 15)
-
--- a/drivers/scsi/cpqfcTSinit.c	2005-08-14 15:05:57.000000000 +0200
+++ b/drivers/scsi/cpqfcTSinit.c	2005-08-14 16:13:17.000000000 +0200
@@ -659,40 +659,6 @@ int cpqfcTS_ioctl( struct scsi_device *S
         return result;
       }
 
-      case CPQFCTS_GETPCIINFO:
-      {
-	cpqfc_pci_info_struct pciinfo;
-	
-	if( !arg)
-	  return -EINVAL;
-
-         	
-	
-        pciinfo.bus = cpqfcHBAdata->PciDev->bus->number;
-        pciinfo.dev_fn = cpqfcHBAdata->PciDev->devfn;
-	pciinfo.board_id = cpqfcHBAdata->PciDev->device |
-			  (cpqfcHBAdata->PciDev->vendor <<16);
-	
-        if(copy_to_user( arg, &pciinfo, sizeof(cpqfc_pci_info_struct)))
-		return( -EFAULT);
-        return 0;
-      }
-
-      case CPQFCTS_GETDRIVVER:
-      {
-	DriverVer_type DriverVer =
-		CPQFCTS_DRIVER_VER( VER_MAJOR,VER_MINOR,VER_SUBMINOR);
-	
-	if( !arg)
-	  return -EINVAL;
-
-        if(copy_to_user( arg, &DriverVer, sizeof(DriverVer)))
-		return( -EFAULT);
-        return 0;
-      }
-
-
-
       case CPQFC_IOCTL_FC_TARGET_ADDRESS:
 	// can we find an FC device mapping to this SCSI target?
 /* 	DumCmnd.channel = ScsiDev->channel; */		// For searching

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver
  2005-08-16  9:11   ` [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver Rolf Eike Beer
  2005-08-16  9:11     ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for " Rolf Eike Beer
@ 2005-08-16  9:17     ` Christoph Hellwig
  2005-08-16  9:37       ` Rolf Eike Beer
  1 sibling, 1 reply; 21+ messages in thread
From: Christoph Hellwig @ 2005-08-16  9:17 UTC (permalink / raw)
  To: Rolf Eike Beer
  Cc: Linux Kernel Mailing List, linux-scsi, James Bottomley,
	Andrew Morton, Linus Torvalds, Bolke de Bruin

On Tue, Aug 16, 2005 at 11:11:06AM +0200, Rolf Eike Beer wrote:
> cpqfcTS_reset() is never referenced from anywhere. By using the nonexistent 
> constant SCSI_RESET_ERROR it causes just another unneeded compile error.

That was the old reset handler.  Do you actually have this hardware?
The driver is pretty much un-recoverable and mkp is working on a from
scratch driver for this hardware - I don't think putting any work into the
driver makes sense unless you have a very urgent need to use it.


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver
  2005-08-16  9:17     ` [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver Christoph Hellwig
@ 2005-08-16  9:37       ` Rolf Eike Beer
  2005-08-16 14:49         ` Martin K. Petersen
  0 siblings, 1 reply; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16  9:37 UTC (permalink / raw)
  To: Christoph Hellwig, Linux Kernel Mailing List, linux-scsi,
	James Bottomley, Andrew Morton, Linus Torvalds, Bolke de Bruin

[-- Attachment #1: Type: text/plain, Size: 1240 bytes --]

Christoph Hellwig wrote:
>On Tue, Aug 16, 2005 at 11:11:06AM +0200, Rolf Eike Beer wrote:
>> cpqfcTS_reset() is never referenced from anywhere. By using the
>> nonexistent constant SCSI_RESET_ERROR it causes just another unneeded
>> compile error.
>
>That was the old reset handler.  Do you actually have this hardware?
>The driver is pretty much un-recoverable and mkp is working on a from
>scratch driver for this hardware - I don't think putting any work into the
>driver makes sense unless you have a very urgent need to use it.

No, I don't have (but maybe I'll get access to it soon). There was a request 
on lkml last week for a working version of this driver. For the moment I try 
to clean this up a bit before doing some real work. I found 4 major things 
that should be done, for half of them I have patches in a proof-of-concept 
state.

-split the interrupt handler into a handler and a tasklet
-remove the stack abuse
-use Linux 2.6 hardware probing code (this would cause the most problems for 
me, I'm not familiar with the preferred way of doing this for scsi drivers)
-fix kernel thread stopping

After this some more error checking at different places can't hurt. And a big 
Lindent run.

Eike

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver
  2005-08-16  9:11     ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for " Rolf Eike Beer
  2005-08-16  9:12       ` [PATCH 2.6.13-rc6] remove 2.4 compat code from " Rolf Eike Beer
@ 2005-08-16 12:53       ` Jiri Slaby
  2005-08-16 13:57         ` Rolf Eike Beer
  2005-08-16 14:36       ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver, take 2 Rolf Eike Beer
  2 siblings, 1 reply; 21+ messages in thread
From: Jiri Slaby @ 2005-08-16 12:53 UTC (permalink / raw)
  To: Rolf Eike Beer
  Cc: Linux Kernel Mailing List, linux-scsi, James Bottomley,
	Andrew Morton, Linus Torvalds, Bolke de Bruin, Greg KH

Rolf Eike Beer napsal(a):

>Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
>
>--- a/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:20:40.000000000 +0200
>+++ b/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:25:33.000000000 +0200
>@@ -264,18 +264,14 @@ static void launch_FCworker_thread(struc
>  * Agilent XL2 
>  * HP Tachyon
>  */
>-#define HBA_TYPES 3
>-
>-#ifndef PCI_DEVICE_ID_COMPAQ_
>-#define PCI_DEVICE_ID_COMPAQ_TACHYON	0xa0fc
>-#endif
>-
>-static struct SupportedPCIcards cpqfc_boards[] __initdata = {
>-	{PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TACHYON},
>-	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHLITE},
>-	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHYON},
>+static struct pci_device_id cpqfc_boards[] __initdata = {
>+	{PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TACHYON, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
>+	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHLITE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
>+	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHYON, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
>+	{0, }
> };
>  
>
Wouldn't be better to use PCI_DEVICE macro for better readability?

> 
>+MODULE_DEVICE_TABLE(pci, cpqfc_boards);
> 
> int cpqfcTS_detect(Scsi_Host_Template *ScsiHostTemplate)
> {
>@@ -294,14 +290,9 @@ int cpqfcTS_detect(Scsi_Host_Template *S
>   ScsiHostTemplate->proc_name = "cpqfcTS";
> #endif
> 
>-  for( i=0; i < HBA_TYPES; i++)
>-  {
>-    // look for all HBAs of each type
>-
>-    while((PciDev = pci_find_device(cpqfc_boards[i].vendor_id,
>-				    cpqfc_boards[i].device_id, PciDev)))
>-    {
>-
>+  for(i = 0; cpqfc_boards[i]; i++) {
>+    while((PciDev = pci_get_device(cpqfc_boards[i].vendor,
>+				    cpqfc_boards[i].device, PciDev))) {
>       if (pci_enable_device(PciDev)) {
> 	printk(KERN_ERR
> 		"cpqfc: can't enable PCI device at %s\n", pci_name(PciDev));
>  
>
You maybe forgot to add pci_dev_put in error cases. You can inspire 
yourself here:
http://www.fi.muni.cz/~xslaby/lnx/pci_find/drivers:scsi:cpqfcTSinit.c.txt
(it wasn't accepted yet).

BTW. Greg KH wants me to cc him, if some of these changes are being done.

regards,

-- 
Jiri Slaby         www.fi.muni.cz/~xslaby
~\-/~      jirislaby@gmail.com      ~\-/~
241B347EC88228DE51EE A49C4A73A25004CB2A10


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver
  2005-08-16 12:53       ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver Jiri Slaby
@ 2005-08-16 13:57         ` Rolf Eike Beer
  0 siblings, 0 replies; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16 13:57 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Jiri Slaby, linux-scsi, James Bottomley, Andrew Morton,
	Linus Torvalds, Bolke de Bruin, Greg KH

[-- Attachment #1: Type: text/plain, Size: 2886 bytes --]

Jiri Slaby wrote:
>Rolf Eike Beer napsal(a):
>>Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
>>
>>--- a/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:20:40.000000000 +0200
>>+++ b/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:25:33.000000000 +0200
>>@@ -264,18 +264,14 @@ static void launch_FCworker_thread(struc
>>  * Agilent XL2
>>  * HP Tachyon
>>  */
>>-#define HBA_TYPES 3
>>-
>>-#ifndef PCI_DEVICE_ID_COMPAQ_
>>-#define PCI_DEVICE_ID_COMPAQ_TACHYON	0xa0fc
>>-#endif
>>-
>>-static struct SupportedPCIcards cpqfc_boards[] __initdata = {
>>-	{PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TACHYON},
>>-	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHLITE},
>>-	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHYON},
>>+static struct pci_device_id cpqfc_boards[] __initdata = {
>>+	{PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TACHYON, PCI_ANY_ID,
>> PCI_ANY_ID, 0, 0, 0}, +	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHLITE,
>> PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +	{PCI_VENDOR_ID_HP,
>> PCI_DEVICE_ID_HP_TACHYON, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, +	{0, }
>> };
>
>Wouldn't be better to use PCI_DEVICE macro for better readability?

Yes, useful little thing. Thanks, I wasn't aware of it.

>>+MODULE_DEVICE_TABLE(pci, cpqfc_boards);
>>
>> int cpqfcTS_detect(Scsi_Host_Template *ScsiHostTemplate)
>> {
>>@@ -294,14 +290,9 @@ int cpqfcTS_detect(Scsi_Host_Template *S
>>   ScsiHostTemplate->proc_name = "cpqfcTS";
>> #endif
>>
>>-  for( i=0; i < HBA_TYPES; i++)
>>-  {
>>-    // look for all HBAs of each type
>>-
>>-    while((PciDev = pci_find_device(cpqfc_boards[i].vendor_id,
>>-				    cpqfc_boards[i].device_id, PciDev)))
>>-    {
>>-
>>+  for(i = 0; cpqfc_boards[i]; i++) {
>>+    while((PciDev = pci_get_device(cpqfc_boards[i].vendor,
>>+				    cpqfc_boards[i].device, PciDev))) {
>>       if (pci_enable_device(PciDev)) {
>> 	printk(KERN_ERR
>> 		"cpqfc: can't enable PCI device at %s\n", pci_name(PciDev));
>
>You maybe forgot to add pci_dev_put in error cases. 

No, all errors will result in next iteration of this loop. Anyway this 
function should be rewritten. Once I figure out how to do the correct 
register stuff for SCSI drivers I'll port this over to Linux 2.6 driver 
model. Then this loop will go away.

>You can inspire yourself here:
>http://www.fi.muni.cz/~xslaby/lnx/pci_find/drivers:scsi:cpqfcTSinit.c.txt
>(it wasn't accepted yet).

*g* I've done such patches more than once ;)

>BTW. Greg KH wants me to cc him, if some of these changes are being done.

I read that, yes. But I had reasons not to CC him. This change is more or less 
to prevent others touching this file ;)

Eike

P.S.: your host is listed in cbl.abuseat.org. You should go and check this. 
Either you have a dynamic IP used by someone dumb before (than you have to 
ask them for delisting) or you probably have some sort of security hole.

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] remove 2.4 compat code from cpqfcTS driver, take 2
  2005-08-16  9:12       ` [PATCH 2.6.13-rc6] remove 2.4 compat code from " Rolf Eike Beer
  2005-08-16  9:13         ` [PATCH 2.6.13-rc6] more whitespace cleanups for cpqfcTS Rolf Eike Beer
@ 2005-08-16 14:28         ` Rolf Eike Beer
  2005-08-16 14:51           ` [PATCH 2.6.13-rc6] remove 2.4 compat code from cpqfcTS driver, take 3 Rolf Eike Beer
  1 sibling, 1 reply; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16 14:28 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds,
	Bolke de Bruin

Remove compat code for Linux 2.4 and earlier. Fixed bug in earlier version
that caused compile error.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

--- a/drivers/scsi/cpqfcTScontrol.c	2005-08-13 19:00:35.000000000 +0200
+++ b/drivers/scsi/cpqfcTScontrol.c	2005-08-14 11:02:09.000000000 +0200
@@ -28,8 +28,6 @@
    Hewlitt Packard Manual Part Number 5968-1083E.
 */
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
-
 #include <linux/blkdev.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
--- a/drivers/scsi/cpqfcTSstructs.h	2005-08-14 11:11:52.000000000 +0200
+++ b/drivers/scsi/cpqfcTSstructs.h	2005-08-14 11:12:54.000000000 +0200
@@ -88,7 +88,6 @@
 #define CPQFCTS_CMD_PER_LUN 15 // power of 2 -1, must be >0 
 #define CPQFCTS_REQ_QUEUE_LEN (TACH_SEST_LEN/2) // must be < TACH_SEST_LEN
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
 #ifndef DECLARE_MUTEX_LOCKED
 #define DECLARE_MUTEX_LOCKED(sem) struct semaphore sem = MUTEX_LOCKED
 #endif
--- a/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:56:41.000000000 +0200
+++ b/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:57:27.000000000 +0200
@@ -29,8 +29,6 @@
 */
 
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
-
 #include <linux/config.h>  
 #include <linux/interrupt.h>  
 #include <linux/module.h>
@@ -72,31 +70,10 @@ int cpqfcTS_TargetDeviceReset( Scsi_Devi
 // few fields...
 // NOTE: proc_fs changes in 2.4 kernel
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
-static struct proc_dir_entry proc_scsi_cpqfcTS =
-{
-  PROC_SCSI_CPQFCTS,           // ushort low_ino (enumerated list)
-  7,                           // ushort namelen
-  DEV_NAME,                    // const char* name
-  S_IFDIR | S_IRUGO | S_IXUGO, // mode_t mode
-  2                            // nlink_t nlink
-	                       // etc. ...
-};
-
-
-#endif
-
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,7)
-#  define CPQFC_DECLARE_COMPLETION(x) DECLARE_COMPLETION(x)
-#  define CPQFC_WAITING waiting
-#  define CPQFC_COMPLETE(x) complete(x)
-#  define CPQFC_WAIT_FOR_COMPLETION(x) wait_for_completion(x);
-#else
-#  define CPQFC_DECLARE_COMPLETION(x) DECLARE_MUTEX_LOCKED(x)
-#  define CPQFC_WAITING sem
-#  define CPQFC_COMPLETE(x) up(x)
-#  define CPQFC_WAIT_FOR_COMPLETION(x) down(x)
-#endif
+#define CPQFC_DECLARE_COMPLETION(x) DECLARE_COMPLETION(x)
+#define CPQFC_WAITING waiting
+#define CPQFC_COMPLETE(x) complete(x)
+#define CPQFC_WAIT_FOR_COMPLETION(x) wait_for_completion(x);
 
 static int cpqfc_alloc_private_data_pool(CPQFCHBA *hba);
 
@@ -284,12 +261,6 @@ int cpqfcTS_detect(Scsi_Host_Template *S
 
   ENTER("cpqfcTS_detect");
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
-  ScsiHostTemplate->proc_dir = &proc_scsi_cpqfcTS;
-#else
-  ScsiHostTemplate->proc_name = "cpqfcTS";
-#endif
-
   for(i = 0; cpqfc_boards[i]; i++) {
     while((PciDev = pci_get_device(cpqfc_boards[i].vendor,
 				    cpqfc_boards[i].device, PciDev))) {
@@ -2059,6 +2030,7 @@ void* fcMemManager( struct pci_dev *pdev
 
 
 static Scsi_Host_Template driver_template = {
+	.proc_name              = DEV_NAME,
 	.detect                 = cpqfcTS_detect,
 	.release                = cpqfcTS_release,
 	.info                   = cpqfcTS_info,

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver, take 2
  2005-08-16  9:11     ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for " Rolf Eike Beer
  2005-08-16  9:12       ` [PATCH 2.6.13-rc6] remove 2.4 compat code from " Rolf Eike Beer
  2005-08-16 12:53       ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver Jiri Slaby
@ 2005-08-16 14:36       ` Rolf Eike Beer
  2 siblings, 0 replies; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16 14:36 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds,
	Bolke de Bruin

cpqfcTSinit has a static array of PCI device and vendor ids supported by the 
driver. Sounds familiar, doesn't it? Use pci_device_id as type for the 
entries of this array and declare the array as MODULE_DEVICE_TABLE. Also use 
pci_get_device() instead of pci_find_device() and remove some superfluos 
defines for device scanning.

Version 2:
-use PCI_DEVICE makro (thanks to Jiri Slaby for pointing this out)
-fix compile error (diffed wrong files)

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

--- a/drivers/scsi/cpqfcTSstructs.h	2005-08-14 10:56:41.000000000 +0200
+++ b/drivers/scsi/cpqfcTSstructs.h	2005-08-14 10:57:32.000000000 +0200
@@ -95,12 +95,6 @@
 
 #define DEV_NAME "cpqfcTS"
 
-struct SupportedPCIcards
-{
-  __u16 vendor_id;
-  __u16 device_id;
-};
-			 
 // nn:nn denotes bit field
                             // TachyonHeader struct def.
                             // the fields shared with ODB
--- a/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:20:40.000000000 +0200
+++ b/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:25:33.000000000 +0200
@@ -264,18 +264,14 @@ static void launch_FCworker_thread(struc
  * Agilent XL2 
  * HP Tachyon
  */
-#define HBA_TYPES 3
-
-#ifndef PCI_DEVICE_ID_COMPAQ_
-#define PCI_DEVICE_ID_COMPAQ_TACHYON	0xa0fc
-#endif
-
-static struct SupportedPCIcards cpqfc_boards[] __initdata = {
-	{PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TACHYON},
-	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHLITE},
-	{PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHYON},
+static struct pci_device_id cpqfc_boards[] __initdata = {
+	{PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TACHYON), 0, 0, 0},
+	{PCI_DEVICE(PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHLITE), 0, 0, 0},
+	{PCI_DEVICE(PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_TACHYON), 0, 0, 0},
+	{0, }
 };
 
+MODULE_DEVICE_TABLE(pci, cpqfc_boards);
 
 int cpqfcTS_detect(Scsi_Host_Template *ScsiHostTemplate)
 {
@@ -294,14 +290,9 @@ int cpqfcTS_detect(Scsi_Host_Template *S
   ScsiHostTemplate->proc_name = "cpqfcTS";
 #endif
 
-  for( i=0; i < HBA_TYPES; i++)
-  {
-    // look for all HBAs of each type
-
-    while((PciDev = pci_find_device(cpqfc_boards[i].vendor_id,
-				    cpqfc_boards[i].device_id, PciDev)))
-    {
-
+  for(i = 0; cpqfc_boards[i].vendor; i++) {
+    while((PciDev = pci_get_device(cpqfc_boards[i].vendor,
+				    cpqfc_boards[i].device, PciDev))) {
       if (pci_enable_device(PciDev)) {
 	printk(KERN_ERR
 		"cpqfc: can't enable PCI device at %s\n", pci_name(PciDev));

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver
  2005-08-16  9:37       ` Rolf Eike Beer
@ 2005-08-16 14:49         ` Martin K. Petersen
  2005-08-16 15:07           ` Rolf Eike Beer
  0 siblings, 1 reply; 21+ messages in thread
From: Martin K. Petersen @ 2005-08-16 14:49 UTC (permalink / raw)
  To: Rolf Eike Beer
  Cc: Christoph Hellwig, Linux Kernel Mailing List, linux-scsi,
	James Bottomley, Andrew Morton, Linus Torvalds, Bolke de Bruin

>>>>> "Rolf" == Rolf Eike Beer <eike-kernel@sf-tec.de> writes:

Hey Rolf!

Rolf> There was a request on lkml last week for a working version of
Rolf> this driver. For the moment I try to clean this up a bit before
Rolf> doing some real work. I found 4 major things that should be
Rolf> done, for half of them I have patches in a proof-of-concept
Rolf> state.

As Christoph said I'm working on a driver for the TachLite TL/TS/XL2
chips.

Initially I just wanted to add support for the integrated PHY on XL2
so we could support those cards on PA-RISC.  But when I started
looking at the driver I came to the conclusion that it was just too
ugly to live.  Architecturally, the overall design of cpqfc just
doesn't fit in well with Linux.  So I'm rewriting it from scratch -
but that obviously takes a while.

I think it's cool that you want to hack on cpqfcTS.  But be aware that
it's not just a matter of running lindent and making it compile in
2.6.late.  And without hardware it's going to be hard.  Fibre channel
is very finicky.

If you manage to get your hands on hardware (cards - avoid Tachyon
5000 series. TachLite 5100, 5166 or 5200 is what you want, disk array,
hub/switch, GBICs, etc.) I wouldn't mind some help...

-- 
Martin K. Petersen      http://mkp.net/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] remove 2.4 compat code from cpqfcTS driver, take 3
  2005-08-16 14:28         ` [PATCH 2.6.13-rc6] remove 2.4 compat code from cpqfcTS driver, take 2 Rolf Eike Beer
@ 2005-08-16 14:51           ` Rolf Eike Beer
  0 siblings, 0 replies; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16 14:51 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds,
	Bolke de Bruin

Remove compat code for Linux 2.4 and earlier.
Version 2: Fixed bug in earlier version that caused compile error.
Version 3: found bug in previous patch, changed this to apply cleanly.

Sorry for the noise.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

--- a/drivers/scsi/cpqfcTScontrol.c	2005-08-13 19:00:35.000000000 +0200
+++ b/drivers/scsi/cpqfcTScontrol.c	2005-08-14 11:02:09.000000000 +0200
@@ -28,8 +28,6 @@
    Hewlitt Packard Manual Part Number 5968-1083E.
 */
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
-
 #include <linux/blkdev.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
--- a/drivers/scsi/cpqfcTSstructs.h	2005-08-14 11:11:52.000000000 +0200
+++ b/drivers/scsi/cpqfcTSstructs.h	2005-08-14 11:12:54.000000000 +0200
@@ -88,7 +88,6 @@
 #define CPQFCTS_CMD_PER_LUN 15 // power of 2 -1, must be >0 
 #define CPQFCTS_REQ_QUEUE_LEN (TACH_SEST_LEN/2) // must be < TACH_SEST_LEN
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
 #ifndef DECLARE_MUTEX_LOCKED
 #define DECLARE_MUTEX_LOCKED(sem) struct semaphore sem = MUTEX_LOCKED
 #endif
--- a/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:56:41.000000000 +0200
+++ b/drivers/scsi/cpqfcTSinit.c	2005-08-14 14:57:27.000000000 +0200
@@ -29,8 +29,6 @@
 */
 
 
-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
-
 #include <linux/config.h>  
 #include <linux/interrupt.h>  
 #include <linux/module.h>
@@ -72,31 +70,10 @@ int cpqfcTS_TargetDeviceReset( Scsi_Devi
 // few fields...
 // NOTE: proc_fs changes in 2.4 kernel
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
-static struct proc_dir_entry proc_scsi_cpqfcTS =
-{
-  PROC_SCSI_CPQFCTS,           // ushort low_ino (enumerated list)
-  7,                           // ushort namelen
-  DEV_NAME,                    // const char* name
-  S_IFDIR | S_IRUGO | S_IXUGO, // mode_t mode
-  2                            // nlink_t nlink
-	                       // etc. ...
-};
-
-
-#endif
-
-#if LINUX_VERSION_CODE >= LinuxVersionCode(2,4,7)
-#  define CPQFC_DECLARE_COMPLETION(x) DECLARE_COMPLETION(x)
-#  define CPQFC_WAITING waiting
-#  define CPQFC_COMPLETE(x) complete(x)
-#  define CPQFC_WAIT_FOR_COMPLETION(x) wait_for_completion(x);
-#else
-#  define CPQFC_DECLARE_COMPLETION(x) DECLARE_MUTEX_LOCKED(x)
-#  define CPQFC_WAITING sem
-#  define CPQFC_COMPLETE(x) up(x)
-#  define CPQFC_WAIT_FOR_COMPLETION(x) down(x)
-#endif
+#define CPQFC_DECLARE_COMPLETION(x) DECLARE_COMPLETION(x)
+#define CPQFC_WAITING waiting
+#define CPQFC_COMPLETE(x) complete(x)
+#define CPQFC_WAIT_FOR_COMPLETION(x) wait_for_completion(x);
 
 static int cpqfc_alloc_private_data_pool(CPQFCHBA *hba);
 
@@ -284,12 +261,6 @@ int cpqfcTS_detect(Scsi_Host_Template *S
 
   ENTER("cpqfcTS_detect");
 
-#if LINUX_VERSION_CODE < LinuxVersionCode(2,3,27)
-  ScsiHostTemplate->proc_dir = &proc_scsi_cpqfcTS;
-#else
-  ScsiHostTemplate->proc_name = "cpqfcTS";
-#endif
-
   for(i = 0; cpqfc_boards[i].vendor; i++) {
     while((PciDev = pci_get_device(cpqfc_boards[i].vendor,
 				    cpqfc_boards[i].device, PciDev))) {
@@ -2059,6 +2030,7 @@ void* fcMemManager( struct pci_dev *pdev
 
 
 static Scsi_Host_Template driver_template = {
+	.proc_name              = DEV_NAME,
 	.detect                 = cpqfcTS_detect,
 	.release                = cpqfcTS_release,
 	.info                   = cpqfcTS_info,

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver
  2005-08-16  9:14           ` [PATCH 2.6.13-rc6] remove superfluos ioctls from cpqfcTS Rolf Eike Beer
@ 2005-08-16 14:58             ` Rolf Eike Beer
  2005-08-16 16:20               ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 2 Rolf Eike Beer
  0 siblings, 1 reply; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16 14:58 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Andrew Morton, Linus Torvalds,
	Bolke de Bruin

Use pid of worker thread and struct completion for signaling end of worker 
thread (code more or less taken from drivers/net/8139too.c). For the moment 
the return code of the start/stop functions is ignored, this will change 
once the init/exit code is changed to use 2.6 driver model.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSinit.c linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSinit.c
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSinit.c	2005-08-16 16:42:14.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSinit.c	2005-08-16 16:34:02.000000000 +0200
@@ -204,32 +204,35 @@ static void Cpqfc_initHBAdata(CPQFCHBA *
       }
 }
 
-
-/* (borrowed from linux/drivers/scsi/hosts.c) */
-static void launch_FCworker_thread(struct Scsi_Host *HostAdapter)
+static int launch_FCworker_thread(struct Scsi_Host *HostAdapter)
 {
-  DECLARE_MUTEX_LOCKED(sem);
-
-  CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
-
-  ENTER("launch_FC_worker_thread");
-
-  cpqfcHBAdata->notify_wt = &sem;
-
-  /* must unlock before kernel_thread(), for it may cause a reschedule. */
-  spin_unlock_irq(HostAdapter->host_lock);
-  kernel_thread((int (*)(void *))cpqfcTSWorkerThread,
-                          (void *) HostAdapter, 0);
-  /*
-   * Now wait for the kernel error thread to initialize itself
-
-   */
-  down (&sem);
-  spin_lock_irq(HostAdapter->host_lock);
-  cpqfcHBAdata->notify_wt = NULL;
-
-  LEAVE("launch_FC_worker_thread");
-
+	DECLARE_MUTEX_LOCKED(sem);
+	
+	CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
+	
+	ENTER(__function__);
+	
+	cpqfcHBAdata->notify_wt = &sem;
+	
+	/* must unlock before kernel_thread(), for it may cause a reschedule. */
+	spin_unlock_irq(HostAdapter->host_lock);
+	cpqfcHBAdata->thr_pid = -1;
+	cpqfcHBAdata->time_to_die = 0;
+	cpqfcHBAdata->thr_pid = kernel_thread(cpqfcTSWorkerThread, HostAdapter, 0);
+	if (cpqfcHBAdata->thr_pid) {
+		printk(KERN_ERR DEV_NAME " can't start worker thread\n");
+		return cpqfcHBAdata->thr_pid;
+	} else {
+	/*
+		* Now wait for the kernel error thread to initialize itself
+	*/
+		down (&sem);
+		spin_lock_irq(HostAdapter->host_lock);
+		cpqfcHBAdata->notify_wt = NULL;
+	}
+	
+	LEAVE(__function__);
+	return 0;
 }
 
 
@@ -317,9 +320,8 @@ int cpqfcTS_detect(Scsi_Host_Template *S
       // each HBA on the PCI bus(ses)).
       cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
 
-      // make certain our data struct is clear
-      memset( cpqfcHBAdata, 0, sizeof( CPQFCHBA ) );
-
+      memset(cpqfcHBAdata, 0, sizeof(*cpqfcHBAdata));
+      init_completion(&cpqfcHBAdata->thr_exited);
 
       // initialize our HBA info
       cpqfcHBAdata->HBAnum = NumberOfAdapters;
@@ -712,6 +714,25 @@ int cpqfcTS_ioctl( struct scsi_device *S
   return result;
 }
 
+static int
+cpqfcTS_kill_worker(CPQFCHBA *hba)
+{
+	int ret = 0;
+
+	if(hba->thr_pid >= 0) {
+		hba->time_to_die = 1;
+		wmb();
+		ret = kill_proc(hba->thr_pid, SIGTERM, 1);
+		if (ret) {
+			printk(KERN_ERR DEV_NAME " unable to signal thread %i\n",
+				hba->thr_pid);
+		} else {
+			wait_for_completion(&hba->thr_exited);
+			hba->thr_pid = -1;
+		}
+	}
+	return ret;
+}
 
 /* "Release" the Host Bus Adapter...
    disable interrupts, stop the HBA, release the interrupt,
@@ -731,18 +752,7 @@ int cpqfcTS_release(struct Scsi_Host *Ho
   DEBUG_PCI( printk(" disable hardware, destroy queues, free mem\n"));
   cpqfcHBAdata->fcChip.ResetTachyon( cpqfcHBAdata, CLEAR_FCPORTS);
 
-  // kill kernel thread
-  if( cpqfcHBAdata->worker_thread ) // (only if exists)
-  {
-    DECLARE_MUTEX_LOCKED(sem);  // synchronize thread kill
-
-    cpqfcHBAdata->notify_wt = &sem;
-    DEBUG_PCI( printk(" killing kernel thread\n"));
-    send_sig( SIGKILL, cpqfcHBAdata->worker_thread, 1);
-    down( &sem);
-    cpqfcHBAdata->notify_wt = NULL;
-
-  }
+  cpqfcTS_kill_worker(cpqfcHBAdata);
 
   cpqfc_free_private_data_pool(cpqfcHBAdata);
   // free Linux resources
diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSstructs.h linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSstructs.h
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSstructs.h	2005-08-16 16:42:14.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSstructs.h	2005-08-16 16:28:53.000000000 +0200
@@ -829,7 +829,7 @@ int CpqTsReadWriteWWN(void*, int ReadWri
 int CpqTsReadWriteNVRAM(void*, void* data, int ReadWrite);
 
 void cpqfcTS_WorkTask( struct Scsi_Host *HostAdapter);
-void cpqfcTSWorkerThread( void *host);
+extern int cpqfcTSWorkerThread(void *host);
 
 int cpqfcTS_GetNVRAM_data( UCHAR *wwnbuf, UCHAR *buf );
 ULONG cpqfcTS_ReadNVRAM( void* GPIOin, void* GPIOout , USHORT count,
@@ -937,7 +937,10 @@ typedef struct 
                                   // logouts, FC protocol timeouts, etc.
   int fcStatsTime;  // Statistics delta reporting time
 
-  struct task_struct *worker_thread; // our kernel thread
+  pid_t thr_pid;	/* pid of worker thread */
+  struct completion thr_exited;	/* exit status of worker thread */
+  int time_to_die;	/* flag for worker thread to exit */
+
   int PortDiscDone;    // set by SendLogins(), cleared by LDn
   
   struct semaphore *TachFrozen;
diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSworker.c linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSworker.c
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSworker.c	2005-08-16 16:42:14.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSworker.c	2005-08-16 16:45:13.000000000 +0200
@@ -147,7 +147,7 @@ static void IssueReportLunsCommand( 
 
 // (see scsi_error.c comments on kernel task creation)
 
-void cpqfcTSWorkerThread( void *host)
+int cpqfcTSWorkerThread(void *host)
 {
   struct Scsi_Host *HostAdapter = (struct Scsi_Host*)host;
   CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata; 
@@ -169,10 +169,7 @@ void cpqfcTSWorkerThread( void *host)
   cpqfcHBAdata->fcQueReady = &fcQueReady;  // primary wait point
   cpqfcHBAdata->TYOBcomplete = &fcTYOBcomplete;
   cpqfcHBAdata->TachFrozen = &TachFrozen;
-    
- 
-  cpqfcHBAdata->worker_thread = current;
-  
+
   unlock_kernel();
 
   if( cpqfcHBAdata->notify_wt != NULL )
@@ -184,7 +181,9 @@ void cpqfcTSWorkerThread( void *host)
 
     down_interruptible( &fcQueReady);  // wait for something to do
 
-    if (signal_pending(current) )
+    if (signal_pending(current))
+		flush_signals(current);
+    if (cpqfcHBAdata->time_to_die)
       break;
     
     PCI_TRACE( 0x90)
@@ -225,12 +224,9 @@ void cpqfcTSWorkerThread( void *host)
     // Now, complete any Cmnd we Q'd up while BoardLock was held
 
     CompleteBoardLockCmnd( cpqfcHBAdata);
-  
-
   }
-  // hopefully, the signal was for our module exit...
-  if( cpqfcHBAdata->notify_wt != NULL )
-    up( cpqfcHBAdata->notify_wt); // yep, we're outta here
+
+	complete_and_exit(&cpqfcHBAdata->thr_exited, 0);
 }
 
 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver
  2005-08-16 14:49         ` Martin K. Petersen
@ 2005-08-16 15:07           ` Rolf Eike Beer
  0 siblings, 0 replies; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16 15:07 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Martin K. Petersen, Christoph Hellwig, linux-scsi,
	James Bottomley, Andrew Morton, Linus Torvalds, Bolke de Bruin

[-- Attachment #1: Type: text/plain, Size: 1972 bytes --]

Martin K. Petersen wrote:
>>>>>> "Rolf" == Rolf Eike Beer <eike-kernel@sf-tec.de> writes:
>
>Hey Rolf!

I should go and use "R. Eike Beer" ;)

>Rolf> There was a request on lkml last week for a working version of
>Rolf> this driver. For the moment I try to clean this up a bit before
>Rolf> doing some real work. I found 4 major things that should be
>Rolf> done, for half of them I have patches in a proof-of-concept
>Rolf> state.
>
>As Christoph said I'm working on a driver for the TachLite TL/TS/XL2
>chips.
>
>Initially I just wanted to add support for the integrated PHY on XL2
>so we could support those cards on PA-RISC.  But when I started
>looking at the driver I came to the conclusion that it was just too
>ugly to live.  Architecturally, the overall design of cpqfc just
>doesn't fit in well with Linux.  So I'm rewriting it from scratch -
>but that obviously takes a while.

>I think it's cool that you want to hack on cpqfcTS.  But be aware that
>it's not just a matter of running lindent and making it compile in
>2.6.late.  And without hardware it's going to be hard.  Fibre channel
>is very finicky.

For the moment I'm trying to fix the most buggy parts. The Lindent run is 
scheduled to be done last, it's too big and adds nothing if it would go into 
kernel for now. It won't even compile now, my tests are only compile tests 
done with the two #error commented out. That should prevent most users from 
using it without all patches applied. The rest either knows what he's doing 
and/or would get crashes anyway ;)

Next to come will be splitting up the ISR and then fixing the #errors. After 
this is might even work. :)

>If you manage to get your hands on hardware (cards - avoid Tachyon
>5000 series. TachLite 5100, 5166 or 5200 is what you want, disk array,
>hub/switch, GBICs, etc.) I wouldn't mind some help...

Give me some code and we can see...

Bolke, what kind of adapter do you have?

Eike

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 2
  2005-08-16 14:58             ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver Rolf Eike Beer
@ 2005-08-16 16:20               ` Rolf Eike Beer
  2005-08-16 16:24                 ` Christoph Hellwig
  2005-08-16 17:09                 ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 3 Rolf Eike Beer
  0 siblings, 2 replies; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16 16:20 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: linux-scsi, James Bottomley, Bolke de Bruin

Use pid of worker thread and struct completion for signaling end of worker 
thread (code more or less taken from drivers/net/8139too.c). For the moment 
the return code of the start/stop functions is ignored, this will change 
once the init/exit code is changed to use 2.6 driver model.

Version 2: remove that lock_kernel() stuff missed in the first version

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSinit.c linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSinit.c
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSinit.c	2005-08-16 16:42:14.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSinit.c	2005-08-16 16:34:02.000000000 +0200
@@ -204,32 +204,35 @@ static void Cpqfc_initHBAdata(CPQFCHBA *
       }
 }
 
-
-/* (borrowed from linux/drivers/scsi/hosts.c) */
-static void launch_FCworker_thread(struct Scsi_Host *HostAdapter)
+static int launch_FCworker_thread(struct Scsi_Host *HostAdapter)
 {
-  DECLARE_MUTEX_LOCKED(sem);
-
-  CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
-
-  ENTER("launch_FC_worker_thread");
-
-  cpqfcHBAdata->notify_wt = &sem;
-
-  /* must unlock before kernel_thread(), for it may cause a reschedule. */
-  spin_unlock_irq(HostAdapter->host_lock);
-  kernel_thread((int (*)(void *))cpqfcTSWorkerThread,
-                          (void *) HostAdapter, 0);
-  /*
-   * Now wait for the kernel error thread to initialize itself
-
-   */
-  down (&sem);
-  spin_lock_irq(HostAdapter->host_lock);
-  cpqfcHBAdata->notify_wt = NULL;
-
-  LEAVE("launch_FC_worker_thread");
-
+	DECLARE_MUTEX_LOCKED(sem);
+	
+	CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
+	
+	ENTER(__function__);
+	
+	cpqfcHBAdata->notify_wt = &sem;
+	
+	/* must unlock before kernel_thread(), for it may cause a reschedule. */
+	spin_unlock_irq(HostAdapter->host_lock);
+	cpqfcHBAdata->thr_pid = -1;
+	cpqfcHBAdata->time_to_die = 0;
+	cpqfcHBAdata->thr_pid = kernel_thread(cpqfcTSWorkerThread, HostAdapter, 0);
+	if (cpqfcHBAdata->thr_pid) {
+		printk(KERN_ERR DEV_NAME " can't start worker thread\n");
+		return cpqfcHBAdata->thr_pid;
+	} else {
+	/*
+		* Now wait for the kernel error thread to initialize itself
+	*/
+		down (&sem);
+		spin_lock_irq(HostAdapter->host_lock);
+		cpqfcHBAdata->notify_wt = NULL;
+	}
+	
+	LEAVE(__function__);
+	return 0;
 }
 
 
@@ -317,9 +320,8 @@ int cpqfcTS_detect(Scsi_Host_Template *S
       // each HBA on the PCI bus(ses)).
       cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
 
-      // make certain our data struct is clear
-      memset( cpqfcHBAdata, 0, sizeof( CPQFCHBA ) );
-
+      memset(cpqfcHBAdata, 0, sizeof(*cpqfcHBAdata));
+      init_completion(&cpqfcHBAdata->thr_exited);
 
       // initialize our HBA info
       cpqfcHBAdata->HBAnum = NumberOfAdapters;
@@ -712,6 +714,25 @@ int cpqfcTS_ioctl( struct scsi_device *S
   return result;
 }
 
+static int
+cpqfcTS_kill_worker(CPQFCHBA *hba)
+{
+	int ret = 0;
+
+	if(hba->thr_pid >= 0) {
+		hba->time_to_die = 1;
+		wmb();
+		ret = kill_proc(hba->thr_pid, SIGTERM, 1);
+		if (ret) {
+			printk(KERN_ERR DEV_NAME " unable to signal thread %i\n",
+				hba->thr_pid);
+		} else {
+			wait_for_completion(&hba->thr_exited);
+			hba->thr_pid = -1;
+		}
+	}
+	return ret;
+}
 
 /* "Release" the Host Bus Adapter...
    disable interrupts, stop the HBA, release the interrupt,
@@ -731,18 +752,7 @@ int cpqfcTS_release(struct Scsi_Host *Ho
   DEBUG_PCI( printk(" disable hardware, destroy queues, free mem\n"));
   cpqfcHBAdata->fcChip.ResetTachyon( cpqfcHBAdata, CLEAR_FCPORTS);
 
-  // kill kernel thread
-  if( cpqfcHBAdata->worker_thread ) // (only if exists)
-  {
-    DECLARE_MUTEX_LOCKED(sem);  // synchronize thread kill
-
-    cpqfcHBAdata->notify_wt = &sem;
-    DEBUG_PCI( printk(" killing kernel thread\n"));
-    send_sig( SIGKILL, cpqfcHBAdata->worker_thread, 1);
-    down( &sem);
-    cpqfcHBAdata->notify_wt = NULL;
-
-  }
+  cpqfcTS_kill_worker(cpqfcHBAdata);
 
   cpqfc_free_private_data_pool(cpqfcHBAdata);
   // free Linux resources
diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSstructs.h linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSstructs.h
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSstructs.h	2005-08-16 16:42:14.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSstructs.h	2005-08-16 16:28:53.000000000 +0200
@@ -829,7 +829,7 @@ int CpqTsReadWriteWWN(void*, int ReadWri
 int CpqTsReadWriteNVRAM(void*, void* data, int ReadWrite);
 
 void cpqfcTS_WorkTask( struct Scsi_Host *HostAdapter);
-void cpqfcTSWorkerThread( void *host);
+extern int cpqfcTSWorkerThread(void *host);
 
 int cpqfcTS_GetNVRAM_data( UCHAR *wwnbuf, UCHAR *buf );
 ULONG cpqfcTS_ReadNVRAM( void* GPIOin, void* GPIOout , USHORT count,
@@ -937,7 +937,10 @@ typedef struct 
                                   // logouts, FC protocol timeouts, etc.
   int fcStatsTime;  // Statistics delta reporting time
 
-  struct task_struct *worker_thread; // our kernel thread
+  pid_t thr_pid;	/* pid of worker thread */
+  struct completion thr_exited;	/* exit status of worker thread */
+  int time_to_die;	/* flag for worker thread to exit */
+
   int PortDiscDone;    // set by SendLogins(), cleared by LDn
   
   struct semaphore *TachFrozen;
diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSworker.c linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSworker.c
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSworker.c	2005-08-16 16:42:14.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSworker.c	2005-08-16 18:05:54.000000000 +0200
@@ -32,8 +32,6 @@
 #include <linux/smp_lock.h>
 #include <linux/pci.h>
 
-#define SHUTDOWN_SIGS	(sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM))
-
 #include <asm/system.h>
 #include <asm/irq.h>
 #include <asm/dma.h>
@@ -145,9 +143,8 @@ static void IssueReportLunsCommand( 
               CPQFCHBA* cpqfcHBAdata, 
 	      TachFCHDR_GCMND* fchs);
 
-// (see scsi_error.c comments on kernel task creation)
-
-void cpqfcTSWorkerThread( void *host)
+int
+cpqfcTSWorkerThread(void *host)
 {
   struct Scsi_Host *HostAdapter = (struct Scsi_Host*)host;
   CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata; 
@@ -159,21 +156,14 @@ void cpqfcTSWorkerThread( void *host)
   DECLARE_MUTEX_LOCKED(TachFrozen);  
   DECLARE_MUTEX_LOCKED(BoardLock);  
 
-  ENTER("WorkerThread");
+  ENTER(__function__);
 
-  lock_kernel();
   daemonize("cpqfcTS_wt_%d", HostAdapter->host_no);
-  siginitsetinv(&current->blocked, SHUTDOWN_SIGS);
-
+  allow_signal(SIGTERM);
 
   cpqfcHBAdata->fcQueReady = &fcQueReady;  // primary wait point
   cpqfcHBAdata->TYOBcomplete = &fcTYOBcomplete;
   cpqfcHBAdata->TachFrozen = &TachFrozen;
-    
- 
-  cpqfcHBAdata->worker_thread = current;
-  
-  unlock_kernel();
 
   if( cpqfcHBAdata->notify_wt != NULL )
     up( cpqfcHBAdata->notify_wt); // OK to continue
@@ -184,7 +174,9 @@ void cpqfcTSWorkerThread( void *host)
 
     down_interruptible( &fcQueReady);  // wait for something to do
 
-    if (signal_pending(current) )
+    if (signal_pending(current))
+		flush_signals(current);
+    if (cpqfcHBAdata->time_to_die)
       break;
     
     PCI_TRACE( 0x90)
@@ -225,14 +217,10 @@ void cpqfcTSWorkerThread( void *host)
     // Now, complete any Cmnd we Q'd up while BoardLock was held
 
     CompleteBoardLockCmnd( cpqfcHBAdata);
-  
-
   }
-  // hopefully, the signal was for our module exit...
-  if( cpqfcHBAdata->notify_wt != NULL )
-    up( cpqfcHBAdata->notify_wt); // yep, we're outta here
-}
 
+	complete_and_exit(&cpqfcHBAdata->thr_exited, 0);
+}
 
 // Freeze Tachyon routine.
 // If Tachyon is already frozen, return FALSE

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 2
  2005-08-16 16:20               ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 2 Rolf Eike Beer
@ 2005-08-16 16:24                 ` Christoph Hellwig
  2005-08-16 17:09                 ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 3 Rolf Eike Beer
  1 sibling, 0 replies; 21+ messages in thread
From: Christoph Hellwig @ 2005-08-16 16:24 UTC (permalink / raw)
  To: Rolf Eike Beer
  Cc: Linux Kernel Mailing List, linux-scsi, James Bottomley,
	Bolke de Bruin

On Tue, Aug 16, 2005 at 06:20:56PM +0200, Rolf Eike Beer wrote:
> Use pid of worker thread and struct completion for signaling end of worker 
> thread (code more or less taken from drivers/net/8139too.c). For the moment 
> the return code of the start/stop functions is ignored, this will change 
> once the init/exit code is changed to use 2.6 driver model.

thread start/stop should use the kthread.h API.  Not that this helps at
all for this driver..


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 3
  2005-08-16 16:20               ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 2 Rolf Eike Beer
  2005-08-16 16:24                 ` Christoph Hellwig
@ 2005-08-16 17:09                 ` Rolf Eike Beer
  2005-08-17  8:57                   ` [PATCH 2.6.13-rc6] fix copying stack memory in cpqfcTScontrol.c::cpqfcTSPutLinkQue() Rolf Eike Beer
  1 sibling, 1 reply; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-16 17:09 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Bolke de Bruin, Christoph Hellwig

Improve start/stop code for HBA worker thread. For the moment the return code 
of the start/stop functions is ignored, this will change once the init/exit 
code is changed to use 2.6 driver model.

Version 2: remove that lock_kernel() stuff missed in the first version
Version 3: use kthread API (pointed out by Christoph Hellwig)

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSinit.c linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSinit.c
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSinit.c	2005-08-16 16:42:14.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSinit.c	2005-08-16 18:59:26.000000000 +0200
@@ -43,6 +43,7 @@
 #include <linux/init.h>
 #include <linux/ioport.h>  // request_region() prototype
 #include <linux/completion.h>
+#include <linux/kthread.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>   // ioctl related
@@ -204,32 +205,26 @@ static void Cpqfc_initHBAdata(CPQFCHBA *
       }
 }
 
-
-/* (borrowed from linux/drivers/scsi/hosts.c) */
-static void launch_FCworker_thread(struct Scsi_Host *HostAdapter)
+static int launch_FCworker_thread(struct Scsi_Host *HostAdapter)
 {
-  DECLARE_MUTEX_LOCKED(sem);
-
-  CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
+	CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
 
-  ENTER("launch_FC_worker_thread");
+	ENTER(__function__);
 
-  cpqfcHBAdata->notify_wt = &sem;
+	spin_unlock_irq(HostAdapter->host_lock);
 
-  /* must unlock before kernel_thread(), for it may cause a reschedule. */
-  spin_unlock_irq(HostAdapter->host_lock);
-  kernel_thread((int (*)(void *))cpqfcTSWorkerThread,
-                          (void *) HostAdapter, 0);
-  /*
-   * Now wait for the kernel error thread to initialize itself
-
-   */
-  down (&sem);
-  spin_lock_irq(HostAdapter->host_lock);
-  cpqfcHBAdata->notify_wt = NULL;
+	cpqfcHBAdata->worker_thread = kthread_run(cpqfcTSWorkerThread,
+			HostAdapter,
+			"cpqfcTS_wt_%d", HostAdapter->host_no);
+	if (IS_ERR(cpqfcHBAdata->worker_thread)) {
+		printk(KERN_ERR DEV_NAME " can't start worker thread\n");
+		return PTR_ERR(cpqfcHBAdata->worker_thread);
+	}
 
-  LEAVE("launch_FC_worker_thread");
+	spin_lock_irq(HostAdapter->host_lock);
 
+	LEAVE(__function__);
+	return 0;
 }
 
 
@@ -317,9 +312,7 @@ int cpqfcTS_detect(Scsi_Host_Template *S
       // each HBA on the PCI bus(ses)).
       cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata;
 
-      // make certain our data struct is clear
-      memset( cpqfcHBAdata, 0, sizeof( CPQFCHBA ) );
-
+      memset(cpqfcHBAdata, 0, sizeof(*cpqfcHBAdata));
 
       // initialize our HBA info
       cpqfcHBAdata->HBAnum = NumberOfAdapters;
@@ -731,18 +724,7 @@ int cpqfcTS_release(struct Scsi_Host *Ho
   DEBUG_PCI( printk(" disable hardware, destroy queues, free mem\n"));
   cpqfcHBAdata->fcChip.ResetTachyon( cpqfcHBAdata, CLEAR_FCPORTS);
 
-  // kill kernel thread
-  if( cpqfcHBAdata->worker_thread ) // (only if exists)
-  {
-    DECLARE_MUTEX_LOCKED(sem);  // synchronize thread kill
-
-    cpqfcHBAdata->notify_wt = &sem;
-    DEBUG_PCI( printk(" killing kernel thread\n"));
-    send_sig( SIGKILL, cpqfcHBAdata->worker_thread, 1);
-    down( &sem);
-    cpqfcHBAdata->notify_wt = NULL;
-
-  }
+  kthread_stop(cpqfcHBAdata->worker_thread);
 
   cpqfc_free_private_data_pool(cpqfcHBAdata);
   // free Linux resources
diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSstructs.h linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSstructs.h
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSstructs.h	2005-08-16 16:42:14.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSstructs.h	2005-08-16 19:01:42.000000000 +0200
@@ -829,7 +829,7 @@ int CpqTsReadWriteWWN(void*, int ReadWri
 int CpqTsReadWriteNVRAM(void*, void* data, int ReadWrite);
 
 void cpqfcTS_WorkTask( struct Scsi_Host *HostAdapter);
-void cpqfcTSWorkerThread( void *host);
+extern int cpqfcTSWorkerThread(void *host);
 
 int cpqfcTS_GetNVRAM_data( UCHAR *wwnbuf, UCHAR *buf );
 ULONG cpqfcTS_ReadNVRAM( void* GPIOin, void* GPIOout , USHORT count,
diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSworker.c linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSworker.c
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSworker.c	2005-08-16 16:42:14.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSworker.c	2005-08-16 19:05:42.000000000 +0200
@@ -31,8 +31,7 @@
 #include <linux/delay.h>
 #include <linux/smp_lock.h>
 #include <linux/pci.h>
-
-#define SHUTDOWN_SIGS	(sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM))
+#include <linux/kthread.h>
 
 #include <asm/system.h>
 #include <asm/irq.h>
@@ -145,9 +144,8 @@ static void IssueReportLunsCommand( 
               CPQFCHBA* cpqfcHBAdata, 
 	      TachFCHDR_GCMND* fchs);
 
-// (see scsi_error.c comments on kernel task creation)
-
-void cpqfcTSWorkerThread( void *host)
+int
+cpqfcTSWorkerThread(void *host)
 {
   struct Scsi_Host *HostAdapter = (struct Scsi_Host*)host;
   CPQFCHBA *cpqfcHBAdata = (CPQFCHBA *)HostAdapter->hostdata; 
@@ -159,24 +157,11 @@ void cpqfcTSWorkerThread( void *host)
   DECLARE_MUTEX_LOCKED(TachFrozen);  
   DECLARE_MUTEX_LOCKED(BoardLock);  
 
-  ENTER("WorkerThread");
-
-  lock_kernel();
-  daemonize("cpqfcTS_wt_%d", HostAdapter->host_no);
-  siginitsetinv(&current->blocked, SHUTDOWN_SIGS);
-
+  ENTER(__function__);
 
   cpqfcHBAdata->fcQueReady = &fcQueReady;  // primary wait point
   cpqfcHBAdata->TYOBcomplete = &fcTYOBcomplete;
   cpqfcHBAdata->TachFrozen = &TachFrozen;
-    
- 
-  cpqfcHBAdata->worker_thread = current;
-  
-  unlock_kernel();
-
-  if( cpqfcHBAdata->notify_wt != NULL )
-    up( cpqfcHBAdata->notify_wt); // OK to continue
 
   while(1)
   {
@@ -184,9 +169,11 @@ void cpqfcTSWorkerThread( void *host)
 
     down_interruptible( &fcQueReady);  // wait for something to do
 
-    if (signal_pending(current) )
-      break;
-    
+    if (signal_pending(current))
+		flush_signals(current);
+    if (kthread_should_stop())
+		return 0;
+
     PCI_TRACE( 0x90)
     // first, take the IO lock so the SCSI upper layers can't call
     // into our _quecommand function (this also disables INTs)
@@ -225,15 +212,9 @@ void cpqfcTSWorkerThread( void *host)
     // Now, complete any Cmnd we Q'd up while BoardLock was held
 
     CompleteBoardLockCmnd( cpqfcHBAdata);
-  
-
   }
-  // hopefully, the signal was for our module exit...
-  if( cpqfcHBAdata->notify_wt != NULL )
-    up( cpqfcHBAdata->notify_wt); // yep, we're outta here
 }
 
-
 // Freeze Tachyon routine.
 // If Tachyon is already frozen, return FALSE
 // If Tachyon is not frozen, call freeze function, return TRUE

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2.6.13-rc6] fix copying stack memory in cpqfcTScontrol.c::cpqfcTSPutLinkQue()
  2005-08-16 17:09                 ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 3 Rolf Eike Beer
@ 2005-08-17  8:57                   ` Rolf Eike Beer
  0 siblings, 0 replies; 21+ messages in thread
From: Rolf Eike Beer @ 2005-08-17  8:57 UTC (permalink / raw)
  To: linux-scsi

First of all: since the request for a working version of this driver is not
longer there at the moment I'll only send out what I currently have to get it
into list archives. Merging this would be fine to decrease the amount of bugs
in this (and the size of it). I removed everyone but linux-scsi from recipient
list because of this. Removing the stack error is rather simple now, but I 
don't do it for now to make sure noone uses this beast until it's fixed.

cpqfcTSPutLinkQue() sometimes gets a pointer to an integer on the stack as 
third argument. Only this integer is meant to be copied into the next queue 
item, but everytime 160 bytes of stack memory are memcpy()'ed. This patch 
introduced a fourth argument for this error case and changes the third one 
not to be void* anymore. It also shrinks this driver by 50 lines and 1kB.

Signed-off-by: Rolf Eike Beer <eike-kernel@sf-tec.de>

diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTScontrol.c linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTScontrol.c
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTScontrol.c	2005-08-16 16:42:14.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTScontrol.c	2005-08-17 10:36:38.000000000 +0200
@@ -662,9 +662,9 @@ int CpqTsProcessIMQEntry(void *host)
   USHORT i, RPCset, DPCset;
   ULONG x_ID;
   ULONG ulBuff, dwStatus;
-  TachFCHDR_GCMND* fchs;
 #error This is too much stack
   ULONG ulFibreFrame[2048/4];  // max number of DWORDS in incoming Fibre Frame
+  TachFCHDR_GCMND* fchs = (TachFCHDR_GCMND*) ulFibreFrame;
   UCHAR ucInboundMessageType;  // Inbound CM, dword 3 "type" field
 
   ENTER("ProcessIMQEntry");
@@ -761,12 +761,10 @@ int CpqTsProcessIMQEntry(void *host)
 	      {
 		// presumes device is still there: send ABTS.
 
-                cpqfcTSPutLinkQue( cpqfcHBAdata, BLS_ABTS, &x_ID);
+			cpqfcTSPutLinkQue(cpqfcHBAdata, BLS_ABTS, NULL, x_ID);
 	      }
-	    }
-	    else  // Abort all other errors
-	    {
-              cpqfcTSPutLinkQue( cpqfcHBAdata, BLS_ABTS, &x_ID);
+	    } else { /* Abort all other errors */
+		cpqfcTSPutLinkQue(cpqfcHBAdata, BLS_ABTS, NULL, x_ID);
 	    }
 
             // if the HPE bit is set, we have to CLose the LOOP
@@ -879,7 +877,6 @@ int CpqTsProcessIMQEntry(void *host)
 
       if( ucInboundMessageType == 1 )
       {
-        fchs = (TachFCHDR_GCMND*)ulFibreFrame; // cast to examine IB frame
         // don't fill up our Q with garbage - only accept FCP-CMND
         // or XRDY frames
         if( (fchs->d_id & 0xFF000000) == 0x06000000 ) // CMND
@@ -920,21 +917,16 @@ int CpqTsProcessIMQEntry(void *host)
               Exchanges->fcExchange[ x_ID ].status |= SFQ_FRAME;
 
 	      // presumes device is still there: send ABTS.
-              cpqfcTSPutLinkQue( cpqfcHBAdata, BLS_ABTS, &x_ID);
+		cpqfcTSPutLinkQue(cpqfcHBAdata, BLS_ABTS, NULL, x_ID);
 	      break;  // done
 	    }
 	  }
 	}
 	
-      }
-      else if( ucInboundMessageType == 3)
-      {
+	} else if (ucInboundMessageType == 3) {
         // FC Link Service frames (e.g. PLOGI, ACC) come in here.
-        cpqfcTSPutLinkQue( cpqfcHBAdata, SFQ_UNKNOWN, ulFibreFrame);
-
-      }
-      else if( ucInboundMessageType == 2 ) // "bad FCP"?
-      {
+		cpqfcTSPutLinkQue(cpqfcHBAdata, SFQ_UNKNOWN, fchs, 0);
+	} else if (ucInboundMessageType == 2) { // "bad FCP"?
 #ifdef IMQ_DEBUG
         printk("Bad FCP incoming frame discarded\n");
 #endif
@@ -1290,7 +1282,7 @@ int CpqTsProcessIMQEntry(void *host)
 //	  printk("skipping LINKACTIVE post\n");
 	}
 	else
-          cpqfcTSPutLinkQue(cpqfcHBAdata, LINKACTIVE, ulFibreFrame);
+		cpqfcTSPutLinkQue(cpqfcHBAdata, LINKACTIVE, fchs, 0);
       }
 
       // ******* Set Fabric Login indication ********
diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSinit.c linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSinit.c
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSinit.c	2005-08-16 20:24:23.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSinit.c	2005-08-17 10:15:51.000000000 +0200
@@ -1440,7 +1440,7 @@ int cpqfcTS_eh_abort(Scsi_Cmnd *Cmnd)
       // upper layers, we can't make future reference to any of its
       // fields (e.g the Nexus).
 
-      cpqfcTSPutLinkQue( cpqfcHBAdata, BLS_ABTS, &i);
+	cpqfcTSPutLinkQue(cpqfcHBAdata, BLS_ABTS, NULL, i);
 
       break;
     }
diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSstructs.h linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSstructs.h
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSstructs.h	2005-08-16 20:24:23.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSstructs.h	2005-08-17 10:14:48.000000000 +0200
@@ -999,10 +999,7 @@ PFC_LOGGEDIN_PORT  fcFindLoggedInPort( 
   PFC_LOGGEDIN_PORT *pLastLoggedInPort
 );
 
-void cpqfcTSPutLinkQue( 
-  CPQFCHBA *cpqfcHBAdata, 
-  int Type, 
-  void *QueContent);
+void cpqfcTSPutLinkQue(CPQFCHBA *, int, TachFCHDR_GCMND*, ULONG);
 
 void fcPutScsiQue( 
   CPQFCHBA *cpqfcHBAdata, 
diff -aup linux-2.6.13-rc6/drivers/scsi/cpqfcTSworker.c linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSworker.c
--- linux-2.6.13-rc6/drivers/scsi/cpqfcTSworker.c	2005-08-16 20:24:23.000000000 +0200
+++ linux-2.6.13-rc6-eike/drivers/scsi/cpqfcTSworker.c	2005-08-17 10:31:51.000000000 +0200
@@ -789,9 +789,9 @@ void cpqfcTS_WorkTask( struct Scsi_Host 
 // This circular Q works like Tachyon's que - the producer points to the next
 // (unused) entry.  Called by Interrupt handler, WorkerThread, Timer
 // sputlinkq
-void cpqfcTSPutLinkQue( CPQFCHBA *cpqfcHBAdata,
-  int Type, 
-  void *QueContent)
+void
+cpqfcTSPutLinkQue(CPQFCHBA *cpqfcHBAdata, int Type,
+		TachFCHDR_GCMND *content, ULONG err)
 {
   PTACHYON fcChip = &cpqfcHBAdata->fcChip;
 //  FC_EXCHANGES *Exchanges = fcChip->Exchanges;
@@ -800,12 +800,8 @@ void cpqfcTSPutLinkQue( CPQFCHBA *cpqfcH
   
   ENTER("cpqfcTSPutLinkQ");
 
-  ndx = fcLQ->producer;
-  
-  ndx += 1;  // test for Que full
-
+  ndx = fcLQ->producer + 1; /* test for Que full */
 
-  
   if( ndx >= FC_LINKQ_DEPTH ) // rollover test
     ndx = 0;
 
@@ -863,11 +859,13 @@ void cpqfcTSPutLinkQue( CPQFCHBA *cpqfcH
     // OK, add the Q'd item...
     
     fcLQ->Qitem[fcLQ->producer].Type = Type;
-   
-    memcpy(
-        fcLQ->Qitem[fcLQ->producer].ulBuff,
-        QueContent, 
-        sizeof(fcLQ->Qitem[fcLQ->producer].ulBuff));
+
+	if (content) {
+		memcpy(fcLQ->Qitem[fcLQ->producer].ulBuff, content,
+			sizeof(fcLQ->Qitem[fcLQ->producer].ulBuff));
+	} else {
+		fcLQ->Qitem[fcLQ->producer].ulBuff[0] = err;
+	}
 
     fcLQ->producer = ndx;  // increment Que producer
 
@@ -1165,10 +1163,8 @@ void cpqfcTSTerminateExchange( 
       if( ScsiNexus == NULL ) // our HBA changed - term. all
       {
 	Exchanges->fcExchange[x_ID].status = TerminateStatus;
-        cpqfcTSPutLinkQue( cpqfcHBAdata, BLS_ABTS, &x_ID ); 
-      }
-      else
-      {
+		cpqfcTSPutLinkQue(cpqfcHBAdata, BLS_ABTS, NULL, x_ID); 
+	} else {
 	// If a device, according to WWN, has been removed, it's
 	// port_id may be used by another working device, so we
 	// have to terminate by SCSI target, NOT port_id.
@@ -1179,7 +1175,7 @@ void cpqfcTSTerminateExchange( 
             (Exchanges->fcExchange[x_ID].Cmnd->device->channel == ScsiNexus->channel)) 
           {
             Exchanges->fcExchange[x_ID].status = TerminateStatus;
-            cpqfcTSPutLinkQue( cpqfcHBAdata, BLS_ABTS, &x_ID ); // timed-out
+		cpqfcTSPutLinkQue(cpqfcHBAdata, BLS_ABTS, NULL, x_ID); /* timed-out */
           }
 	}
 
@@ -1245,7 +1241,7 @@ static void ProcessELS_Request( 
             // send 'ACC' reply 
             cpqfcTSPutLinkQue( cpqfcHBAdata, 
                           ELS_PLOGI_ACC, // (PDISC same as PLOGI ACC)
-                          fchs );
+				fchs, 0);
 
 	    // OK to resume I/O...
 	  }
@@ -1310,7 +1306,7 @@ static void ProcessELS_Request( 
 	port_id = fchs->s_id &0xFFFFFF;
       }
       fchs->reserved = ls_reject_code; // borrow this (unused) field
-      cpqfcTSPutLinkQue( cpqfcHBAdata, ELS_RJT, fchs );
+	cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_RJT, fchs, 0);
     }
    
     break;
@@ -1372,7 +1368,7 @@ static void ProcessELS_Request( 
         // send 'ACC' reply 
         cpqfcTSPutLinkQue( cpqfcHBAdata, 
                       ELS_PLOGI_ACC, // (PDISC same as PLOGI ACC)
-                      fchs );
+			fchs, 0);
       }
     }
     else // Payload unacceptable
@@ -1392,7 +1388,7 @@ static void ProcessELS_Request( 
       fchs->reserved = ls_reject_code; // borrow this (unused) field
 
       // send 'RJT' reply 
-      cpqfcTSPutLinkQue( cpqfcHBAdata, ELS_RJT, fchs );
+	cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_RJT, fchs, 0);
     }
    
     // terminate any exchanges with this device...
@@ -1437,14 +1433,9 @@ static void ProcessELS_Request( 
           SetLoginFields( pLoggedInPort, fchs, FALSE, FALSE);
 
           // Q an ACCept Reply
-	  cpqfcTSPutLinkQue( cpqfcHBAdata,
-                        ELS_PRLI_ACC, 
-                        fchs );   
-	  
-	  NeedReject = FALSE;
-	}
-        else
-        {
+		cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_PRLI_ACC, fchs, 0);
+		NeedReject = FALSE;
+	} else {
           // huh?
           printk(" (unexpected) PRLI REQEST with plogi FALSE\n");
 
@@ -1468,9 +1459,7 @@ static void ProcessELS_Request( 
     {
       // Q a ReJecT Reply with reason code
       fchs->reserved = ls_reject_code;
-      cpqfcTSPutLinkQue( cpqfcHBAdata,
-                    ELS_RJT, // Q Type
-                    fchs );  
+	cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_RJT, fchs, 0);
     }
   }
     break;
@@ -1501,9 +1490,7 @@ static void ProcessELS_Request( 
     if( pLoggedInPort ) // found the device?
     {
       // Q an ACC reply 
-      cpqfcTSPutLinkQue( cpqfcHBAdata,
-                    ELS_LOGO_ACC, // Q Type
-                    fchs );       // device to respond to
+		cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_LOGO_ACC, fchs, 0);
 
       // set login struct fields (LOGO_counter increment)
       SetLoginFields( pLoggedInPort, fchs, FALSE, FALSE);
@@ -1524,11 +1511,8 @@ static void ProcessELS_Request( 
 	else if( pLoggedInPort->LOGO_counter <= 3)
 	{
 	  // try (another) login (PLOGI request)
-	  
-          cpqfcTSPutLinkQue( cpqfcHBAdata,
-                    ELS_PLOGI, // Q Type
-                    fchs );  
-	
+		cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_PLOGI, fchs, 0);
+
 	  // Terminate I/O with "retry" potential
 	  cpqfcTSTerminateExchange( cpqfcHBAdata, 
 			            &pLoggedInPort->ScsiNexus,
@@ -1558,9 +1542,7 @@ static void ProcessELS_Request( 
     {
       // Q a ReJecT Reply with reason code
       fchs->reserved = ls_reject_code;
-      cpqfcTSPutLinkQue( cpqfcHBAdata,
-                    ELS_RJT, // Q Type
-                    fchs );  
+	cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_RJT, fchs, 0);
     }
   }
     break;
@@ -1590,18 +1572,11 @@ static void ProcessELS_Request( 
     {
       // ReJecT the command
       fchs->reserved = LS_RJT_REASON( UNABLE_TO_PERFORM, 0);
-    
-      cpqfcTSPutLinkQue( cpqfcHBAdata,
-                    ELS_RJT, // Q Type
-                    fchs ); 
-      
-      break;
-    }
-    else  // Accept the command
-    {
-       cpqfcTSPutLinkQue( cpqfcHBAdata,
-                    ELS_ACC, // Q Type
-                    fchs ); 
+
+		cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_RJT, fchs, 0);
+		break;
+	} else { /* Accept the command */
+		cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_ACC, fchs, 0);
     }
     
       // Check the "address format" to determine action.
@@ -1622,7 +1597,7 @@ static void ProcessELS_Request( 
         // For example, "port_id" 0x201300 
 	// OK, let's try a Name Service Request (Query)
       fchs->s_id = 0xFFFFFC;  // Name Server Address
-      cpqfcTSPutLinkQue( cpqfcHBAdata, FCS_NSR, fchs);
+	cpqfcTSPutLinkQue(cpqfcHBAdata, FCS_NSR, fchs, 0);
 
       break;
 	
@@ -1641,10 +1616,8 @@ static void ProcessELS_Request( 
     // set reject reason code 
     fchs->reserved = LS_RJT_REASON( UNABLE_TO_PERFORM, 
 		                    REQUEST_NOT_SUPPORTED);
-    
-    cpqfcTSPutLinkQue( cpqfcHBAdata,
-                    ELS_RJT, // Q Type
-                    fchs );     
+
+	cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_RJT, fchs, 0);
     break;  
   }
 }
@@ -1761,14 +1734,11 @@ static void ProcessELS_Reply( 
       {
         // PLOGI ACC was a Fabric response... issue SCR
 	fchs->s_id = 0xFFFFFD;  // address for SCR
-        cpqfcTSPutLinkQue( cpqfcHBAdata, ELS_SCR, fchs);
-      }
-
-      else
-      {
+		cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_SCR, fchs, 0);
+	} else {
       // Now we need a PRLI to enable FCP-SCSI operation
       // set flags and Q up a ELS_PRLI
-        cpqfcTSPutLinkQue( cpqfcHBAdata, ELS_PRLI, fchs);
+		cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_PRLI, fchs, 0);
       }
     }
     else
@@ -1834,7 +1804,7 @@ static void ProcessELS_Reply( 
                 fchs->reserved = i; // copy ExchangeID
 //                printk(" *Q x_ID %Xh after PDISC* ",i);
 
-                cpqfcTSPutLinkQue( cpqfcHBAdata, EXCHANGE_QUEUED, fchs );
+		cpqfcTSPutLinkQue(cpqfcHBAdata, EXCHANGE_QUEUED, fchs, 0);
               }
             }
 
@@ -1869,10 +1839,7 @@ static void ProcessELS_Reply( 
 	// terminate any I/O to this port, and Q a PLOGI
 	if( pLoggedInPort )  // FC device previously known?
 	{
-
-          cpqfcTSPutLinkQue( cpqfcHBAdata,
-                    ELS_LOGO, // Q Type
-                    fchs );   // has port_id to send to 
+		cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_LOGO, fchs, 0);
 
 	  // There are a variety of error scenarios which can result
   	  // in PDISC failure, so as a catchall, add the check for
@@ -1887,7 +1854,7 @@ static void ProcessELS_Reply( 
           cpqfcTSTerminateExchange( cpqfcHBAdata, 
 	    &pLoggedInPort->ScsiNexus, PORTID_CHANGED);
         }
-        cpqfcTSPutLinkQue( cpqfcHBAdata, ELS_PLOGI, fchs );
+	cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_PLOGI, fchs, 0);
       }
     }
     else
@@ -1934,7 +1901,7 @@ static void ProcessELS_Reply( 
         // OK, let's send a REPORT_LUNS command to determine
 	// whether VSA or PDA FCP-LUN addressing is used.
 	
-        cpqfcTSPutLinkQue( cpqfcHBAdata, SCSI_REPORT_LUNS, fchs );
+	cpqfcTSPutLinkQue(cpqfcHBAdata, SCSI_REPORT_LUNS, fchs, 0);
 	
 	// It's possible that a device we were talking to changed 
 	// port_id, and has logged back in.  This function ensures
@@ -1971,8 +1938,7 @@ static void ProcessELS_Reply( 
 
     // now send out a PLOGI to the well known port_id 0xFFFFFC
     fchs->s_id = 0xFFFFFC;
-    cpqfcTSPutLinkQue( cpqfcHBAdata, ELS_PLOGI, fchs);
-  
+	cpqfcTSPutLinkQue(cpqfcHBAdata, ELS_PLOGI, fchs, 0);
    break; 
 
 
@@ -1988,9 +1954,7 @@ static void ProcessELS_Reply( 
    
 	
     fchs->s_id = 0xFFFFFC;  // Name Server Address
-    cpqfcTSPutLinkQue( cpqfcHBAdata, FCS_NSR, fchs);
-    
-
+	cpqfcTSPutLinkQue(cpqfcHBAdata, FCS_NSR, fchs, 0);
     break;
 
     
@@ -2199,7 +2163,7 @@ static void AnalyzeIncomingFrame( 
 	  memcpy( fcChip->LILPmap, &fchs->pl[1], 32*4); // 32 DWORDs
 	  fcChip->Options.LILPin = 1; // our LILPmap is valid!
 	  // now post to make Port Discovery happen...
-          cpqfcTSPutLinkQue( cpqfcHBAdata, LINKACTIVE, fchs);  
+		cpqfcTSPutLinkQue(cpqfcHBAdata, LINKACTIVE, fchs, 0);
 	}
       }
     }
@@ -2252,9 +2216,7 @@ static void AnalyzeIncomingFrame( 
               fchs->ox_rx_id = 
                 Exchanges->fcExchange[ ExchangeID].fchs.ox_rx_id;
                 
-              cpqfcTSPutLinkQue( cpqfcHBAdata,
-                            BLS_ABTS_ACC, // Q Type 
-                            fchs );    // void QueContent
+		cpqfcTSPutLinkQue(cpqfcHBAdata, BLS_ABTS_ACC, fchs, 0);
               AbortAccept = TRUE;
       printk("ACCepting ABTS for x_ID %8.8Xh, SEST pair %8.8Xh\n", 
              fchs->ox_rx_id, Exchanges->fcExchange[ ExchangeID].fchs.ox_rx_id);
@@ -2727,7 +2689,7 @@ static void ScsiReportLunsDone(Scsi_Cmnd
       // context is "reply to source".
       
         fchs->s_id = fchs->d_id; // (temporarily re-use the struct)
-        cpqfcTSPutLinkQue( cpqfcHBAdata, SCSI_REPORT_LUNS, fchs );
+	cpqfcTSPutLinkQue(cpqfcHBAdata, SCSI_REPORT_LUNS, fchs, 0);
       }
     }
     else  // probably, the device doesn't support Report Luns
@@ -3180,7 +3142,7 @@ void cpqfcTSheartbeat( unsigned long ptr
            
             // We expect the WorkerThread to change the xchng type to
             // abort and set appropriate timeout.
-            cpqfcTSPutLinkQue( cpqfcHBAdata, BLS_ABTS, &i ); // timed-out
+		cpqfcTSPutLinkQue(cpqfcHBAdata, BLS_ABTS, NULL, i); /* timed-out */
 	  }
         }
       }

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2005-08-17  8:56 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-05 10:02 [PATCH 2.6.13-rc5] reduce whitespace bloat in drivers/scsi/cpqfcTScontrol.c Rolf Eike Beer
2005-08-09 16:06 ` [PATCH 2.6.13-rc5] rewrite drivers/scsi/cpqfcTScontrol.c::CpqTsGetSFQEntry Rolf Eike Beer
2005-08-16  9:11   ` [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver Rolf Eike Beer
2005-08-16  9:11     ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for " Rolf Eike Beer
2005-08-16  9:12       ` [PATCH 2.6.13-rc6] remove 2.4 compat code from " Rolf Eike Beer
2005-08-16  9:13         ` [PATCH 2.6.13-rc6] more whitespace cleanups for cpqfcTS Rolf Eike Beer
2005-08-16  9:14           ` [PATCH 2.6.13-rc6] remove superfluos ioctls from cpqfcTS Rolf Eike Beer
2005-08-16 14:58             ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver Rolf Eike Beer
2005-08-16 16:20               ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 2 Rolf Eike Beer
2005-08-16 16:24                 ` Christoph Hellwig
2005-08-16 17:09                 ` [PATCH 2.6.13-rc6] improve start/stop code for worker thread in cpqfcTS driver, take 3 Rolf Eike Beer
2005-08-17  8:57                   ` [PATCH 2.6.13-rc6] fix copying stack memory in cpqfcTScontrol.c::cpqfcTSPutLinkQue() Rolf Eike Beer
2005-08-16 14:28         ` [PATCH 2.6.13-rc6] remove 2.4 compat code from cpqfcTS driver, take 2 Rolf Eike Beer
2005-08-16 14:51           ` [PATCH 2.6.13-rc6] remove 2.4 compat code from cpqfcTS driver, take 3 Rolf Eike Beer
2005-08-16 12:53       ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver Jiri Slaby
2005-08-16 13:57         ` Rolf Eike Beer
2005-08-16 14:36       ` [PATCH 2.6.13-rc6] MODULE_DEVICE_TABLE for cpqfcTS driver, take 2 Rolf Eike Beer
2005-08-16  9:17     ` [PATCH 2.6.13-rc6] remove dead reset function from cpqfcTS driver Christoph Hellwig
2005-08-16  9:37       ` Rolf Eike Beer
2005-08-16 14:49         ` Martin K. Petersen
2005-08-16 15:07           ` Rolf Eike Beer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).