]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mm: reuse DEFINE_SHOW_ATTRIBUTE() macro
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 5 Apr 2018 23:23:16 +0000 (16:23 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 6 Apr 2018 04:36:25 +0000 (21:36 -0700)
...instead of open coding file operations followed by custom ->open()
callbacks per each attribute.

[andriy.shevchenko@linux.intel.com: add tags, fix compilation issue]
Link: http://lkml.kernel.org/r/20180217144253.58604-1-andriy.shevchenko@linux.intel.com
Link: http://lkml.kernel.org/r/20180214154644.54505-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Christoph Lameter <cl@linux.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Dennis Zhou <dennisszhou@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/backing-dev.c
mm/memblock.c
mm/percpu-stats.c
mm/zsmalloc.c

index b5f940ce0143ba061a183db0df3ef0dc17f57c72..fac66abd5a68e85e8b6ddf53063b6fe943287c9f 100644 (file)
@@ -100,18 +100,7 @@ static int bdi_debug_stats_show(struct seq_file *m, void *v)
 
        return 0;
 }
-
-static int bdi_debug_stats_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, bdi_debug_stats_show, inode->i_private);
-}
-
-static const struct file_operations bdi_debug_stats_fops = {
-       .open           = bdi_debug_stats_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(bdi_debug_stats);
 
 static int bdi_debug_register(struct backing_dev_info *bdi, const char *name)
 {
index c2fed302c2f82b183648def0995fb1b5dc08a8b3..04406a930bfccd7b2aefee54939774f689940894 100644 (file)
@@ -1795,18 +1795,7 @@ static int memblock_debug_show(struct seq_file *m, void *private)
        }
        return 0;
 }
-
-static int memblock_debug_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, memblock_debug_show, inode->i_private);
-}
-
-static const struct file_operations memblock_debug_fops = {
-       .open = memblock_debug_open,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(memblock_debug);
 
 static int __init memblock_init_debugfs(void)
 {
index 7a58460bfd27a303c7ab4d3c4f10abac02c15603..063ff60ecd901edd979d301e462a94fb51374a20 100644 (file)
@@ -223,18 +223,7 @@ alloc_buffer:
 
        return 0;
 }
-
-static int percpu_stats_open(struct inode *inode, struct file *filp)
-{
-       return single_open(filp, percpu_stats_show, NULL);
-}
-
-static const struct file_operations percpu_stats_fops = {
-       .open           = percpu_stats_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(percpu_stats);
 
 static int __init init_percpu_stats_debugfs(void)
 {
index b7f61cd1c709318a22ddba31ab2fb2b01d9322a8..a583ab111a43847ceb4082206e00712f7478e8bc 100644 (file)
@@ -642,18 +642,7 @@ static int zs_stats_size_show(struct seq_file *s, void *v)
 
        return 0;
 }
-
-static int zs_stats_size_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, zs_stats_size_show, inode->i_private);
-}
-
-static const struct file_operations zs_stat_size_ops = {
-       .open           = zs_stats_size_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(zs_stats_size);
 
 static void zs_pool_stat_create(struct zs_pool *pool, const char *name)
 {
@@ -672,7 +661,7 @@ static void zs_pool_stat_create(struct zs_pool *pool, const char *name)
        pool->stat_dentry = entry;
 
        entry = debugfs_create_file("classes", S_IFREG | S_IRUGO,
-                       pool->stat_dentry, pool, &zs_stat_size_ops);
+                       pool->stat_dentry, pool, &zs_stats_size_fops);
        if (!entry) {
                pr_warn("%s: debugfs file entry <%s> creation failed\n",
                                name, "classes");