All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/error-inject: Convert to DEFINE_SEQ_ATTRIBUTE
@ 2022-06-12  5:20 wuchi
  0 siblings, 0 replies; only message in thread
From: wuchi @ 2022-06-12  5:20 UTC (permalink / raw)
  To: mhiramat, kafai, songliubraving, yhs, john.fastabend, kpsingh
  Cc: akpm, linux-kernel, netdev, bpf

Use DEFINE_SEQ_ATTRIBUTE helper macro to simplify the code.

Signed-off-by: wuchi <wuchi.zero@gmail.com>
---
 lib/error-inject.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/lib/error-inject.c b/lib/error-inject.c
index 2ff5ef689d72..4a4f1278c419 100644
--- a/lib/error-inject.c
+++ b/lib/error-inject.c
@@ -197,24 +197,14 @@ static int ei_seq_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static const struct seq_operations ei_seq_ops = {
+static const struct seq_operations ei_sops = {
 	.start = ei_seq_start,
 	.next  = ei_seq_next,
 	.stop  = ei_seq_stop,
 	.show  = ei_seq_show,
 };
 
-static int ei_open(struct inode *inode, struct file *filp)
-{
-	return seq_open(filp, &ei_seq_ops);
-}
-
-static const struct file_operations debugfs_ei_ops = {
-	.open           = ei_open,
-	.read           = seq_read,
-	.llseek         = seq_lseek,
-	.release        = seq_release,
-};
+DEFINE_SEQ_ATTRIBUTE(ei);
 
 static int __init ei_debugfs_init(void)
 {
@@ -224,7 +214,7 @@ static int __init ei_debugfs_init(void)
 	if (!dir)
 		return -ENOMEM;
 
-	file = debugfs_create_file("list", 0444, dir, NULL, &debugfs_ei_ops);
+	file = debugfs_create_file("list", 0444, dir, NULL, &ei_fops);
 	if (!file) {
 		debugfs_remove(dir);
 		return -ENOMEM;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-12  5:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-12  5:20 [PATCH] lib/error-inject: Convert to DEFINE_SEQ_ATTRIBUTE wuchi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.