Skip to content

Commit

Permalink
mm: reuse DEFINE_SHOW_ATTRIBUTE() macro
Browse files Browse the repository at this point in the history
...instead of open coding file operations followed by custom ->open()
callbacks per each attribute.

[[email protected]: add tags, fix compilation issue]
  Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Matthew Wilcox <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Reviewed-by: Sergey Senozhatsky <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Dennis Zhou <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Nitin Gupta <[email protected]>
Cc: Sergey Senozhatsky <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
andy-shev authored and torvalds committed Apr 6, 2018
1 parent 7f16f91 commit 5ad3509
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 49 deletions.
13 changes: 1 addition & 12 deletions mm/backing-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
13 changes: 1 addition & 12 deletions mm/memblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
13 changes: 1 addition & 12 deletions mm/percpu-stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,7 @@ static int percpu_stats_show(struct seq_file *m, void *v)

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)
{
Expand Down
15 changes: 2 additions & 13 deletions mm/zsmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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");
Expand Down

0 comments on commit 5ad3509

Please sign in to comment.