public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rolf Eike Beer <eike-kernel@sf-tec.de>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: linux-scsi@vger.kernel.org,
	James Bottomley <James.Bottomley@steeleye.com>,
	Andrew Morton <akpm@osdl.org>, Linus Torvalds <torvalds@osdl.org>
Subject: [PATCH 2.6.13-rc5] rewrite drivers/scsi/cpqfcTScontrol.c::CpqTsGetSFQEntry
Date: Tue, 9 Aug 2005 18:06:43 +0200	[thread overview]
Message-ID: <200508091806.45341@bilbo.math.uni-mannheim.de> (raw)
In-Reply-To: <200508051202.07091@bilbo.math.uni-mannheim.de>

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,

  reply	other threads:[~2005-08-09 16:06 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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-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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200508091806.45341@bilbo.math.uni-mannheim.de \
    --to=eike-kernel@sf-tec.de \
    --cc=James.Bottomley@steeleye.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox