proc: introduce proc_create_seq{,_data}

Variants of proc_create{,_data} that directly take a struct seq_operations
argument and drastically reduces the boilerplate code in the callers.

All trivial callers converted over.

Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Christoph Hellwig
2018-04-13 19:44:18 +02:00
parent 7aed53d1df
commit fddda2b7b5
53 changed files with 151 additions and 925 deletions

View File

@@ -1453,18 +1453,6 @@ static const struct seq_operations rose_info_seqops = {
.stop = rose_info_stop,
.show = rose_info_show,
};
static int rose_info_open(struct inode *inode, struct file *file)
{
return seq_open(file, &rose_info_seqops);
}
static const struct file_operations rose_info_fops = {
.open = rose_info_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
#endif /* CONFIG_PROC_FS */
static const struct net_proto_family rose_family_ops = {
@@ -1567,13 +1555,13 @@ static int __init rose_proto_init(void)
rose_add_loopback_neigh();
proc_create("rose", 0444, init_net.proc_net, &rose_info_fops);
proc_create("rose_neigh", 0444, init_net.proc_net,
&rose_neigh_fops);
proc_create("rose_nodes", 0444, init_net.proc_net,
&rose_nodes_fops);
proc_create("rose_routes", 0444, init_net.proc_net,
&rose_routes_fops);
proc_create_seq("rose", 0444, init_net.proc_net, &rose_info_seqops);
proc_create_seq("rose_neigh", 0444, init_net.proc_net,
&rose_neigh_seqops);
proc_create_seq("rose_nodes", 0444, init_net.proc_net,
&rose_node_seqops);
proc_create_seq("rose_routes", 0444, init_net.proc_net,
&rose_route_seqops);
out:
return rc;
fail:

View File

@@ -1143,25 +1143,13 @@ static int rose_node_show(struct seq_file *seq, void *v)
return 0;
}
static const struct seq_operations rose_node_seqops = {
const struct seq_operations rose_node_seqops = {
.start = rose_node_start,
.next = rose_node_next,
.stop = rose_node_stop,
.show = rose_node_show,
};
static int rose_nodes_open(struct inode *inode, struct file *file)
{
return seq_open(file, &rose_node_seqops);
}
const struct file_operations rose_nodes_fops = {
.open = rose_nodes_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static void *rose_neigh_start(struct seq_file *seq, loff_t *pos)
__acquires(rose_neigh_list_lock)
{
@@ -1226,26 +1214,13 @@ static int rose_neigh_show(struct seq_file *seq, void *v)
}
static const struct seq_operations rose_neigh_seqops = {
const struct seq_operations rose_neigh_seqops = {
.start = rose_neigh_start,
.next = rose_neigh_next,
.stop = rose_neigh_stop,
.show = rose_neigh_show,
};
static int rose_neigh_open(struct inode *inode, struct file *file)
{
return seq_open(file, &rose_neigh_seqops);
}
const struct file_operations rose_neigh_fops = {
.open = rose_neigh_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
static void *rose_route_start(struct seq_file *seq, loff_t *pos)
__acquires(rose_route_list_lock)
{
@@ -1311,25 +1286,12 @@ static int rose_route_show(struct seq_file *seq, void *v)
return 0;
}
static const struct seq_operations rose_route_seqops = {
struct seq_operations rose_route_seqops = {
.start = rose_route_start,
.next = rose_route_next,
.stop = rose_route_stop,
.show = rose_route_show,
};
static int rose_route_open(struct inode *inode, struct file *file)
{
return seq_open(file, &rose_route_seqops);
}
const struct file_operations rose_routes_fops = {
.open = rose_route_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
#endif /* CONFIG_PROC_FS */
/*