Skip to contentSkip to conversation

bpf: convert to DEFINE_SHOW_ATTRIBUTE

PATCH In review Yangtao Li 2 participants 3 messages Dec 10, 2018 – Dec 12, 2018

Subsystems (2)
lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 bpf: convert to DEFINE_SHOW_ATTRIBUTE

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

---
 drivers/net/netdevsim/bpf.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/net/netdevsim/bpf.c +2 -14
index cb3518474f0e..14b4d9774708 100644
@@ -48,7 +48,7 @@ struct nsim_bpf_bound_map {
 	struct list_head l;
 };
 
-static int nsim_debugfs_bpf_string_read(struct seq_file *file, void *data)
+static int nsim_bpf_string_show(struct seq_file *file, void *data)
 {
 	const char **str = file->private;
 
@@ -57,19 +57,7 @@ static int nsim_debugfs_bpf_string_read(struct seq_file *file, void *data)
 
 	return 0;
 }
-
-static int nsim_debugfs_bpf_string_open(struct inode *inode, struct file *f)
-{
-	return single_open(f, nsim_debugfs_bpf_string_read, inode->i_private);
-}
-
-static const struct file_operations nsim_bpf_string_fops = {
-	.owner = THIS_MODULE,
-	.open = nsim_debugfs_bpf_string_open,
-	.release = single_release,
-	.read = seq_read,
-	.llseek = seq_lseek
-};
+DEFINE_SHOW_ATTRIBUTE(nsim_bpf_string);
 
 static int
 nsim_bpf_verify_insn(struct bpf_verifier_env *env, int insn_idx, int prev_insn)
Signature · 1 line
2.17.0
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Please post v2 with the subject prefix set to "netdevsim:" rather than "bpf:".

Quoted 37 lines
 drivers/net/netdevsim/bpf.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/net/netdevsim/bpf.c +2 -14
index cb3518474f0e..14b4d9774708 100644
@@ -48,7 +48,7 @@ struct nsim_bpf_bound_map {
 	struct list_head l;
 };
 
-static int nsim_debugfs_bpf_string_read(struct seq_file *file, void *data)
+static int nsim_bpf_string_show(struct seq_file *file, void *data)
 {
 	const char **str = file->private;
 
@@ -57,19 +57,7 @@ static int nsim_debugfs_bpf_string_read(struct seq_file *file, void *data)
 
 	return 0;
 }
-
-static int nsim_debugfs_bpf_string_open(struct inode *inode, struct file *f)
-{
-	return single_open(f, nsim_debugfs_bpf_string_read, inode->i_private);
-}
-
-static const struct file_operations nsim_bpf_string_fops = {
-	.owner = THIS_MODULE,
-	.open = nsim_debugfs_bpf_string_open,
-	.release = single_release,
-	.read = seq_read,
-	.llseek = seq_lseek
-};
+DEFINE_SHOW_ATTRIBUTE(nsim_bpf_string);
 
 static int
 nsim_bpf_verify_insn(struct bpf_verifier_env *env, int insn_idx, int prev_insn)
author
#2 lore raw
Quoted 10 lines · Jakub Kicinski
Quoted 3 lines · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Please post v2 with the subject prefix set to "netdevsim:" rather than "bpf:".

The newer has been sent.

Thanks,
Yangtao

Quoted 39 lines
Quoted 38 lines
 drivers/net/netdevsim/bpf.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/net/netdevsim/bpf.c +2 -14
index cb3518474f0e..14b4d9774708 100644
@@ -48,7 +48,7 @@ struct nsim_bpf_bound_map {
      struct list_head l;
 };
 
-static int nsim_debugfs_bpf_string_read(struct seq_file *file, void *data)
+static int nsim_bpf_string_show(struct seq_file *file, void *data)
 {
      const char **str = file->private;
 
@@ -57,19 +57,7 @@ static int nsim_debugfs_bpf_string_read(struct seq_file *file, void *data)
 
      return 0;
 }
-
-static int nsim_debugfs_bpf_string_open(struct inode *inode, struct file *f)
-{
-     return single_open(f, nsim_debugfs_bpf_string_read, inode->i_private);
-}
-
-static const struct file_operations nsim_bpf_string_fops = {
-     .owner = THIS_MODULE,
-     .open = nsim_debugfs_bpf_string_open,
-     .release = single_release,
-     .read = seq_read,
-     .llseek = seq_lseek
-};
+DEFINE_SHOW_ATTRIBUTE(nsim_bpf_string);
 
 static int
 nsim_bpf_verify_insn(struct bpf_verifier_env *env, int insn_idx, int prev_insn)