From: Laura Garcia <nevola@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] cpqarray: Cleanups about ida_proc_get_info
Date: Tue, 13 Jun 2006 01:34:52 +0200 [thread overview]
Message-ID: <20060613013452.2e237f63@enano> (raw)
[-- Attachment #1: Type: text/plain, Size: 4508 bytes --]
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 <nevola@gmail.com>
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 #2: cpqarray-ida_proc_get_info.patch --]
[-- Type: application/octet-stream, Size: 3503 bytes --]
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 *eof, 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
reply other threads:[~2006-06-12 23:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20060613013452.2e237f63@enano \
--to=nevola@gmail.com \
--cc=linux-kernel@vger.kernel.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