Commit 6ea1511e authored by Al Viro's avatar Al Viro

prominfo_proc fixes

* check for proc_mkdir() failures
* use remove_proc_subtree()
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 1c1ec6c6
...@@ -216,58 +216,40 @@ void __exit prominfo_exit(void); ...@@ -216,58 +216,40 @@ void __exit prominfo_exit(void);
module_init(prominfo_init); module_init(prominfo_init);
module_exit(prominfo_exit); module_exit(prominfo_exit);
static struct proc_dir_entry **proc_entries;
static struct proc_dir_entry *sgi_prominfo_entry; static struct proc_dir_entry *sgi_prominfo_entry;
#define NODE_NAME_LEN 11 #define NODE_NAME_LEN 11
int __init prominfo_init(void) int __init prominfo_init(void)
{ {
struct proc_dir_entry **entp;
cnodeid_t cnodeid; cnodeid_t cnodeid;
unsigned long nasid;
int size;
char name[NODE_NAME_LEN];
if (!ia64_platform_is("sn2")) if (!ia64_platform_is("sn2"))
return 0; return 0;
size = num_online_nodes() * sizeof(struct proc_dir_entry *);
proc_entries = kzalloc(size, GFP_KERNEL);
if (!proc_entries)
return -ENOMEM;
sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL); sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL);
if (!sgi_prominfo_entry)
return -ENOMEM;
entp = proc_entries;
for_each_online_node(cnodeid) { for_each_online_node(cnodeid) {
struct proc_dir_entry *dir;
unsigned long nasid;
char name[NODE_NAME_LEN];
sprintf(name, "node%d", cnodeid); sprintf(name, "node%d", cnodeid);
*entp = proc_mkdir(name, sgi_prominfo_entry); dir = proc_mkdir(name, sgi_prominfo_entry);
if (!dir)
continue;
nasid = cnodeid_to_nasid(cnodeid); nasid = cnodeid_to_nasid(cnodeid);
create_proc_read_entry("fit", 0, *entp, read_fit_entry, create_proc_read_entry("fit", 0, dir, read_fit_entry,
(void *)nasid); (void *)nasid);
create_proc_read_entry("version", 0, *entp, create_proc_read_entry("version", 0, dir,
read_version_entry, (void *)nasid); read_version_entry, (void *)nasid);
entp++;
} }
return 0; return 0;
} }
void __exit prominfo_exit(void) void __exit prominfo_exit(void)
{ {
struct proc_dir_entry **entp; remove_proc_subtree("sgi_prominfo", NULL);
unsigned int cnodeid;
char name[NODE_NAME_LEN];
entp = proc_entries;
for_each_online_node(cnodeid) {
remove_proc_entry("fit", *entp);
remove_proc_entry("version", *entp);
sprintf(name, "node%d", cnodeid);
remove_proc_entry(name, sgi_prominfo_entry);
entp++;
}
remove_proc_entry("sgi_prominfo", NULL);
kfree(proc_entries);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment