patch-2.0.32 linux/drivers/scsi/aic7xxx_proc.c

Next file: linux/drivers/scsi/aic7xxx_reg.h
Previous file: linux/drivers/scsi/aic7xxx.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.31/linux/drivers/scsi/aic7xxx_proc.c linux/drivers/scsi/aic7xxx_proc.c
@@ -51,6 +51,13 @@
 #  define proc_debug(fmt, args...)
 #endif /* PROC_DEBUG */
 
+static int aic7xxx_buffer_size = 0;
+static char *aic7xxx_buffer = NULL;
+static const char *bus_names[] = { "Single", "Twin", "Wide" };
+static const char *chip_names[] = { "AIC-777x", "AIC-785x", "AIC-786x",
+   "AIC-787x", "AIC-788x" };
+
+
 /*+F*************************************************************************
  * Function:
  *   aic7xxx_set_info
@@ -64,7 +71,8 @@
   proc_debug("aic7xxx_set_info(): %s\n", buffer);
   return (-ENOSYS);  /* Currently this is a no-op */
 }
- 
+
+
 /*+F*************************************************************************
  * Function:
  *   aic7xxx_proc_info
@@ -78,14 +86,9 @@
 {
   struct Scsi_Host *HBAptr;
   struct aic7xxx_host *p;
-  static int aic7xxx_buffer_size = 0;
   int    found = FALSE;
-  static int   size = 0;
+  int    size = 0;
   unsigned char i;
-  static char *aic7xxx_buffer = NULL;
-  static char *bus_names[] = { "Single", "Twin", "Wide" };
-  static char *chip_names[] = { "AIC-777x", "AIC-785x", "AIC-786x",
-      "AIC-787x", "AIC-788x" };
 #ifdef AIC7XXX_PROC_STATS
   struct aic7xxx_xferstats *sp;
   unsigned char target, lun;
@@ -100,7 +103,7 @@
       {
         break;
       }
-      
+
       while ((HBAptr->hostdata != NULL) && !found &&
           ((HBAptr = ((struct aic7xxx_host *) HBAptr->hostdata)->next) != NULL))
       {
@@ -109,7 +112,7 @@
           found = TRUE;
         }
       }
-      
+
       if (!found)
       {
         HBAptr = NULL;
@@ -120,49 +123,59 @@
       }
     }
   }
-  
+
   if (HBAptr == NULL)
   {
-    size += sprintf( buffer, "Can't find adapter for host number %d\n", hostno);
-    if ( size > length) return size;
-    return length;
+    size += sprintf(buffer, "Can't find adapter for host number %d\n", hostno);
+    if (size > length)
+    {
+      return (size);
+    }
+    else
+    {
+      return (length);
+    }
   }
-  
+
   if (inout == TRUE) /* Has data been written to the file? */ 
   {
     return (aic7xxx_set_info(buffer, length, HBAptr));
   }
-  
+
   p = (struct aic7xxx_host *) HBAptr->hostdata;
 
-  /* It takes roughly 1K of space to hold all relevant card info, not     */
-  /* counting any proc stats, so we start out with a 1.5k buffer size and */
-  /* if proc_stats is defined, then we sweep the stats structure to see   */
-  /* how many drives we will be printing out for and add 384 bytes per    */
-  /* device with active stats.                                            */
+  /*
+   * It takes roughly 1K of space to hold all relevant card info, not
+   * counting any proc stats, so we start out with a 1.5k buffer size and
+   * if proc_stats is defined, then we sweep the stats structure to see
+   * how many drives we will be printing out for and add 384 bytes per
+   * device with active stats.
+   */
 
   size = 1536;
 #ifdef AIC7XXX_PROC_STATS
-  for (target=0; target<16; target++)
+  for (target = 0; target < MAX_TARGETS; target++)
   {
-    for (lun=0; lun<8; lun++)
+    for (lun = 0; lun < MAX_LUNS; lun++)
     {
       if (p->stats[target][lun].xfers != 0)
         size += 384;
     }
   }
 #endif
