Commit ce9fe438 authored by Christoph Hellwig's avatar Christoph Hellwig

atm: simplify procfs code

Use remove_proc_subtree to remove the whole subtree on cleanup, and
unwind the registration loop into individual calls.  Switch to use
proc_create_seq where applicable.

Also don't bother handling proc_create* failures - the driver works
perfectly fine without the proc files, and the cleanup will handle
missing files gracefully.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent a9170e0a
...@@ -257,18 +257,6 @@ static const struct seq_operations atm_dev_seq_ops = { ...@@ -257,18 +257,6 @@ static const struct seq_operations atm_dev_seq_ops = {
.show = atm_dev_seq_show, .show = atm_dev_seq_show,
}; };
static int atm_dev_seq_open(struct inode *inode, struct file *file)
{
return seq_open(file, &atm_dev_seq_ops);
}
static const struct file_operations devices_seq_fops = {
.open = atm_dev_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static int pvc_seq_show(struct seq_file *seq, void *v) static int pvc_seq_show(struct seq_file *seq, void *v)
{ {
static char atm_pvc_banner[] = static char atm_pvc_banner[] =
...@@ -440,58 +428,19 @@ void atm_proc_dev_deregister(struct atm_dev *dev) ...@@ -440,58 +428,19 @@ void atm_proc_dev_deregister(struct atm_dev *dev)
kfree(dev->proc_name); kfree(dev->proc_name);
} }
static struct atm_proc_entry {
char *name;
const struct file_operations *proc_fops;
struct proc_dir_entry *dirent;
} atm_proc_ents[] = {
{ .name = "devices", .proc_fops = &devices_seq_fops },
{ .name = "pvc", .proc_fops = &pvc_seq_fops },
{ .name = "svc", .proc_fops = &svc_seq_fops },
{ .name = "vc", .proc_fops = &vcc_seq_fops },
{ .name = NULL, .proc_fops = NULL }
};
static void atm_proc_dirs_remove(void)
{
static struct atm_proc_entry *e;
for (e = atm_proc_ents; e->name; e++) {
if (e->dirent)
remove_proc_entry(e->name, atm_proc_root);
}
remove_proc_entry("atm", init_net.proc_net);
}
int __init atm_proc_init(void) int __init atm_proc_init(void)
{ {
static struct atm_proc_entry *e;
int ret;
atm_proc_root = proc_net_mkdir(&init_net, "atm", init_net.proc_net); atm_proc_root = proc_net_mkdir(&init_net, "atm", init_net.proc_net);
if (!atm_proc_root) if (!atm_proc_root)
goto err_out; return -ENOMEM;
for (e = atm_proc_ents; e->name; e++) { proc_create_seq("devices", 0444, atm_proc_root, &atm_dev_seq_ops);
struct proc_dir_entry *dirent; proc_create("pvc", 0444, atm_proc_root, &pvc_seq_fops);
proc_create("svc", 0444, atm_proc_root, &svc_seq_fops);
dirent = proc_create(e->name, 0444, proc_create("vc", 0444, atm_proc_root, &vcc_seq_fops);
atm_proc_root, e->proc_fops); return 0;
if (!dirent)
goto err_out_remove;
e->dirent = dirent;
}
ret = 0;
out:
return ret;
err_out_remove:
atm_proc_dirs_remove();
err_out:
ret = -ENOMEM;
goto out;
} }
void atm_proc_exit(void) void atm_proc_exit(void)
{ {
atm_proc_dirs_remove(); remove_proc_subtree("atm", 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