lkml.org 
[lkml]   [2020]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next] dlm: convert to use DEFINE_SEQ_ATTRIBUTE macro
Date
Use DEFINE_SEQ_ATTRIBUTE macro to simplify the code.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
---
fs/dlm/debug_fs.c | 104 ++++------------------------------------------
1 file changed, 8 insertions(+), 96 deletions(-)

diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
index d6bbccb0ed15..c4d1860b9e41 100644
--- a/fs/dlm/debug_fs.c
+++ b/fs/dlm/debug_fs.c
@@ -571,126 +571,38 @@ static void table_seq_stop(struct seq_file *seq, void *iter_ptr)
}
}

-static const struct seq_operations format1_seq_ops = {
+static const struct seq_operations format1_sops = {
.start = table_seq_start,
.next = table_seq_next,
.stop = table_seq_stop,
.show = table_seq_show,
};

-static const struct seq_operations format2_seq_ops = {
+static const struct seq_operations format2_sops = {
.start = table_seq_start,
.next = table_seq_next,
.stop = table_seq_stop,
.show = table_seq_show,
};

-static const struct seq_operations format3_seq_ops = {
+static const struct seq_operations format3_sops = {
.start = table_seq_start,
.next = table_seq_next,
.stop = table_seq_stop,
.show = table_seq_show,
};

-static const struct seq_operations format4_seq_ops = {
+static const struct seq_operations format4_sops = {
.start = table_seq_start,
.next = table_seq_next,
.stop = table_seq_stop,
.show = table_seq_show,
};

-static const struct file_operations format1_fops;
-static const struct file_operations format2_fops;
-static const struct file_operations format3_fops;
-static const struct file_operations format4_fops;
-
-static int table_open1(struct inode *inode, struct file *file)
-{
- struct seq_file *seq;
- int ret;
-
- ret = seq_open(file, &format1_seq_ops);
- if (ret)
- return ret;
-
- seq = file->private_data;
- seq->private = inode->i_private; /* the dlm_ls */
- return 0;
-}
-
-static int table_open2(struct inode *inode, struct file *file)
-{
- struct seq_file *seq;
- int ret;
-
- ret = seq_open(file, &format2_seq_ops);
- if (ret)
- return ret;
-
- seq = file->private_data;
- seq->private = inode->i_private; /* the dlm_ls */
- return 0;
-}
-
-static int table_open3(struct inode *inode, struct file *file)
-{
- struct seq_file *seq;
- int ret;
-
- ret = seq_open(file, &format3_seq_ops);
- if (ret)
- return ret;
-
- seq = file->private_data;
- seq->private = inode->i_private; /* the dlm_ls */
- return 0;
-}
-
-static int table_open4(struct inode *inode, struct file *file)
-{
- struct seq_file *seq;
- int ret;
-
- ret = seq_open(file, &format4_seq_ops);
- if (ret)
- return ret;
-
- seq = file->private_data;
- seq->private = inode->i_private; /* the dlm_ls */
- return 0;
-}
-
-static const struct file_operations format1_fops = {
- .owner = THIS_MODULE,
- .open = table_open1,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release
-};
-
-static const struct file_operations format2_fops = {
- .owner = THIS_MODULE,
- .open = table_open2,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release
-};
-
-static const struct file_operations format3_fops = {
- .owner = THIS_MODULE,
- .open = table_open3,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release
-};
-
-static const struct file_operations format4_fops = {
- .owner = THIS_MODULE,
- .open = table_open4,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release
-};
+DEFINE_SEQ_ATTRIBUTE(format1);
+DEFINE_SEQ_ATTRIBUTE(format2);
+DEFINE_SEQ_ATTRIBUTE(format3);
+DEFINE_SEQ_ATTRIBUTE(format4);

/*
* dump lkb's on the ls_waiters list
--
2.25.1
\
 
 \ /
  Last update: 2020-09-16 04:30    [W:0.037 / U:2.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site