diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-03-31 18:29:51 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-09 14:13:33 -0400 |
commit | c35f2e49f88e72ffcb0cc6af2f93fe153fa88dd8 (patch) | |
tree | d202ba0b1f7e07324a96fb9cb09fd0d107f5da0c /arch/alpha | |
parent | d9dda78bad879595d8c4220a067fc029d6484a16 (diff) |
srm_env: use proc_remove_subtree()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/alpha')
-rw-r--r-- | arch/alpha/kernel/srm_env.c | 64 |
1 files changed, 7 insertions, 57 deletions
diff --git a/arch/alpha/kernel/srm_env.c b/arch/alpha/kernel/srm_env.c index ef8769b6c98b..97b4f3fee497 100644 --- a/arch/alpha/kernel/srm_env.c +++ b/arch/alpha/kernel/srm_env.c | |||
@@ -51,7 +51,6 @@ 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; |
@@ -149,52 +148,6 @@ static const struct file_operations srm_env_proc_fops = { | |||
149 | .write = srm_env_proc_write, | 148 | .write = srm_env_proc_write, |
150 | }; | 149 | }; |
151 | 150 | ||
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 | 151 | static int __init |
199 | srm_env_init(void) | 152 | srm_env_init(void) |
200 | { | 153 | { |
@@ -225,7 +178,7 @@ srm_env_init(void) | |||
225 | if (!base_dir) { | 178 | if (!base_dir) { |
226 | printk(KERN_ERR "Couldn't create base dir /proc/%s\n", | 179 | printk(KERN_ERR "Couldn't create base dir /proc/%s\n", |
227 | BASE_DIR); | 180 | BASE_DIR); |
228 | goto cleanup; | 181 | return -ENOMEM; |
229 | } | 182 | } |
230 | 183 | ||
231 | /* | 184 | /* |
@@ -254,9 +207,8 @@ srm_env_init(void) | |||
254 | */ | 207 | */ |
255 | entry = srm_named_entries; | 208 | entry = srm_named_entries; |
256 | while (entry->name && entry->id) { | 209 | while (entry->name && entry->id) { |
257 | entry->proc_entry = proc_create_data(entry->name, 0644, named_dir, | 210 | if (!proc_create_data(entry->name, 0644, named_dir, |
258 | &srm_env_proc_fops, entry); | 211 | &srm_env_proc_fops, entry)) |
259 | if (!entry->proc_entry) | ||
260 | goto cleanup; | 212 | goto cleanup; |
261 | entry++; | 213 | entry++; |
262 | } | 214 | } |
@@ -268,9 +220,8 @@ srm_env_init(void) | |||
268 | entry = &srm_numbered_entries[var_num]; | 220 | entry = &srm_numbered_entries[var_num]; |
269 | entry->name = number[var_num]; | 221 | entry->name = number[var_num]; |
270 | 222 | ||
271 | entry->proc_entry = proc_create_data(entry->name, 0644, numbered_dir, | 223 | if (!proc_create_data(entry->name, 0644, numbered_dir, |
272 | &srm_env_proc_fops, entry); | 224 | &srm_env_proc_fops, entry)) |
273 | if (!entry->proc_entry) | ||
274 | goto cleanup; | 225 | goto cleanup; |
275 | 226 | ||
276 | entry->id = var_num; | 227 | entry->id = var_num; |
@@ -282,15 +233,14 @@ srm_env_init(void) | |||
282 | return 0; | 233 | return 0; |
283 | 234 | ||
284 | cleanup: | 235 | cleanup: |
285 | srm_env_cleanup(); | 236 | remove_proc_subtree(BASE_DIR, NULL); |
286 | |||
287 | return -ENOMEM; | 237 | return -ENOMEM; |
288 | } | 238 | } |
289 | 239 | ||
290 | static void __exit | 240 | static void __exit |
291 | srm_env_exit(void) | 241 | srm_env_exit(void) |
292 | { | 242 | { |
293 | srm_env_cleanup(); | 243 | remove_proc_subtree(BASE_DIR, NULL); |
294 | printk(KERN_INFO "%s: unloaded successfully\n", NAME); | 244 | printk(KERN_INFO "%s: unloaded successfully\n", NAME); |
295 | 245 | ||
296 | return; | 246 | return; |