diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 20:51:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 20:51:54 -0400 |
commit | 20b4fb485227404329e41ad15588afad3df23050 (patch) | |
tree | f3e099f0ab3da8a93b447203e294d2bb22f6dc05 /arch/ia64/sn | |
parent | b9394d8a657cd3c064fa432aa0905c1b58b38fe9 (diff) | |
parent | ac3e3c5b1164397656df81b9e9ab4991184d3236 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull VFS updates from Al Viro,
Misc cleanups all over the place, mainly wrt /proc interfaces (switch
create_proc_entry to proc_create(), get rid of the deprecated
create_proc_read_entry() in favor of using proc_create_data() and
seq_file etc).
7kloc removed.
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (204 commits)
don't bother with deferred freeing of fdtables
proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h
proc: Make the PROC_I() and PDE() macros internal to procfs
proc: Supply a function to remove a proc entry by PDE
take cgroup_open() and cpuset_open() to fs/proc/base.c
ppc: Clean up scanlog
ppc: Clean up rtas_flash driver somewhat
hostap: proc: Use remove_proc_subtree()
drm: proc: Use remove_proc_subtree()
drm: proc: Use minor->index to label things, not PDE->name
drm: Constify drm_proc_list[]
zoran: Don't print proc_dir_entry data in debug
reiserfs: Don't access the proc_dir_entry in r_open(), r_start() r_show()
proc: Supply an accessor for getting the data from a PDE's parent
airo: Use remove_proc_subtree()
rtl8192u: Don't need to save device proc dir PDE
rtl8187se: Use a dir under /proc/net/r8180/
proc: Add proc_mkdir_data()
proc: Move some bits from linux/proc_fs.h to linux/{of.h,signal.h,tty.h}
proc: Move PDE_NET() to fs/proc/proc_net.c
...
Diffstat (limited to 'arch/ia64/sn')
-rw-r--r-- | arch/ia64/sn/kernel/sn2/prominfo_proc.c | 146 |
1 files changed, 52 insertions, 94 deletions
diff --git a/arch/ia64/sn/kernel/sn2/prominfo_proc.c b/arch/ia64/sn/kernel/sn2/prominfo_proc.c index 20b88cb1881a..daa8d6badb16 100644 --- a/arch/ia64/sn/kernel/sn2/prominfo_proc.c +++ b/arch/ia64/sn/kernel/sn2/prominfo_proc.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/proc_fs.h> | 13 | #include <linux/proc_fs.h> |
14 | #include <linux/seq_file.h> | ||
14 | #include <linux/nodemask.h> | 15 | #include <linux/nodemask.h> |
15 | #include <asm/io.h> | 16 | #include <asm/io.h> |
16 | #include <asm/sn/sn_sal.h> | 17 | #include <asm/sn/sn_sal.h> |
@@ -101,18 +102,18 @@ get_fit_entry(unsigned long nasid, int index, unsigned long *fentry, | |||
101 | /* | 102 | /* |
102 | * These two routines display the FIT table for each node. | 103 | * These two routines display the FIT table for each node. |
103 | */ | 104 | */ |
104 | static int dump_fit_entry(char *page, unsigned long *fentry) | 105 | static void dump_fit_entry(struct seq_file *m, unsigned long *fentry) |
105 | { | 106 | { |
106 | unsigned type; | 107 | unsigned type; |
107 | 108 | ||
108 | type = FIT_TYPE(fentry[1]); | 109 | type = FIT_TYPE(fentry[1]); |
109 | return sprintf(page, "%02x %-25s %x.%02x %016lx %u\n", | 110 | seq_printf(m, "%02x %-25s %x.%02x %016lx %u\n", |
110 | type, | 111 | type, |
111 | fit_type_name(type), | 112 | fit_type_name(type), |
112 | FIT_MAJOR(fentry[1]), FIT_MINOR(fentry[1]), | 113 | FIT_MAJOR(fentry[1]), FIT_MINOR(fentry[1]), |
113 | fentry[0], | 114 | fentry[0], |
114 | /* mult by sixteen to get size in bytes */ | 115 | /* mult by sixteen to get size in bytes */ |
115 | (unsigned)(fentry[1] & 0xffffff) * 16); | 116 | (unsigned)(fentry[1] & 0xffffff) * 16); |
116 | } | 117 | } |
117 | 118 | ||
118 | 119 | ||
@@ -124,31 +125,39 @@ static int dump_fit_entry(char *page, unsigned long *fentry) | |||
124 | * OK except for 4kB pages (and no one is going to do that on SN | 125 | * OK except for 4kB pages (and no one is going to do that on SN |
125 | * anyway). | 126 | * anyway). |
126 | */ | 127 | */ |
127 | static int | 128 | static int proc_fit_show(struct seq_file *m, void *v) |
128 | dump_fit(char *page, unsigned long nasid) | ||
129 | { | 129 | { |
130 | unsigned long nasid = (unsigned long)m->private; | ||
130 | unsigned long fentry[2]; | 131 | unsigned long fentry[2]; |
131 | int index; | 132 | int index; |
132 | char *p; | ||
133 | 133 | ||
134 | p = page; | ||
135 | for (index=0;;index++) { | 134 | for (index=0;;index++) { |
136 | BUG_ON(index * 60 > PAGE_SIZE); | 135 | BUG_ON(index * 60 > PAGE_SIZE); |
137 | if (get_fit_entry(nasid, index, fentry, NULL, 0)) | 136 | if (get_fit_entry(nasid, index, fentry, NULL, 0)) |
138 | break; | 137 | break; |
139 | p += dump_fit_entry(p, fentry); | 138 | dump_fit_entry(m, fentry); |
140 | } | 139 | } |
140 | return 0; | ||
141 | } | ||
141 | 142 | ||
142 | return p - page; | 143 | static int proc_fit_open(struct inode *inode, struct file *file) |
144 | { | ||
145 | return single_open(file, proc_fit_show, PDE_DATA(inode)); | ||
143 | } | 146 | } |
144 | 147 | ||
145 | static int | 148 | static const struct file_operations proc_fit_fops = { |
146 | dump_version(char *page, unsigned long nasid) | 149 | .open = proc_fit_open, |
150 | .read = seq_read, | ||
151 | .llseek = seq_lseek, | ||
152 | .release = seq_release, | ||
153 | }; | ||
154 | |||
155 | static int proc_version_show(struct seq_file *m, void *v) | ||
147 | { | 156 | { |
157 | unsigned long nasid = (unsigned long)m->private; | ||
148 | unsigned long fentry[2]; | 158 | unsigned long fentry[2]; |
149 | char banner[128]; | 159 | char banner[128]; |
150 | int index; | 160 | int index; |
151 | int len; | ||
152 | 161 | ||
153 | for (index = 0; ; index++) { | 162 | for (index = 0; ; index++) { |
154 | if (get_fit_entry(nasid, index, fentry, banner, | 163 | if (get_fit_entry(nasid, index, fentry, banner, |
@@ -158,56 +167,24 @@ dump_version(char *page, unsigned long nasid) | |||
158 | break; | 167 | break; |
159 | } | 168 | } |
160 | 169 | ||
161 | len = sprintf(page, "%x.%02x\n", FIT_MAJOR(fentry[1]), | 170 | seq_printf(m, "%x.%02x\n", FIT_MAJOR(fentry[1]), FIT_MINOR(fentry[1])); |
162 | FIT_MINOR(fentry[1])); | ||
163 | page += len; | ||
164 | 171 | ||
165 | if (banner[0]) | 172 | if (banner[0]) |
166 | len += snprintf(page, PAGE_SIZE-len, "%s\n", banner); | 173 | seq_printf(m, "%s\n", banner); |
167 | 174 | return 0; | |
168 | return len; | ||
169 | } | ||
170 | |||
171 | /* same as in proc_misc.c */ | ||
172 | static int | ||
173 | proc_calc_metrics(char *page, char **start, off_t off, int count, int *eof, | ||
174 | int len) | ||
175 | { | ||
176 | if (len <= off + count) | ||
177 | *eof = 1; | ||
178 | *start = page + off; | ||
179 | len -= off; | ||
180 | if (len > count) | ||
181 | len = count; | ||
182 | if (len < 0) | ||
183 | len = 0; | ||
184 | return len; | ||
185 | } | 175 | } |
186 | 176 | ||
187 | static int | 177 | static int proc_version_open(struct inode *inode, struct file *file) |
188 | read_version_entry(char *page, char **start, off_t off, int count, int *eof, | ||
189 | void *data) | ||
190 | { | 178 | { |
191 | int len; | 179 | return single_open(file, proc_version_show, PDE_DATA(inode)); |
192 | |||
193 | /* data holds the NASID of the node */ | ||
194 | len = dump_version(page, (unsigned long)data); | ||
195 | len = proc_calc_metrics(page, start, off, count, eof, len); | ||
196 | return len; | ||
197 | } | 180 | } |
198 | 181 | ||
199 | static int | 182 | static const struct file_operations proc_version_fops = { |
200 | read_fit_entry(char *page, char **start, off_t off, int count, int *eof, | 183 | .open = proc_version_open, |
201 | void *data) | 184 | .read = seq_read, |
202 | { | 185 | .llseek = seq_lseek, |
203 | int len; | 186 | .release = seq_release, |
204 | 187 | }; | |
205 | /* data holds the NASID of the node */ | ||
206 | len = dump_fit(page, (unsigned long)data); | ||
207 | len = proc_calc_metrics(page, start, off, count, eof, len); | ||
208 | |||
209 | return len; | ||
210 | } | ||
211 | 188 | ||
212 | /* module entry points */ | 189 | /* module entry points */ |
213 | int __init prominfo_init(void); | 190 | int __init prominfo_init(void); |
@@ -216,58 +193,39 @@ void __exit prominfo_exit(void); | |||
216 | module_init(prominfo_init); | 193 | module_init(prominfo_init); |
217 | module_exit(prominfo_exit); | 194 | module_exit(prominfo_exit); |
218 | 195 | ||
219 | static struct proc_dir_entry **proc_entries; | ||
220 | static struct proc_dir_entry *sgi_prominfo_entry; | ||
221 | |||
222 | #define NODE_NAME_LEN 11 | 196 | #define NODE_NAME_LEN 11 |
223 | 197 | ||
224 | int __init prominfo_init(void) | 198 | int __init prominfo_init(void) |
225 | { | 199 | { |
226 | struct proc_dir_entry **entp; | 200 | struct proc_dir_entry *sgi_prominfo_entry; |
227 | cnodeid_t cnodeid; | 201 | cnodeid_t cnodeid; |
228 | unsigned long nasid; | ||
229 | int size; | ||
230 | char name[NODE_NAME_LEN]; | ||
231 | 202 | ||
232 | if (!ia64_platform_is("sn2")) | 203 | if (!ia64_platform_is("sn2")) |
233 | return 0; | 204 | return 0; |
234 | 205 | ||
235 | size = num_online_nodes() * sizeof(struct proc_dir_entry *); | ||
236 | proc_entries = kzalloc(size, GFP_KERNEL); | ||
237 | if (!proc_entries) | ||
238 | return -ENOMEM; | ||
239 | |||
240 | sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL); | 206 | sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL); |
207 | if (!sgi_prominfo_entry) | ||
208 | return -ENOMEM; | ||
241 | 209 | ||
242 | entp = proc_entries; | ||
243 | for_each_online_node(cnodeid) { | 210 | for_each_online_node(cnodeid) { |
211 | struct proc_dir_entry *dir; | ||
212 | unsigned long nasid; | ||
213 | char name[NODE_NAME_LEN]; | ||
214 | |||
244 | sprintf(name, "node%d", cnodeid); | 215 | sprintf(name, "node%d", cnodeid); |
245 | *entp = proc_mkdir(name, sgi_prominfo_entry); | 216 | dir = proc_mkdir(name, sgi_prominfo_entry); |
217 | if (!dir) | ||
218 | continue; | ||
246 | nasid = cnodeid_to_nasid(cnodeid); | 219 | nasid = cnodeid_to_nasid(cnodeid); |
247 | create_proc_read_entry("fit", 0, *entp, read_fit_entry, | 220 | proc_create_data("fit", 0, dir, |
248 | (void *)nasid); | 221 | &proc_fit_fops, (void *)nasid); |
249 | create_proc_read_entry("version", 0, *entp, | 222 | proc_create_data("version", 0, dir, |
250 | read_version_entry, (void *)nasid); | 223 | &proc_version_fops, (void *)nasid); |
251 | entp++; | ||
252 | } | 224 | } |
253 | |||
254 | return 0; | 225 | return 0; |
255 | } | 226 | } |
256 | 227 | ||
257 | void __exit prominfo_exit(void) | 228 | void __exit prominfo_exit(void) |
258 | { | 229 | { |
259 | struct proc_dir_entry **entp; | 230 | remove_proc_subtree("sgi_prominfo", NULL); |
260 | unsigned int cnodeid; | ||
261 | char name[NODE_NAME_LEN]; | ||
262 | |||
263 | entp = proc_entries; | ||
264 | for_each_online_node(cnodeid) { | ||
265 | remove_proc_entry("fit", *entp); | ||
266 | remove_proc_entry("version", *entp); | ||
267 | sprintf(name, "node%d", cnodeid); | ||
268 | remove_proc_entry(name, sgi_prominfo_entry); | ||
269 | entp++; | ||
270 | } | ||
271 | remove_proc_entry("sgi_prominfo", NULL); | ||
272 | kfree(proc_entries); | ||
273 | } | 231 | } |