Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Yangtao Li <tiny.win...@gmail.com>
---
 drivers/ras/cec.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c
index 2d9ec378a8bc..05301ef4820e 100644
--- a/drivers/ras/cec.c
+++ b/drivers/ras/cec.c
@@ -400,7 +400,7 @@ static int count_threshold_set(void *data, u64 val)
 }
 DEFINE_DEBUGFS_ATTRIBUTE(count_threshold_ops, u64_get, count_threshold_set, 
"%lld\n");
 
-static int array_dump(struct seq_file *m, void *v)
+static int array_show(struct seq_file *m, void *v)
 {
        struct ce_array *ca = &ce_arr;
        u64 prev = 0;
@@ -436,18 +436,7 @@ static int array_dump(struct seq_file *m, void *v)
        return 0;
 }
 
-static int array_open(struct inode *inode, struct file *filp)
-{
-       return single_open(filp, array_dump, NULL);
-}
-
-static const struct file_operations array_ops = {
-       .owner   = THIS_MODULE,
-       .open    = array_open,
-       .read    = seq_read,
-       .llseek  = seq_lseek,
-       .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(array);
 
 static int __init create_debugfs_nodes(void)
 {
@@ -459,13 +448,15 @@ static int __init create_debugfs_nodes(void)
                return -1;
        }
 
-       pfn = debugfs_create_file("pfn", S_IRUSR | S_IWUSR, d, &dfs_pfn, 
&pfn_ops);
+       pfn = debugfs_create_file("pfn", S_IRUSR | S_IWUSR, d,
+                                   &dfs_pfn, &pfn_ops);
        if (!pfn) {
                pr_warn("Error creating pfn debugfs node!\n");
                goto err;
        }
 
-       array = debugfs_create_file("array", S_IRUSR, d, NULL, &array_ops);
+       array = debugfs_create_file("array", S_IRUSR, d, NULL,
+                                   &array_fops);
        if (!array) {
                pr_warn("Error creating array debugfs node!\n");
                goto err;
-- 
2.17.0

Reply via email to