diff options
author | Christoph Hellwig <hch@lst.de> | 2018-05-15 09:57:23 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-05-16 01:23:35 -0400 |
commit | 3f3942aca6da351a12543aa776467791b63b3a78 (patch) | |
tree | 31030e086ea36920e07078ea2289b9b72c0b2939 /kernel/cgroup | |
parent | 44414d82cfe0f68cb59d0a42f599ccd893ae0032 (diff) |
proc: introduce proc_create_single{,_data}
Variants of proc_create{,_data} that directly take a seq_file show
callback 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 'kernel/cgroup')
-rw-r--r-- | kernel/cgroup/cgroup-internal.h | 2 | ||||
-rw-r--r-- | kernel/cgroup/cgroup-v1.c | 14 | ||||
-rw-r--r-- | kernel/cgroup/cgroup.c | 2 |
3 files changed, 3 insertions, 15 deletions
diff --git a/kernel/cgroup/cgroup-internal.h b/kernel/cgroup/cgroup-internal.h index b928b27050c6..0808a33d16d3 100644 --- a/kernel/cgroup/cgroup-internal.h +++ b/kernel/cgroup/cgroup-internal.h | |||
@@ -218,9 +218,9 @@ extern const struct proc_ns_operations cgroupns_operations; | |||
218 | * cgroup-v1.c | 218 | * cgroup-v1.c |
219 | */ | 219 | */ |
220 | extern struct cftype cgroup1_base_files[]; | 220 | extern struct cftype cgroup1_base_files[]; |
221 | extern const struct file_operations proc_cgroupstats_operations; | ||
222 | extern struct kernfs_syscall_ops cgroup1_kf_syscall_ops; | 221 | extern struct kernfs_syscall_ops cgroup1_kf_syscall_ops; |
223 | 222 | ||
223 | int proc_cgroupstats_show(struct seq_file *m, void *v); | ||
224 | bool cgroup1_ssid_disabled(int ssid); | 224 | bool cgroup1_ssid_disabled(int ssid); |
225 | void cgroup1_pidlist_destroy_all(struct cgroup *cgrp); | 225 | void cgroup1_pidlist_destroy_all(struct cgroup *cgrp); |
226 | void cgroup1_release_agent(struct work_struct *work); | 226 | void cgroup1_release_agent(struct work_struct *work); |
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index a2c05d2476ac..e06c97f3ed1a 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c | |||
@@ -682,7 +682,7 @@ struct cftype cgroup1_base_files[] = { | |||
682 | }; | 682 | }; |
683 | 683 | ||
684 | /* Display information about each subsystem and each hierarchy */ | 684 | /* Display information about each subsystem and each hierarchy */ |
685 | static int proc_cgroupstats_show(struct seq_file *m, void *v) | 685 | int proc_cgroupstats_show(struct seq_file *m, void *v) |
686 | { | 686 | { |
687 | struct cgroup_subsys *ss; | 687 | struct cgroup_subsys *ss; |
688 | int i; | 688 | int i; |
@@ -705,18 +705,6 @@ static int proc_cgroupstats_show(struct seq_file *m, void *v) | |||
705 | return 0; | 705 | return 0; |
706 | } | 706 | } |
707 | 707 | ||
708 | static int cgroupstats_open(struct inode *inode, struct file *file) | ||
709 | { | ||
710 | return single_open(file, proc_cgroupstats_show, NULL); | ||
711 | } | ||
712 | |||
713 | const struct file_operations proc_cgroupstats_operations = { | ||
714 | .open = cgroupstats_open, | ||
715 | .read = seq_read, | ||
716 | .llseek = seq_lseek, | ||
717 | .release = single_release, | ||
718 | }; | ||
719 | |||
720 | /** | 708 | /** |
721 | * cgroupstats_build - build and fill cgroupstats | 709 | * cgroupstats_build - build and fill cgroupstats |
722 | * @stats: cgroupstats to fill information into | 710 | * @stats: cgroupstats to fill information into |
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index a662bfcbea0e..12883656e63e 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c | |||
@@ -5335,7 +5335,7 @@ int __init cgroup_init(void) | |||
5335 | WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup")); | 5335 | WARN_ON(sysfs_create_mount_point(fs_kobj, "cgroup")); |
5336 | WARN_ON(register_filesystem(&cgroup_fs_type)); | 5336 | WARN_ON(register_filesystem(&cgroup_fs_type)); |
5337 | WARN_ON(register_filesystem(&cgroup2_fs_type)); | 5337 | WARN_ON(register_filesystem(&cgroup2_fs_type)); |
5338 | WARN_ON(!proc_create("cgroups", 0, NULL, &proc_cgroupstats_operations)); | 5338 | WARN_ON(!proc_create_single("cgroups", 0, NULL, proc_cgroupstats_show)); |
5339 | 5339 | ||
5340 | return 0; | 5340 | return 0; |
5341 | } | 5341 | } |