Commit e2bcd8b0 authored by YueHaibing's avatar YueHaibing Committed by David S. Miller

appletalk: use remove_proc_subtree to simplify procfs code

Use remove_proc_subtree to remove the whole subtree
on cleanup.Also do some cleanup.
Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 084e5bb1
...@@ -210,56 +210,34 @@ static const struct seq_operations atalk_seq_socket_ops = { ...@@ -210,56 +210,34 @@ static const struct seq_operations atalk_seq_socket_ops = {
.show = atalk_seq_socket_show, .show = atalk_seq_socket_show,
}; };
static struct proc_dir_entry *atalk_proc_dir;
int __init atalk_proc_init(void) int __init atalk_proc_init(void)
{ {
struct proc_dir_entry *p; if (!proc_mkdir("atalk", init_net.proc_net))
int rc = -ENOMEM; return -ENOMEM;
atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net); if (!proc_create_seq("atalk/interface", 0444, init_net.proc_net,
if (!atalk_proc_dir) &atalk_seq_interface_ops))
goto out; goto out;
p = proc_create_seq("interface", 0444, atalk_proc_dir, if (!proc_create_seq("atalk/route", 0444, init_net.proc_net,
&atalk_seq_interface_ops); &atalk_seq_route_ops))
if (!p) goto out;
goto out_interface;
p = proc_create_seq("route", 0444, atalk_proc_dir,
&atalk_seq_route_ops);
if (!p)
goto out_route;
p = proc_create_seq("socket", 0444, atalk_proc_dir, if (!proc_create_seq("atalk/socket", 0444, init_net.proc_net,
&atalk_seq_socket_ops); &atalk_seq_socket_ops))
if (!p) goto out;
goto out_socket;
p = proc_create_seq_private("arp", 0444, atalk_proc_dir, &aarp_seq_ops, if (!proc_create_seq_private("atalk/arp", 0444, init_net.proc_net,
sizeof(struct aarp_iter_state), NULL); &aarp_seq_ops,
if (!p) sizeof(struct aarp_iter_state), NULL))
goto out_arp; goto out;
rc = 0;
out: out:
return rc; remove_proc_subtree("atalk", init_net.proc_net);
out_arp: return -ENOMEM;
remove_proc_entry("socket", atalk_proc_dir);
out_socket:
remove_proc_entry("route", atalk_proc_dir);
out_route:
remove_proc_entry("interface", atalk_proc_dir);
out_interface:
remove_proc_entry("atalk", init_net.proc_net);
goto out;
} }
void __exit atalk_proc_exit(void) void __exit atalk_proc_exit(void)
{ {
remove_proc_entry("interface", atalk_proc_dir); remove_proc_subtree("atalk", init_net.proc_net);
remove_proc_entry("route", atalk_proc_dir);
remove_proc_entry("socket", atalk_proc_dir);
remove_proc_entry("arp", atalk_proc_dir);
remove_proc_entry("atalk", init_net.proc_net);
} }
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