-  if ( aic7xxx_buffer_size != size) {
-    if ( aic7xxx_buffer != NULL) 
+  if (aic7xxx_buffer_size != size)
+  {
+    if (aic7xxx_buffer != NULL) 
     {
-      kfree  ( aic7xxx_buffer);
+      kfree(aic7xxx_buffer);
       aic7xxx_buffer_size = 0;
     }
-    aic7xxx_buffer = kmalloc ( size, GFP_KERNEL);
+    aic7xxx_buffer = kmalloc(size, GFP_KERNEL);
   }
-  if ( aic7xxx_buffer == NULL) {
-    size = sprintf ( buffer, "AIC7xxx - kmalloc error at line %d\n",
-                                     __LINE__);
+  if (aic7xxx_buffer == NULL)
+  {
+    size = sprintf(buffer, "AIC7xxx - kmalloc error at line %d\n",
+        __LINE__);
     return size;
   }
   aic7xxx_buffer_size = size;
@@ -177,12 +190,10 @@
   size += sprintf(BLS, "\n");
   size += sprintf(BLS, "Compile Options:\n");
 #ifdef AIC7XXX_RESET_DELAY
-  size += sprintf(BLS, "  AIC7XXX_RESET_DELAY    : %d\n",
-                     AIC7XXX_RESET_DELAY);
+  size += sprintf(BLS, "  AIC7XXX_RESET_DELAY    : %d\n", AIC7XXX_RESET_DELAY);
 #endif
 #ifdef AIC7XXX_CMDS_PER_LUN
-  size += sprintf(BLS, "  AIC7XXX_CMDS_PER_LUN   : %d\n",
-                     AIC7XXX_CMDS_PER_LUN);
+  size += sprintf(BLS, "  AIC7XXX_CMDS_PER_LUN   : %d\n", AIC7XXX_CMDS_PER_LUN);
 #endif
 #ifdef AIC7XXX_TAGGED_QUEUEING
   size += sprintf(BLS, "  AIC7XXX_TAGGED_QUEUEING: Enabled\n");
@@ -201,18 +212,17 @@
 #endif
   size += sprintf(BLS, "\n");
   size += sprintf(BLS, "Adapter Configuration:\n");
-  size += sprintf(BLS, "          SCSI Adapter: %s\n",
-         board_names[p->chip_type]);
-  size += sprintf(BLS, "                        (%s chipset)\n",
-         chip_names[p->chip_class]);
-  size += sprintf(BLS, "              Host Bus: %s\n",
-                     bus_names[p->bus_type]);
-  size += sprintf(BLS, "               Base IO: %#.4x\n", p->base);
-  size += sprintf(BLS, "        Base IO Memory: 0x%x\n", p->mbase);
-  size += sprintf(BLS, "                   IRQ: %d\n", HBAptr->irq);
-  size += sprintf(BLS, "                  SCBs: Used %d, HW %d, Page %d\n",
-         p->scb_data->numscbs, p->scb_data->maxhscbs, p->scb_data->maxscbs);
-  size += sprintf(BLS, "            Interrupts: %d", p->isr_count);
+  size += sprintf(BLS, "           SCSI Adapter: %s\n",
+      board_names[p->chip_type]);
+  size += sprintf(BLS, "                         (%s chipset)\n",
+      chip_names[p->chip_class]);
+  size += sprintf(BLS, "               Host Bus: %s\n", bus_names[p->bus_type]);
+  size += sprintf(BLS, "                Base IO: %#.4x\n", p->base);
+  size += sprintf(BLS, "         Base IO Memory: 0x%x\n", p->mbase);
+  size += sprintf(BLS, "                    IRQ: %d\n", HBAptr->irq);
+  size += sprintf(BLS, "                   SCBs: Used %d, HW %d, Page %d\n",
+      p->scb_data->numscbs, p->scb_data->maxhscbs, p->scb_data->maxscbs);
+  size += sprintf(BLS, "             Interrupts: %d", p->isr_count);
   if (p->chip_class == AIC_777x)
   {
     size += sprintf(BLS, " %s\n",
@@ -222,23 +232,22 @@
   {
     size += sprintf(BLS, "\n");
   }
-  size += sprintf(BLS, "         Serial EEPROM: %s\n",
+  size += sprintf(BLS, "          Serial EEPROM: %s\n",
       (p->flags & HAVE_SEEPROM) ? "True" : "False");
-  size += sprintf(BLS, "  Extended Translation: %sabled\n",
+  size += sprintf(BLS, "   Extended Translation: %sabled\n",
       (p->flags & EXTENDED_TRANSLATION) ? "En" : "Dis");
-  size += sprintf(BLS, "        SCSI Bus Reset: %sabled\n",
+  size += sprintf(BLS, "         SCSI Bus Reset: %sabled\n",
       aic7xxx_no_reset ? "Dis" : "En");
-  size += sprintf(BLS, "            Ultra SCSI: %sabled\n",
+  size += sprintf(BLS, "             Ultra SCSI: %sabled\n",
       (p->flags & ULTRA_ENABLED) ? "En" : "Dis");
-  size += sprintf(BLS, "     Target Disconnect: %sabled\n",
-      p->discenable ? "En" : "Dis");
+  size += sprintf(BLS, "Disconnect Enable Flags: 0x%x\n", p->discenable);
   
 #ifdef AIC7XXX_PROC_STATS
   size += sprintf(BLS, "\n");
   size += sprintf(BLS, "Statistics:\n");
-  for (target = 0; target < 16; target++)
+  for (target = 0; target < MAX_TARGETS; target++)
   {
-    for (lun = 0; lun < 8; lun++)
+    for (lun = 0; lun < MAX_LUNS; lun++)
     {
       sp = &p->stats[target][lun];
       if (sp->xfers == 0)
@@ -246,42 +255,58 @@
         continue;
       }
       if (p->bus_type == AIC_TWIN)
+      {
         size += sprintf(BLS, "CHAN#%c (TGT %d LUN %d):\n",
             'A' + (target >> 3), (target & 0x7), lun);
+      }
       else
+      {
         size += sprintf(BLS, "CHAN#%c (TGT %d LUN %d):\n",
             'A', target, lun);
+      }
       size += sprintf(BLS, "nxfers %ld (%ld read;%ld written)\n",
-               sp->xfers, sp->r_total, sp->w_total);
+          sp->xfers, sp->r_total, sp->w_total);
       size += sprintf(BLS, "blks(512) rd=%ld; blks(512) wr=%ld\n",
-               sp->r_total512, sp->w_total512);
+          sp->r_total512, sp->w_total512);
       size += sprintf(BLS, "%s\n", HDRB);
       size += sprintf(BLS, " Reads:");
-      for (i=0; i<10; i++)
-             size += sprintf(BLS, "%6ld ", sp->r_bins[i]);
+      for (i = 0; i < NUMBER(sp->r_bins); i++)
+      {
+        size += sprintf(BLS, "%6ld ", sp->r_bins[i]);
+      }
       size += sprintf(BLS, "\n");
       size += sprintf(BLS, "Writes:");
-      for (i=0; i<10; i++)
-             size += sprintf(BLS, "%6ld ", sp->w_bins[i]);
+      for (i = 0; i < NUMBER(sp->w_bins); i++)
+      {
+        size += sprintf(BLS, "%6ld ", sp->w_bins[i]);
+      }
       size += sprintf(BLS, "\n\n");
     }
   }
 #endif /* AIC7XXX_PROC_STATS */
 
-  if ( size >= aic7xxx_buffer_size )
+  if (size >= aic7xxx_buffer_size)
+  {
     printk(KERN_WARNING "aic7xxx: Overflow in aic7xxx_proc.c\n");
+  }
 
-  if ( offset > size - 1) {
-     kfree ( aic7xxx_buffer);
-     aic7xxx_buffer = NULL;
-     aic7xxx_buffer_size = length = 0;
-     *start = NULL;
-  } else {
-     *start = &aic7xxx_buffer[offset];   /* Start of wanted data */
-     if ( size - offset < length) length = size - offset;
+  if (offset > size - 1)
+  {
+    kfree(aic7xxx_buffer);
+    aic7xxx_buffer = NULL;
+    aic7xxx_buffer_size = length = 0;
+    *start = NULL;
   }
-  
-  return length;
+  else
+  {
+    *start = &aic7xxx_buffer[offset];   /* Start of wanted data */
+    if (size - offset < length)
+    {
+      length = size - offset;
+    }
+  }
+
+  return (length);
 }
 
 /*

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov