diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-09-01 20:54:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-01 20:54:07 -0400 |
commit | e7a088f935180b90cfe6ab0aaae8a556f46885fe (patch) | |
tree | 3456eea4f37e1dfa590fed0cb24090c7ebbf29f5 /arch/sparc/kernel/ioport.c | |
parent | 75d9e34698540e96b422293e1d76ab02cc7faefb (diff) |
sparc: convert /proc/io_map, /proc/dvma_map to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel/ioport.c')
-rw-r--r-- | arch/sparc/kernel/ioport.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c index 87ea0d03d975..e71ce79d8c15 100644 --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
36 | #include <linux/pci.h> /* struct pci_dev */ | 36 | #include <linux/pci.h> /* struct pci_dev */ |
37 | #include <linux/proc_fs.h> | 37 | #include <linux/proc_fs.h> |
38 | #include <linux/seq_file.h> | ||
38 | #include <linux/scatterlist.h> | 39 | #include <linux/scatterlist.h> |
39 | #include <linux/of_device.h> | 40 | #include <linux/of_device.h> |
40 | 41 | ||
@@ -663,26 +664,33 @@ EXPORT_SYMBOL(pci_dma_sync_sg_for_device); | |||
663 | 664 | ||
664 | #ifdef CONFIG_PROC_FS | 665 | #ifdef CONFIG_PROC_FS |
665 | 666 | ||
666 | static int | 667 | static int sparc_io_proc_show(struct seq_file *m, void *v) |
667 | _sparc_io_get_info(char *buf, char **start, off_t fpos, int length, int *eof, | ||
668 | void *data) | ||
669 | { | 668 | { |
670 | char *p = buf, *e = buf + length; | 669 | struct resource *root = m->private, *r; |
671 | struct resource *r; | ||
672 | const char *nm; | 670 | const char *nm; |
673 | 671 | ||
674 | for (r = ((struct resource *)data)->child; r != NULL; r = r->sibling) { | 672 | for (r = root->child; r != NULL; r = r->sibling) { |
675 | if (p + 32 >= e) /* Better than nothing */ | ||
676 | break; | ||
677 | if ((nm = r->name) == 0) nm = "???"; | 673 | if ((nm = r->name) == 0) nm = "???"; |
678 | p += sprintf(p, "%016llx-%016llx: %s\n", | 674 | seq_printf(m, "%016llx-%016llx: %s\n", |
679 | (unsigned long long)r->start, | 675 | (unsigned long long)r->start, |
680 | (unsigned long long)r->end, nm); | 676 | (unsigned long long)r->end, nm); |
681 | } | 677 | } |
682 | 678 | ||
683 | return p-buf; | 679 | return 0; |
684 | } | 680 | } |
685 | 681 | ||
682 | static int sparc_io_proc_open(struct inode *inode, struct file *file) | ||
683 | { | ||
684 | return single_open(file, sparc_io_proc_show, PDE(inode)->data); | ||
685 | } | ||
686 | |||
687 | static const struct file_operations sparc_io_proc_fops = { | ||
688 | .owner = THIS_MODULE, | ||
689 | .open = sparc_io_proc_open, | ||
690 | .read = seq_read, | ||
691 | .llseek = seq_lseek, | ||
692 | .release = single_release, | ||
693 | }; | ||
686 | #endif /* CONFIG_PROC_FS */ | 694 | #endif /* CONFIG_PROC_FS */ |
687 | 695 | ||
688 | /* | 696 | /* |
@@ -707,7 +715,7 @@ static struct resource *_sparc_find_resource(struct resource *root, | |||
707 | static void register_proc_sparc_ioport(void) | 715 | static void register_proc_sparc_ioport(void) |
708 | { | 716 | { |
709 | #ifdef CONFIG_PROC_FS | 717 | #ifdef CONFIG_PROC_FS |
710 | create_proc_read_entry("io_map",0,NULL,_sparc_io_get_info,&sparc_iomap); | 718 | proc_create_data("io_map", 0, NULL, &sparc_io_proc_fops, &sparc_iomap); |
711 | create_proc_read_entry("dvma_map",0,NULL,_sparc_io_get_info,&_sparc_dvma); | 719 | proc_create_data("dvma_map", 0, NULL, &sparc_io_proc_fops, &_sparc_dvma); |
712 | #endif | 720 | #endif |
713 | } | 721 | } |