aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-04-11 05:52:39 -0400
committerChristoph Hellwig <hch@lst.de>2018-05-16 01:24:30 -0400
commit4e292a9667558e5c2038a15c0eeb5d73bc1bd3c2 (patch)
tree8f2e888298831605e68f61666f0b91c52d7d0d00
parentdba5e4288d36630b961af89e9dde6eef750fe79d (diff)
resource: switch to proc_create_seq_data
And use the root resource directly from the proc private data. Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--kernel/resource.c43
1 files changed, 5 insertions, 38 deletions
diff --git a/kernel/resource.c b/kernel/resource.c
index 2af6c03858b9..b589dda910b3 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -87,7 +87,7 @@ enum { MAX_IORES_LEVEL = 5 };
87static void *r_start(struct seq_file *m, loff_t *pos) 87static void *r_start(struct seq_file *m, loff_t *pos)
88 __acquires(resource_lock) 88 __acquires(resource_lock)
89{ 89{
90 struct resource *p = m->private; 90 struct resource *p = PDE_DATA(file_inode(m->file));
91 loff_t l = 0; 91 loff_t l = 0;
92 read_lock(&resource_lock); 92 read_lock(&resource_lock);
93 for (p = p->child; p && l < *pos; p = r_next(m, p, &l)) 93 for (p = p->child; p && l < *pos; p = r_next(m, p, &l))
@@ -103,7 +103,7 @@ static void r_stop(struct seq_file *m, void *v)
103 103
104static int r_show(struct seq_file *m, void *v) 104static int r_show(struct seq_file *m, void *v)
105{ 105{
106 struct resource *root = m->private; 106 struct resource *root = PDE_DATA(file_inode(m->file));
107 struct resource *r = v, *p; 107 struct resource *r = v, *p;
108 unsigned long long start, end; 108 unsigned long long start, end;
109 int width = root->end < 0x10000 ? 4 : 8; 109 int width = root->end < 0x10000 ? 4 : 8;
@@ -135,44 +135,11 @@ static const struct seq_operations resource_op = {
135 .show = r_show, 135 .show = r_show,
136}; 136};
137 137
138static int ioports_open(struct inode *inode, struct file *file)
139{
140 int res = seq_open(file, &resource_op);
141 if (!res) {
142 struct seq_file *m = file->private_data;
143 m->private = &ioport_resource;
144 }
145 return res;
146}
147
148static int iomem_open(struct inode *inode, struct file *file)
149{
150 int res = seq_open(file, &resource_op);
151 if (!res) {
152 struct seq_file *m = file->private_data;
153 m->private = &iomem_resource;
154 }
155 return res;
156}
157
158static const struct file_operations proc_ioports_operations = {
159 .open = ioports_open,
160 .read = seq_read,
161 .llseek = seq_lseek,
162 .release = seq_release,
163};
164
165static const struct file_operations proc_iomem_operations = {
166 .open = iomem_open,
167 .read = seq_read,
168 .llseek = seq_lseek,
169 .release = seq_release,
170};
171
172static int __init ioresources_init(void) 138static int __init ioresources_init(void)
173{ 139{
174 proc_create("ioports", 0, NULL, &proc_ioports_operations); 140 proc_create_seq_data("ioports", 0, NULL, &resource_op,
175 proc_create("iomem", 0, NULL, &proc_iomem_operations); 141 &ioport_resource);
142 proc_create_seq_data("iomem", 0, NULL, &resource_op, &iomem_resource);
176 return 0; 143 return 0;
177} 144}
178__initcall(ioresources_init); 145__initcall(ioresources_init);