summaryrefslogtreecommitdiff
path: root/drivers/mtd/nand/raw/nandsim.c
diff options
context:
space:
mode:
authorYangtao Li <tiny.windzz@gmail.com>2018-12-02 03:33:58 -0500
committerBoris Brezillon <boris.brezillon@bootlin.com>2018-12-03 11:32:26 +0100
commitc78f59d7145e7f729c8df58fa7f99ecf66225ddc (patch)
treed5043a0cc6b3d1f36712c87a414141416ac8dfed /drivers/mtd/nand/raw/nandsim.c
parentbafae53817e7f3a47ed74cd03152e166aa639131 (diff)
mtd: use DEFINE_SHOW_ATTRIBUTE() instead of open-coding it
DEFINE_SHOW_ATTRIBUTE macro can help us simplify the code, so change to it. And change the DEBUGFS_RO_ATTR macro defined in some file to a standard macro. Signed-off-by: Yangtao Li <tiny.windzz@gmail.com> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Diffstat (limited to 'drivers/mtd/nand/raw/nandsim.c')
-rw-r--r--drivers/mtd/nand/raw/nandsim.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
index c452819f6123..ef8721418f2d 100644
--- a/drivers/mtd/nand/raw/nandsim.c
+++ b/drivers/mtd/nand/raw/nandsim.c
@@ -443,7 +443,7 @@ static unsigned long total_wear = 0;
/* MTD structure for NAND controller */
static struct mtd_info *nsmtd;
-static int nandsim_debugfs_show(struct seq_file *m, void *private)
+static int nandsim_show(struct seq_file *m, void *private)
{
unsigned long wmin = -1, wmax = 0, avg;
unsigned long deciles[10], decile_max[10], tot = 0;
@@ -494,18 +494,7 @@ static int nandsim_debugfs_show(struct seq_file *m, void *private)
return 0;
}
-
-static int nandsim_debugfs_open(struct inode *inode, struct file *file)
-{
- return single_open(file, nandsim_debugfs_show, inode->i_private);
-}
-
-static const struct file_operations dfs_fops = {
- .open = nandsim_debugfs_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(nandsim);
/**
* nandsim_debugfs_create - initialize debugfs
@@ -531,7 +520,7 @@ static int nandsim_debugfs_create(struct nandsim *dev)
}
dent = debugfs_create_file("nandsim_wear_report", S_IRUSR,
- root, dev, &dfs_fops);
+ root, dev, &nandsim_fops);
if (IS_ERR_OR_NULL(dent)) {
NS_ERR("cannot create \"nandsim_wear_report\" debugfs entry\n");
return -1;