aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2007-03-17 12:28:27 -0400
committerKyle McMartin <kyle@athena.road.mcmartin.ca>2007-05-22 22:43:01 -0400
commit27f282b9c6ec0c2ed64778ca154674929eefb195 (patch)
tree672cda5eb28857255d0c299fd2b92ea6742c529c /arch
parentfd3eef10f5a55acdefbd3f53ca7618a35cb6231f (diff)
parisc: convert /proc/gsc/pcxl_dma to seq_file
As side effect, remove one more ->get_info user and a novel approach of content generation: sprintf(buf, "%sfoo", buf, ...); sprintf(buf, "%sbar", buf, ...); ... Compile-tested. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/parisc/kernel/pci-dma.c94
1 files changed, 53 insertions, 41 deletions
diff --git a/arch/parisc/kernel/pci-dma.c b/arch/parisc/kernel/pci-dma.c
index 0c3aecb85a5c..23c1388df1f5 100644
--- a/arch/parisc/kernel/pci-dma.c
+++ b/arch/parisc/kernel/pci-dma.c
@@ -21,6 +21,7 @@
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/proc_fs.h> 23#include <linux/proc_fs.h>
24#include <linux/seq_file.h>
24#include <linux/slab.h> 25#include <linux/slab.h>
25#include <linux/string.h> 26#include <linux/string.h>
26#include <linux/types.h> 27#include <linux/types.h>
@@ -34,7 +35,6 @@
34#include <asm/tlbflush.h> /* for purge_tlb_*() macros */ 35#include <asm/tlbflush.h> /* for purge_tlb_*() macros */
35 36
36static struct proc_dir_entry * proc_gsc_root __read_mostly = NULL; 37static struct proc_dir_entry * proc_gsc_root __read_mostly = NULL;
37static int pcxl_proc_info(char *buffer, char **start, off_t offset, int length);
38static unsigned long pcxl_used_bytes __read_mostly = 0; 38static unsigned long pcxl_used_bytes __read_mostly = 0;
39static unsigned long pcxl_used_pages __read_mostly = 0; 39static unsigned long pcxl_used_pages __read_mostly = 0;
40 40
@@ -330,6 +330,54 @@ pcxl_free_range(unsigned long vaddr, size_t size)
330 dump_resmap(); 330 dump_resmap();
331} 331}
332 332
333static int proc_pcxl_dma_show(struct seq_file *m, void *v)
334{
335#if 0
336 u_long i = 0;
337 unsigned long *res_ptr = (u_long *)pcxl_res_map;
338#endif
339 unsigned long total_pages = pcxl_res_size << 3; /* 8 bits per byte */
340
341 seq_printf(m, "\nDMA Mapping Area size : %d bytes (%ld pages)\n",
342 PCXL_DMA_MAP_SIZE, total_pages);
343
344 seq_printf(m, "Resource bitmap : %d bytes\n", pcxl_res_size);
345
346 seq_puts(m, " total: free: used: % used:\n");
347 seq_printf(m, "blocks %8d %8ld %8ld %8ld%%\n", pcxl_res_size,
348 pcxl_res_size - pcxl_used_bytes, pcxl_used_bytes,
349 (pcxl_used_bytes * 100) / pcxl_res_size);
350
351 seq_printf(m, "pages %8ld %8ld %8ld %8ld%%\n", total_pages,
352 total_pages - pcxl_used_pages, pcxl_used_pages,
353 (pcxl_used_pages * 100 / total_pages));
354
355#if 0
356 seq_puts(m, "\nResource bitmap:");
357
358 for(; i < (pcxl_res_size / sizeof(u_long)); ++i, ++res_ptr) {
359 if ((i & 7) == 0)
360 seq_puts(m,"\n ");
361 seq_printf(m, "%s %08lx", buf, *res_ptr);
362 }
363#endif
364 seq_putc(m, '\n');
365 return 0;
366}
367
368static int proc_pcxl_dma_open(struct inode *inode, struct file *file)
369{
370 return single_open(file, proc_pcxl_dma_show, NULL);
371}
372
373static const struct file_operations proc_pcxl_dma_ops = {
374 .owner = THIS_MODULE,
375 .open = proc_pcxl_dma_open,
376 .read = seq_read,
377 .llseek = seq_lseek,
378 .release = single_release,
379};
380
333static int __init 381static int __init
334pcxl_dma_init(void) 382pcxl_dma_init(void)
335{ 383{
@@ -348,9 +396,10 @@ pcxl_dma_init(void)
348 "pcxl_dma_init: Unable to create gsc /proc dir entry\n"); 396 "pcxl_dma_init: Unable to create gsc /proc dir entry\n");
349 else { 397 else {
350 struct proc_dir_entry* ent; 398 struct proc_dir_entry* ent;
351 ent = create_proc_info_entry("pcxl_dma", 0, 399 ent = create_proc_entry("pcxl_dma", 0, proc_gsc_root);
352 proc_gsc_root, pcxl_proc_info); 400 if (ent)
353 if (!ent) 401 ent->proc_fops = &proc_pcxl_dma_ops;
402 else
354 printk(KERN_WARNING 403 printk(KERN_WARNING
355 "pci-dma.c: Unable to create pcxl_dma /proc entry.\n"); 404 "pci-dma.c: Unable to create pcxl_dma /proc entry.\n");
356 } 405 }
@@ -551,40 +600,3 @@ struct hppa_dma_ops pcx_dma_ops = {
551 .dma_sync_sg_for_cpu = pa11_dma_sync_sg_for_cpu, 600 .dma_sync_sg_for_cpu = pa11_dma_sync_sg_for_cpu,
552 .dma_sync_sg_for_device = pa11_dma_sync_sg_for_device, 601 .dma_sync_sg_for_device = pa11_dma_sync_sg_for_device,
553}; 602};
554
555
556static int pcxl_proc_info(char *buf, char **start, off_t offset, int len)
557{
558#if 0
559 u_long i = 0;
560 unsigned long *res_ptr = (u_long *)pcxl_res_map;
561#endif
562 unsigned long total_pages = pcxl_res_size << 3; /* 8 bits per byte */
563
564 sprintf(buf, "\nDMA Mapping Area size : %d bytes (%ld pages)\n",
565 PCXL_DMA_MAP_SIZE, total_pages);
566
567 sprintf(buf, "%sResource bitmap : %d bytes\n", buf, pcxl_res_size);
568
569 strcat(buf, " total: free: used: % used:\n");
570 sprintf(buf, "%sblocks %8d %8ld %8ld %8ld%%\n", buf, pcxl_res_size,
571 pcxl_res_size - pcxl_used_bytes, pcxl_used_bytes,
572 (pcxl_used_bytes * 100) / pcxl_res_size);
573
574 sprintf(buf, "%spages %8ld %8ld %8ld %8ld%%\n", buf, total_pages,
575 total_pages - pcxl_used_pages, pcxl_used_pages,
576 (pcxl_used_pages * 100 / total_pages));
577
578#if 0
579 strcat(buf, "\nResource bitmap:");
580
581 for(; i < (pcxl_res_size / sizeof(u_long)); ++i, ++res_ptr) {
582 if ((i & 7) == 0)
583 strcat(buf,"\n ");
584 sprintf(buf, "%s %08lx", buf, *res_ptr);
585 }
586#endif
587 strcat(buf, "\n");
588 return strlen(buf);
589}
590