Commit 2ad17b19 authored by Christoph Hellwig's avatar Christoph Hellwig

net/kcm: simplify proc registration

Remove a couple indirections to make the code look like most other
protocols.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent ad08978a
...@@ -15,12 +15,6 @@ ...@@ -15,12 +15,6 @@
#include <net/tcp.h> #include <net/tcp.h>
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct kcm_seq_muxinfo {
char *name;
const struct file_operations *seq_fops;
const struct seq_operations seq_ops;
};
static struct kcm_mux *kcm_get_first(struct seq_file *seq) static struct kcm_mux *kcm_get_first(struct seq_file *seq)
{ {
struct net *net = seq_file_net(seq); struct net *net = seq_file_net(seq);
...@@ -86,14 +80,6 @@ struct kcm_proc_mux_state { ...@@ -86,14 +80,6 @@ struct kcm_proc_mux_state {
int idx; int idx;
}; };
static int kcm_seq_open(struct inode *inode, struct file *file)
{
struct kcm_seq_muxinfo *muxinfo = PDE_DATA(inode);
return seq_open_net(inode, file, &muxinfo->seq_ops,
sizeof(struct kcm_proc_mux_state));
}
static void kcm_format_mux_header(struct seq_file *seq) static void kcm_format_mux_header(struct seq_file *seq)
{ {
struct net *net = seq_file_net(seq); struct net *net = seq_file_net(seq);
...@@ -246,43 +232,25 @@ static int kcm_seq_show(struct seq_file *seq, void *v) ...@@ -246,43 +232,25 @@ static int kcm_seq_show(struct seq_file *seq, void *v)
return 0; return 0;
} }
static const struct file_operations kcm_seq_fops = { static const struct seq_operations kcm_seq_ops = {
.open = kcm_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release_net,
};
static struct kcm_seq_muxinfo kcm_seq_muxinfo = {
.name = "kcm",
.seq_fops = &kcm_seq_fops,
.seq_ops = {
.show = kcm_seq_show, .show = kcm_seq_show,
.start = kcm_seq_start, .start = kcm_seq_start,
.next = kcm_seq_next, .next = kcm_seq_next,
.stop = kcm_seq_stop, .stop = kcm_seq_stop,
}
}; };
static int kcm_proc_register(struct net *net, struct kcm_seq_muxinfo *muxinfo) static int kcm_seq_open(struct inode *inode, struct file *file)
{ {
struct proc_dir_entry *p; return seq_open_net(inode, file, &kcm_seq_ops,
int rc = 0; sizeof(struct kcm_proc_mux_state));
p = proc_create_data(muxinfo->name, 0444, net->proc_net,
muxinfo->seq_fops, muxinfo);
if (!p)
rc = -ENOMEM;
return rc;
} }
EXPORT_SYMBOL(kcm_proc_register);
static void kcm_proc_unregister(struct net *net, static const struct file_operations kcm_seq_fops = {
struct kcm_seq_muxinfo *muxinfo) .open = kcm_seq_open,
{ .read = seq_read,
remove_proc_entry(muxinfo->name, net->proc_net); .llseek = seq_lseek,
} .release = seq_release_net,
EXPORT_SYMBOL(kcm_proc_unregister); };
static int kcm_stats_seq_show(struct seq_file *seq, void *v) static int kcm_stats_seq_show(struct seq_file *seq, void *v)
{ {
...@@ -404,16 +372,11 @@ static const struct file_operations kcm_stats_seq_fops = { ...@@ -404,16 +372,11 @@ static const struct file_operations kcm_stats_seq_fops = {
static int kcm_proc_init_net(struct net *net) static int kcm_proc_init_net(struct net *net)
{ {
int err;
if (!proc_create("kcm_stats", 0444, net->proc_net, if (!proc_create("kcm_stats", 0444, net->proc_net,
&kcm_stats_seq_fops)) { &kcm_stats_seq_fops))
err = -ENOMEM;
goto out_kcm_stats; goto out_kcm_stats;
}
err = kcm_proc_register(net, &kcm_seq_muxinfo); if (!proc_create("kcm", 0444, net->proc_net, &kcm_seq_fops))
if (err)
goto out_kcm; goto out_kcm;
return 0; return 0;
...@@ -421,12 +384,12 @@ static int kcm_proc_init_net(struct net *net) ...@@ -421,12 +384,12 @@ static int kcm_proc_init_net(struct net *net)
out_kcm: out_kcm:
remove_proc_entry("kcm_stats", net->proc_net); remove_proc_entry("kcm_stats", net->proc_net);
out_kcm_stats: out_kcm_stats:
return err; return -ENOMEM;
} }
static void kcm_proc_exit_net(struct net *net) static void kcm_proc_exit_net(struct net *net)
{ {
kcm_proc_unregister(net, &kcm_seq_muxinfo); remove_proc_entry("kcm", net->proc_net);
remove_proc_entry("kcm_stats", net->proc_net); remove_proc_entry("kcm_stats", 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