[PATCH] cpqarray: Cleanups about ida_proc_get_info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, this patch do some fixes about ida_proc_get_info().

	- Removes unused local variables
	- Eliminates possible null pointers
	- Rewrite spin locks order
	- Define unused CPQ_PROC_PRINT_QUEUES


Signed-off-by: Laura Garcia Liebana <[email protected]>

diff -Nru a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
--- a/drivers/block/cpqarray.c  2006-06-13 01:03:02.000000000 +0200
+++ b/drivers/block/cpqarray.c  2006-06-13 01:01:29.000000000 +0200
@@ -227,11 +227,11 @@
 /*
  * Report information about this controller.
  */
-static int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int *e
of, void *data)
+static int ida_proc_get_info(char *buffer, char **start, off_t offset, 
+                                       int length, int *eof, void *data)
 {
-       off_t pos = 0;
        off_t len = 0;
-       int size, i, ctlr;
+       int i, ctlr;
        ctlr_info_t *h = (ctlr_info_t*)data;
        drv_info_t *drv;
 #ifdef CPQ_PROC_PRINT_QUEUES
@@ -240,7 +240,7 @@
 #endif
 
        ctlr = h->ctlr;
-       size = sprintf(buffer, "%s:  Compaq %s Controller\n"
+       len += sprintf(buffer, "%s:  Compaq %s Controller\n"
                "       Board ID: 0x%08lx\n"
                "       Firmware Revision: %c%c%c%c\n"
                "       Controller Sig: 0x%08lx\n"
@@ -260,47 +260,43 @@
                h->log_drives, h->phys_drives,
                h->Qdepth, h->maxQsinceinit);
 
-       pos += size; len += size;
-       
-       size = sprintf(buffer+len, "Logical Drive Info:\n");
-       pos += size; len += size;
+       len += sprintf(buffer+len, "Logical Drive Info:\n");
 
        for(i=0; i<h->log_drives; i++) {
                drv = &h->drv[i];
-               size = sprintf(buffer+len, "ida/c%dd%d: blksz=%d nr_blks=%d\n",
+               len += sprintf(buffer+len, "ida/c%dd%d: blksz=%d nr_blks=%d\n",
                                ctlr, i, drv->blk_size, drv->nr_blks);
-               pos += size; len += size;
        }
 
 #ifdef CPQ_PROC_PRINT_QUEUES
-       spin_lock_irqsave(IDA_LOCK(h->ctlr), flags); 
-       size = sprintf(buffer+len, "\nCurrent Queues:\n");
-       pos += size; len += size;
+       len += sprintf(buffer+len, "\nCurrent Queues:\n");
+       spin_lock_irqsave(IDA_LOCK(ctlr), flags); 
 
        c = h->reqQ;
-       size = sprintf(buffer+len, "reqQ = %p", c); pos += size; len += size;
-       if (c) c=c->next;
-       while(c && c != h->reqQ) {
-               size = sprintf(buffer+len, "->%p", c);
-               pos += size; len += size;
+       if (c) {
+               len += sprintf(buffer+len, "reqQ = %p", c);
                c=c->next;
+               while(c && c != h->reqQ) {
+                       len += sprintf(buffer+len, "->%p", c);
+                       c=c->next;
+               }
        }
 
        c = h->cmpQ;
-       size = sprintf(buffer+len, "\ncmpQ = %p", c); pos += size; len += size;
-       if (c) c=c->next;
-       while(c && c != h->cmpQ) {
-               size = sprintf(buffer+len, "->%p", c);
-               pos += size; len += size;
+       if (c) {
+               len += sprintf(buffer+len, "\ncmpQ = %p", c);
                c=c->next;
+               while(c && c != h->cmpQ) {
+                       len += sprintf(buffer+len, "->%p", c);
+                       c=c->next;
+               }
        }
 
-       size = sprintf(buffer+len, "\n"); pos += size; len += size;
-       spin_unlock_irqrestore(IDA_LOCK(h->ctlr), flags); 
+       spin_unlock_irqrestore(IDA_LOCK(ctlr), flags); 
+       len += sprintf(buffer+len, "\n");
 #endif
-       size = sprintf(buffer+len, "nr_allocs = %d\nnr_frees = %d\n",
+       len += sprintf(buffer+len, "nr_allocs = %d\nnr_frees = %d\n",
                        h->nr_allocs, h->nr_frees);
-       pos += size; len += size;
 
        *eof = 1;
        *start = buffer+offset;
diff -Nru a/drivers/block/Kconfig b/drivers/block/Kconfig
--- a/drivers/block/Kconfig     2006-06-13 01:04:44.000000000 +0200
+++ b/drivers/block/Kconfig     2006-06-13 01:01:29.000000000 +0200
@@ -154,6 +154,13 @@
          supported by this driver, and for further information on the use of
          this driver.
 
+config CPQ_PROC_PRINT_QUEUES
+       bool "Print Smart Array Queues information"
+       depends on BLK_CPQ_DA
+       help
+         This option prints some extra information about Smart Array Queues
+         under proc filesystem.
+
 config BLK_CPQ_CISS_DA
        tristate "Compaq Smart Array 5xxx support"
        depends on PCI

Attachment: cpqarray-ida_proc_get_info.patch
Description: Binary data


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux