Commit ff2c3de3 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Jens Axboe

cpqarray: switch to seq_file

Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Cc: Chirag Kantharia <chirag.kantharia@hp.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 17d857be
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/blkpg.h> #include <linux/blkpg.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/hdreg.h> #include <linux/hdreg.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
...@@ -177,7 +178,6 @@ static int cpqarray_register_ctlr(int ctlr, struct pci_dev *pdev); ...@@ -177,7 +178,6 @@ static int cpqarray_register_ctlr(int ctlr, struct pci_dev *pdev);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static void ida_procinit(int i); static void ida_procinit(int i);
static int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data);
#else #else
static void ida_procinit(int i) {} static void ida_procinit(int i) {}
#endif #endif
...@@ -206,6 +206,7 @@ static const struct block_device_operations ida_fops = { ...@@ -206,6 +206,7 @@ static const struct block_device_operations ida_fops = {
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static struct proc_dir_entry *proc_array; static struct proc_dir_entry *proc_array;
static const struct file_operations ida_proc_fops;
/* /*
* Get us a file in /proc/array that says something about each controller. * Get us a file in /proc/array that says something about each controller.
...@@ -218,19 +219,16 @@ static void __init ida_procinit(int i) ...@@ -218,19 +219,16 @@ static void __init ida_procinit(int i)
if (!proc_array) return; if (!proc_array) return;
} }
create_proc_read_entry(hba[i]->devname, 0, proc_array, proc_create_data(hba[i]->devname, 0, proc_array, &ida_proc_fops, hba[i]);
ida_proc_get_info, hba[i]);
} }
/* /*
* Report information about this controller. * 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_show(struct seq_file *m, void *v)
{ {
off_t pos = 0; int i, ctlr;
off_t len = 0; ctlr_info_t *h = (ctlr_info_t*)m->private;
int size, i, ctlr;
ctlr_info_t *h = (ctlr_info_t*)data;
drv_info_t *drv; drv_info_t *drv;
#ifdef CPQ_PROC_PRINT_QUEUES #ifdef CPQ_PROC_PRINT_QUEUES
cmdlist_t *c; cmdlist_t *c;
...@@ -238,7 +236,7 @@ static int ida_proc_get_info(char *buffer, char **start, off_t offset, int lengt ...@@ -238,7 +236,7 @@ static int ida_proc_get_info(char *buffer, char **start, off_t offset, int lengt
#endif #endif
ctlr = h->ctlr; ctlr = h->ctlr;
size = sprintf(buffer, "%s: Compaq %s Controller\n" seq_printf(m, "%s: Compaq %s Controller\n"
" Board ID: 0x%08lx\n" " Board ID: 0x%08lx\n"
" Firmware Revision: %c%c%c%c\n" " Firmware Revision: %c%c%c%c\n"
" Controller Sig: 0x%08lx\n" " Controller Sig: 0x%08lx\n"
...@@ -258,55 +256,54 @@ static int ida_proc_get_info(char *buffer, char **start, off_t offset, int lengt ...@@ -258,55 +256,54 @@ static int ida_proc_get_info(char *buffer, char **start, off_t offset, int lengt
h->log_drives, h->phys_drives, h->log_drives, h->phys_drives,
h->Qdepth, h->maxQsinceinit); h->Qdepth, h->maxQsinceinit);
pos += size; len += size; seq_puts(m, "Logical Drive Info:\n");
size = sprintf(buffer+len, "Logical Drive Info:\n");
pos += size; len += size;
for(i=0; i<h->log_drives; i++) { for(i=0; i<h->log_drives; i++) {
drv = &h->drv[i]; drv = &h->drv[i];
size = sprintf(buffer+len, "ida/c%dd%d: blksz=%d nr_blks=%d\n", seq_printf(m, "ida/c%dd%d: blksz=%d nr_blks=%d\n",
ctlr, i, drv->blk_size, drv->nr_blks); ctlr, i, drv->blk_size, drv->nr_blks);
pos += size; len += size;
} }
#ifdef CPQ_PROC_PRINT_QUEUES #ifdef CPQ_PROC_PRINT_QUEUES
spin_lock_irqsave(IDA_LOCK(h->ctlr), flags); spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
size = sprintf(buffer+len, "\nCurrent Queues:\n"); seq_puts(m, "\nCurrent Queues:\n");
pos += size; len += size;
c = h->reqQ; c = h->reqQ;
size = sprintf(buffer+len, "reqQ = %p", c); pos += size; len += size; seq_printf(m, "reqQ = %p", c);
if (c) c=c->next; if (c) c=c->next;
while(c && c != h->reqQ) { while(c && c != h->reqQ) {
size = sprintf(buffer+len, "->%p", c); seq_printf(m, "->%p", c);
pos += size; len += size;
c=c->next; c=c->next;
} }
c = h->cmpQ; c = h->cmpQ;
size = sprintf(buffer+len, "\ncmpQ = %p", c); pos += size; len += size; seq_printf(m, "\ncmpQ = %p", c);
if (c) c=c->next; if (c) c=c->next;
while(c && c != h->cmpQ) { while(c && c != h->cmpQ) {
size = sprintf(buffer+len, "->%p", c); seq_printf(m, "->%p", c);
pos += size; len += size;
c=c->next; c=c->next;
} }
size = sprintf(buffer+len, "\n"); pos += size; len += size; seq_putc(m, '\n');
spin_unlock_irqrestore(IDA_LOCK(h->ctlr), flags); spin_unlock_irqrestore(IDA_LOCK(h->ctlr), flags);
#endif #endif
size = sprintf(buffer+len, "nr_allocs = %d\nnr_frees = %d\n", seq_printf(m, "nr_allocs = %d\nnr_frees = %d\n",
h->nr_allocs, h->nr_frees); h->nr_allocs, h->nr_frees);
pos += size; len += size; return 0;
}
*eof = 1;
*start = buffer+offset; static int ida_proc_open(struct inode *inode, struct file *file)
len -= offset; {
if (len>length) return single_open(file, ida_proc_show, PDE(inode)->data);
len = length;
return len;
} }
static const struct file_operations ida_proc_fops = {
.owner = THIS_MODULE,
.open = ida_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
module_param_array(eisa, int, NULL, 0); module_param_array(eisa, int, NULL, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment