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/alpha | |
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/alpha')
-rw-r--r-- | arch/alpha/kernel/srm_env.c | 93 |
1 files changed, 14 insertions, 79 deletions
diff --git a/arch/alpha/kernel/srm_env.c b/arch/alpha/kernel/srm_env.c index e64559f0a82d..ffe996a54fad 100644 --- a/arch/alpha/kernel/srm_env.c +++ b/arch/alpha/kernel/srm_env.c | |||
@@ -51,13 +51,11 @@ MODULE_LICENSE("GPL"); | |||
51 | typedef struct _srm_env { | 51 | typedef struct _srm_env { |
52 | char *name; | 52 | char *name; |
53 | unsigned long id; | 53 | unsigned long id; |
54 | struct proc_dir_entry *proc_entry; | ||
55 | } srm_env_t; | 54 | } srm_env_t; |
56 | 55 | ||
57 | static struct proc_dir_entry *base_dir; | 56 | static struct proc_dir_entry *base_dir; |
58 | static struct proc_dir_entry *named_dir; | 57 | static struct proc_dir_entry *named_dir; |
59 | static struct proc_dir_entry *numbered_dir; | 58 | static struct proc_dir_entry *numbered_dir; |
60 | static char number[256][4]; | ||
61 | 59 | ||
62 | static srm_env_t srm_named_entries[] = { | 60 | static srm_env_t srm_named_entries[] = { |
63 | { "auto_action", ENV_AUTO_ACTION }, | 61 | { "auto_action", ENV_AUTO_ACTION }, |
@@ -77,21 +75,18 @@ static srm_env_t srm_named_entries[] = { | |||
77 | { "tty_dev", ENV_TTY_DEV }, | 75 | { "tty_dev", ENV_TTY_DEV }, |
78 | { NULL, 0 }, | 76 | { NULL, 0 }, |
79 | }; | 77 | }; |
80 | static srm_env_t srm_numbered_entries[256]; | ||
81 | |||
82 | 78 | ||
83 | static int srm_env_proc_show(struct seq_file *m, void *v) | 79 | static int srm_env_proc_show(struct seq_file *m, void *v) |
84 | { | 80 | { |
85 | unsigned long ret; | 81 | unsigned long ret; |
86 | srm_env_t *entry; | 82 | unsigned long id = (unsigned long)m->private; |
87 | char *page; | 83 | char *page; |
88 | 84 | ||
89 | entry = m->private; | ||
90 | page = (char *)__get_free_page(GFP_USER); | 85 | page = (char *)__get_free_page(GFP_USER); |
91 | if (!page) | 86 | if (!page) |
92 | return -ENOMEM; | 87 | return -ENOMEM; |
93 | 88 | ||
94 | ret = callback_getenv(entry->id, page, PAGE_SIZE); | 89 | ret = callback_getenv(id, page, PAGE_SIZE); |
95 | 90 | ||
96 | if ((ret >> 61) == 0) { | 91 | if ((ret >> 61) == 0) { |
97 | seq_write(m, page, ret); | 92 | seq_write(m, page, ret); |
@@ -104,14 +99,14 @@ static int srm_env_proc_show(struct seq_file *m, void *v) | |||
104 | 99 | ||
105 | static int srm_env_proc_open(struct inode *inode, struct file *file) | 100 | static int srm_env_proc_open(struct inode *inode, struct file *file) |
106 | { | 101 | { |
107 | return single_open(file, srm_env_proc_show, PDE(inode)->data); | 102 | return single_open(file, srm_env_proc_show, PDE_DATA(inode)); |
108 | } | 103 | } |
109 | 104 | ||
110 | static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer, | 105 | static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer, |
111 | size_t count, loff_t *pos) | 106 | size_t count, loff_t *pos) |
112 | { | 107 | { |
113 | int res; | 108 | int res; |
114 | srm_env_t *entry = PDE(file_inode(file))->data; | 109 | unsigned long id = (unsigned long)PDE_DATA(file_inode(file)); |
115 | char *buf = (char *) __get_free_page(GFP_USER); | 110 | char *buf = (char *) __get_free_page(GFP_USER); |
116 | unsigned long ret1, ret2; | 111 | unsigned long ret1, ret2; |
117 | 112 | ||
@@ -127,7 +122,7 @@ static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer, | |||
127 | goto out; | 122 | goto out; |
128 | buf[count] = '\0'; | 123 | buf[count] = '\0'; |
129 | 124 | ||
130 | ret1 = callback_setenv(entry->id, buf, count); | 125 | ret1 = callback_setenv(id, buf, count); |
131 | if ((ret1 >> 61) == 0) { | 126 | if ((ret1 >> 61) == 0) { |
132 | do | 127 | do |
133 | ret2 = callback_save_env(); | 128 | ret2 = callback_save_env(); |
@@ -149,52 +144,6 @@ static const struct file_operations srm_env_proc_fops = { | |||
149 | .write = srm_env_proc_write, | 144 | .write = srm_env_proc_write, |
150 | }; | 145 | }; |
151 | 146 | ||
152 | static void | ||
153 | srm_env_cleanup(void) | ||
154 | { | ||
155 | srm_env_t *entry; | ||
156 | unsigned long var_num; | ||
157 | |||
158 | if (base_dir) { | ||
159 | /* | ||
160 | * Remove named entries | ||
161 | */ | ||
162 | if (named_dir) { | ||
163 | entry = srm_named_entries; | ||
164 | while (entry->name != NULL && entry->id != 0) { | ||
165 | if (entry->proc_entry) { | ||
166 | remove_proc_entry(entry->name, | ||
167 | named_dir); | ||
168 | entry->proc_entry = NULL; | ||
169 | } | ||
170 | entry++; | ||
171 | } | ||
172 | remove_proc_entry(NAMED_DIR, base_dir); | ||
173 | } | ||
174 | |||
175 | /* | ||
176 | * Remove numbered entries | ||
177 | */ | ||
178 | if (numbered_dir) { | ||
179 | for (var_num = 0; var_num <= 255; var_num++) { | ||
180 | entry = &srm_numbered_entries[var_num]; | ||
181 | |||
182 | if (entry->proc_entry) { | ||
183 | remove_proc_entry(entry->name, | ||
184 | numbered_dir); | ||
185 | entry->proc_entry = NULL; | ||
186 | entry->name = NULL; | ||
187 | } | ||
188 | } | ||
189 | remove_proc_entry(NUMBERED_DIR, base_dir); | ||
190 | } | ||
191 | |||
192 | remove_proc_entry(BASE_DIR, NULL); | ||
193 | } | ||
194 | |||
195 | return; | ||
196 | } | ||
197 | |||
198 | static int __init | 147 | static int __init |
199 | srm_env_init(void) | 148 | srm_env_init(void) |
200 | { | 149 | { |
@@ -213,19 +162,13 @@ srm_env_init(void) | |||
213 | } | 162 | } |
214 | 163 | ||
215 | /* | 164 | /* |
216 | * Init numbers | ||
217 | */ | ||
218 | for (var_num = 0; var_num <= 255; var_num++) | ||
219 | sprintf(number[var_num], "%ld", var_num); | ||
220 | |||
221 | /* | ||
222 | * Create base directory | 165 | * Create base directory |
223 | */ | 166 | */ |
224 | base_dir = proc_mkdir(BASE_DIR, NULL); | 167 | base_dir = proc_mkdir(BASE_DIR, NULL); |
225 | if (!base_dir) { | 168 | if (!base_dir) { |
226 | printk(KERN_ERR "Couldn't create base dir /proc/%s\n", | 169 | printk(KERN_ERR "Couldn't create base dir /proc/%s\n", |
227 | BASE_DIR); | 170 | BASE_DIR); |
228 | goto cleanup; | 171 | return -ENOMEM; |
229 | } | 172 | } |
230 | 173 | ||
231 | /* | 174 | /* |
@@ -254,9 +197,8 @@ srm_env_init(void) | |||
254 | */ | 197 | */ |
255 | entry = srm_named_entries; | 198 | entry = srm_named_entries; |
256 | while (entry->name && entry->id) { | 199 | while (entry->name && entry->id) { |
257 | entry->proc_entry = proc_create_data(entry->name, 0644, named_dir, | 200 | if (!proc_create_data(entry->name, 0644, named_dir, |
258 | &srm_env_proc_fops, entry); | 201 | &srm_env_proc_fops, (void *)entry->id)) |
259 | if (!entry->proc_entry) | ||
260 | goto cleanup; | 202 | goto cleanup; |
261 | entry++; | 203 | entry++; |
262 | } | 204 | } |
@@ -265,15 +207,11 @@ srm_env_init(void) | |||
265 | * Create all numbered nodes | 207 | * Create all numbered nodes |
266 | */ | 208 | */ |
267 | for (var_num = 0; var_num <= 255; var_num++) { | 209 | for (var_num = 0; var_num <= 255; var_num++) { |
268 | entry = &srm_numbered_entries[var_num]; | 210 | char name[4]; |
269 | entry->name = number[var_num]; | 211 | sprintf(name, "%ld", var_num); |
270 | 212 | if (!proc_create_data(name, 0644, numbered_dir, | |
271 | entry->proc_entry = proc_create_data(entry->name, 0644, numbered_dir, | 213 | &srm_env_proc_fops, (void *)var_num)) |
272 | &srm_env_proc_fops, entry); | ||
273 | if (!entry->proc_entry) | ||
274 | goto cleanup; | 214 | goto cleanup; |
275 | |||
276 | entry->id = var_num; | ||
277 | } | 215 | } |
278 | 216 | ||
279 | printk(KERN_INFO "%s: version %s loaded successfully\n", NAME, | 217 | printk(KERN_INFO "%s: version %s loaded successfully\n", NAME, |
@@ -282,18 +220,15 @@ srm_env_init(void) | |||
282 | return 0; | 220 | return 0; |
283 | 221 | ||
284 | cleanup: | 222 | cleanup: |
285 | srm_env_cleanup(); | 223 | remove_proc_subtree(BASE_DIR, NULL); |
286 | |||
287 | return -ENOMEM; | 224 | return -ENOMEM; |
288 | } | 225 | } |
289 | 226 | ||
290 | static void __exit | 227 | static void __exit |
291 | srm_env_exit(void) | 228 | srm_env_exit(void) |
292 | { | 229 | { |
293 | srm_env_cleanup(); | 230 | remove_proc_subtree(BASE_DIR, NULL); |
294 | printk(KERN_INFO "%s: unloaded successfully\n", NAME); | 231 | printk(KERN_INFO "%s: unloaded successfully\n", NAME); |
295 | |||
296 | return; | ||
297 | } | 232 | } |
298 | 233 | ||
299 | module_init(srm_env_init); | 234 | module_init(srm_env_init); |