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 /fs/fscache | |
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 'fs/fscache')
-rw-r--r-- | fs/fscache/internal.h | 2 | ||||
-rw-r--r-- | fs/fscache/proc.c | 4 | ||||
-rw-r--r-- | fs/fscache/stats.c | 17 |
3 files changed, 4 insertions, 19 deletions
diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h index 53cfd0b34c38..f83328a7f048 100644 --- a/fs/fscache/internal.h +++ b/fs/fscache/internal.h | |||
@@ -295,7 +295,7 @@ static inline void fscache_stat_d(atomic_t *stat) | |||
295 | 295 | ||
296 | #define __fscache_stat(stat) (stat) | 296 | #define __fscache_stat(stat) (stat) |
297 | 297 | ||
298 | extern const struct file_operations fscache_stats_fops; | 298 | int fscache_stats_show(struct seq_file *m, void *v); |
299 | #else | 299 | #else |
300 | 300 | ||
301 | #define __fscache_stat(stat) (NULL) | 301 | #define __fscache_stat(stat) (NULL) |
diff --git a/fs/fscache/proc.c b/fs/fscache/proc.c index 459df553ea09..49a8c90414bc 100644 --- a/fs/fscache/proc.c +++ b/fs/fscache/proc.c | |||
@@ -26,8 +26,8 @@ int __init fscache_proc_init(void) | |||
26 | goto error_dir; | 26 | goto error_dir; |
27 | 27 | ||
28 | #ifdef CONFIG_FSCACHE_STATS | 28 | #ifdef CONFIG_FSCACHE_STATS |
29 | if (!proc_create("fs/fscache/stats", S_IFREG | 0444, NULL, | 29 | if (!proc_create_single("fs/fscache/stats", S_IFREG | 0444, NULL, |
30 | &fscache_stats_fops)) | 30 | fscache_stats_show)) |
31 | goto error_stats; | 31 | goto error_stats; |
32 | #endif | 32 | #endif |
33 | 33 | ||
diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c index fcc8c2f2690e..00564a1dfd76 100644 --- a/fs/fscache/stats.c +++ b/fs/fscache/stats.c | |||
@@ -138,7 +138,7 @@ atomic_t fscache_n_cache_culled_objects; | |||
138 | /* | 138 | /* |
139 | * display the general statistics | 139 | * display the general statistics |
140 | */ | 140 | */ |
141 | static int fscache_stats_show(struct seq_file *m, void *v) | 141 | int fscache_stats_show(struct seq_file *m, void *v) |
142 | { | 142 | { |
143 | seq_puts(m, "FS-Cache statistics\n"); | 143 | seq_puts(m, "FS-Cache statistics\n"); |
144 | 144 | ||
@@ -284,18 +284,3 @@ static int fscache_stats_show(struct seq_file *m, void *v) | |||
284 | atomic_read(&fscache_n_cache_culled_objects)); | 284 | atomic_read(&fscache_n_cache_culled_objects)); |
285 | return 0; | 285 | return 0; |
286 | } | 286 | } |
287 | |||
288 | /* | ||
289 | * open "/proc/fs/fscache/stats" allowing provision of a statistical summary | ||
290 | */ | ||
291 | static int fscache_stats_open(struct inode *inode, struct file *file) | ||
292 | { | ||
293 | return single_open(file, fscache_stats_show, NULL); | ||
294 | } | ||
295 | |||
296 | const struct file_operations fscache_stats_fops = { | ||
297 | .open = fscache_stats_open, | ||
298 | .read = seq_read, | ||
299 | .llseek = seq_lseek, | ||
300 | .release = single_release, | ||
301 | }; | ||