diff options
author | Christoph Hellwig <hch@lst.de> | 2018-04-13 19:44:18 +0200 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-05-16 07:23:35 +0200 |
commit | fddda2b7b521185f3aa018f9559eb33b0aee53a9 (patch) | |
tree | ece18b3d82822f8eaefd8b0afa2f93307e83b253 /fs/proc/generic.c | |
parent | 7aed53d1dfd14d468e065212ce45068e2b50c1fa (diff) | |
download | linux-stable-fddda2b7b521185f3aa018f9559eb33b0aee53a9.tar.gz linux-stable-fddda2b7b521185f3aa018f9559eb33b0aee53a9.tar.bz2 linux-stable-fddda2b7b521185f3aa018f9559eb33b0aee53a9.zip |
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>
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r-- | fs/proc/generic.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index ab6a321076b8..af644caaaf85 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -25,6 +25,7 @@ #include <linux/spinlock.h> #include <linux/completion.h> #include <linux/uaccess.h> +#include <linux/seq_file.h> #include "internal.h" @@ -555,6 +556,35 @@ struct proc_dir_entry *proc_create(const char *name, umode_t mode, } EXPORT_SYMBOL(proc_create); +static int proc_seq_open(struct inode *inode, struct file *file) +{ + struct proc_dir_entry *de = PDE(inode); + + return seq_open(file, de->seq_ops); +} + +static const struct file_operations proc_seq_fops = { + .open = proc_seq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + +struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode, + struct proc_dir_entry *parent, const struct seq_operations *ops, + void *data) +{ + struct proc_dir_entry *p; + + p = proc_create_reg(name, mode, &parent, data); + if (!p) + return NULL; + p->proc_fops = &proc_seq_fops; + p->seq_ops = ops; + return proc_register(parent, p); +} +EXPORT_SYMBOL(proc_create_seq_data); + void proc_set_size(struct proc_dir_entry *de, loff_t size) { de->size = size; |