diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-09-18 15:58:47 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-10-01 15:15:40 -0400 |
commit | ff2c3de305e2d06ae556e1a382ed75c5dd8f9dda (patch) | |
tree | 449467f415870884fd455e87027e6c82557d6f9a /drivers | |
parent | 17d857be649a21ca90008c6dc425d849fa83db5c (diff) |
cpqarray: switch to seq_file
Signed-off-by: Alexey 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/cpqarray.c | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index b82d438e2607..6422651ec364 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/blkpg.h> | 32 | #include <linux/blkpg.h> |
33 | #include <linux/timer.h> | 33 | #include <linux/timer.h> |
34 | #include <linux/proc_fs.h> | 34 | #include <linux/proc_fs.h> |
35 | #include <linux/seq_file.h> | ||
35 | #include <linux/init.h> | 36 | #include <linux/init.h> |
36 | #include <linux/hdreg.h> | 37 | #include <linux/hdreg.h> |
37 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
@@ -177,7 +178,6 @@ static int cpqarray_register_ctlr(int ctlr, struct pci_dev *pdev); | |||
177 | 178 | ||
178 | #ifdef CONFIG_PROC_FS | 179 | #ifdef CONFIG_PROC_FS |
179 | static void ida_procinit(int i); | 180 | static void ida_procinit(int i); |
180 | static int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data); | ||
181 | #else | 181 | #else |
182 | static void ida_procinit(int i) {} | 182 | static void ida_procinit(int i) {} |
183 | #endif | 183 | #endif |
@@ -206,6 +206,7 @@ static const struct block_device_operations ida_fops = { | |||
206 | #ifdef CONFIG_PROC_FS | 206 | #ifdef CONFIG_PROC_FS |
207 | 207 | ||
208 | static struct proc_dir_entry *proc_array; | 208 | static struct proc_dir_entry *proc_array; |
209 | static const struct file_operations ida_proc_fops; | ||
209 | 210 | ||
210 | /* | 211 | /* |
211 | * Get us a file in /proc/array that says something about each controller. | 212 | * 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 | if (!proc_array) return; | 219 | if (!proc_array) return; |
219 | } | 220 | } |
220 | 221 | ||
221 | create_proc_read_entry(hba[i]->devname, 0, proc_array, | 222 | proc_create_data(hba[i]->devname, 0, proc_array, &ida_proc_fops, hba[i]); |
222 | ida_proc_get_info, hba[i]); | ||
223 | } | 223 | } |
224 | 224 | ||
225 | /* | 225 | /* |
226 | * Report information about this controller. | 226 | * Report information about this controller. |
227 | */ | 227 | */ |
228 | static int ida_proc_get_info(char *buffer, char **start, off_t offset, int length, int *eof, void *data) | 228 | static int ida_proc_show(struct seq_file *m, void *v) |
229 | { | 229 | { |
230 | off_t pos = 0; | 230 | int i, ctlr; |
231 | off_t len = 0; | 231 | ctlr_info_t *h = (ctlr_info_t*)m->private; |
232 | int size, i, ctlr; | ||
233 | ctlr_info_t *h = (ctlr_info_t*)data; | ||
234 | drv_info_t *drv; | 232 | drv_info_t *drv; |
235 | #ifdef CPQ_PROC_PRINT_QUEUES | 233 | #ifdef CPQ_PROC_PRINT_QUEUES |
236 | cmdlist_t *c; | 234 | cmdlist_t *c; |
@@ -238,7 +236,7 @@ static int ida_proc_get_info(char *buffer, char **start, off_t offset, int lengt | |||
238 | #endif | 236 | #endif |
239 | 237 | ||
240 | ctlr = h->ctlr; | 238 | ctlr = h->ctlr; |
241 | size = sprintf(buffer, "%s: Compaq %s Controller\n" | 239 | seq_printf(m, "%s: Compaq %s Controller\n" |
242 | " Board ID: 0x%08lx\n" | 240 | " Board ID: 0x%08lx\n" |
243 | " Firmware Revision: %c%c%c%c\n" | 241 | " Firmware Revision: %c%c%c%c\n" |
244 | " Controller Sig: 0x%08lx\n" | 242 | " 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 | h->log_drives, h->phys_drives, | 256 | h->log_drives, h->phys_drives, |
259 | h->Qdepth, h->maxQsinceinit); | 257 | h->Qdepth, h->maxQsinceinit); |
260 | 258 | ||
261 | pos += size; len += size; | 259 | seq_puts(m, "Logical Drive Info:\n"); |
262 | |||
263 | size = sprintf(buffer+len, "Logical Drive Info:\n"); | ||
264 | pos += size; len += size; | ||
265 | 260 | ||
266 | for(i=0; i<h->log_drives; i++) { | 261 | for(i=0; i<h->log_drives; i++) { |
267 | drv = &h->drv[i]; | 262 | drv = &h->drv[i]; |
268 | size = sprintf(buffer+len, "ida/c%dd%d: blksz=%d nr_blks=%d\n", | 263 | seq_printf(m, "ida/c%dd%d: blksz=%d nr_blks=%d\n", |
269 | ctlr, i, drv->blk_size, drv->nr_blks); | 264 | ctlr, i, drv->blk_size, drv->nr_blks); |
270 | pos += size; len += size; | ||
271 | } | 265 | } |
272 | 266 | ||
273 | #ifdef CPQ_PROC_PRINT_QUEUES | 267 | #ifdef CPQ_PROC_PRINT_QUEUES |
274 | spin_lock_irqsave(IDA_LOCK(h->ctlr), flags); | 268 | spin_lock_irqsave(IDA_LOCK(h->ctlr), flags); |
275 | size = sprintf(buffer+len, "\nCurrent Queues:\n"); | 269 | seq_puts(m, "\nCurrent Queues:\n"); |
276 | pos += size; len += size; | ||
277 | 270 | ||
278 | c = h->reqQ; | 271 | c = h->reqQ; |
279 | size = sprintf(buffer+len, "reqQ = %p", c); pos += size; len += size; | 272 | seq_printf(m, "reqQ = %p", c); |
280 | if (c) c=c->next; | 273 | if (c) c=c->next; |
281 | while(c && c != h->reqQ) { | 274 | while(c && c != h->reqQ) { |
282 | size = sprintf(buffer+len, "->%p", c); | 275 | seq_printf(m, "->%p", c); |
283 | pos += size; len += size; | ||
284 | c=c->next; | 276 | c=c->next; |
285 | } | 277 | } |
286 | 278 | ||
287 | c = h->cmpQ; | 279 | c = h->cmpQ; |
288 | size = sprintf(buffer+len, "\ncmpQ = %p", c); pos += size; len += size; | 280 | seq_printf(m, "\ncmpQ = %p", c); |
289 | if (c) c=c->next; | 281 | if (c) c=c->next; |
290 | while(c && c != h->cmpQ) { | 282 | while(c && c != h->cmpQ) { |
291 | size = sprintf(buffer+len, "->%p", c); | 283 | seq_printf(m, "->%p", c); |
292 | pos += size; len += size; | ||
293 | c=c->next; | 284 | c=c->next; |
294 | } | 285 | } |
295 | 286 | ||
296 | size = sprintf(buffer+len, "\n"); pos += size; len += size; | 287 | seq_putc(m, '\n'); |
297 | spin_unlock_irqrestore(IDA_LOCK(h->ctlr), flags); | 288 | spin_unlock_irqrestore(IDA_LOCK(h->ctlr), flags); |
298 | #endif | 289 | #endif |
299 | size = sprintf(buffer+len, "nr_allocs = %d\nnr_frees = %d\n", | 290 | seq_printf(m, "nr_allocs = %d\nnr_frees = %d\n", |
300 | h->nr_allocs, h->nr_frees); | 291 | h->nr_allocs, h->nr_frees); |
301 | pos += size; len += size; | 292 | return 0; |
302 | 293 | } | |
303 | *eof = 1; | 294 | |
304 | *start = buffer+offset; | 295 | static int ida_proc_open(struct inode *inode, struct file *file) |
305 | len -= offset; | 296 | { |
306 | if (len>length) | 297 | return single_open(file, ida_proc_show, PDE(inode)->data); |
307 | len = length; | ||
308 | return len; | ||
309 | } | 298 | } |
299 | |||
300 | static const struct file_operations ida_proc_fops = { | ||
301 | .owner = THIS_MODULE, | ||
302 | .open = ida_proc_open, | ||
303 | .read = seq_read, | ||
304 | .llseek = seq_lseek, | ||
305 | .release = single_release, | ||
306 | }; | ||
310 | #endif /* CONFIG_PROC_FS */ | 307 | #endif /* CONFIG_PROC_FS */ |
311 | 308 | ||
312 | module_param_array(eisa, int, NULL, 0); | 309 | module_param_array(eisa, int, NULL, 0); |