Skip to contentSkip to conversation

ARM: mm: dump: Change to use DEFINE_SHOW_ATTRIBUTE macro

PATCH In review Yangtao Li 3 participants 3 messages Nov 5, 2018 Arm (32-bit)

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 ARM: mm: dump: Change to use DEFINE_SHOW_ATTRIBUTE macro

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

---
 arch/arm/mm/ptdump_debugfs.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
arch/arm/mm/ptdump_debugfs.c +1 -11
index be8d87be4b93..201cd467a739 100644
@@ -12,17 +12,7 @@ static int ptdump_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static int ptdump_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, ptdump_show, inode->i_private);
-}
-
-static const struct file_operations ptdump_fops = {
-	.open		= ptdump_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(ptdump);
 
 int ptdump_debugfs_register(struct ptdump_info *info, const char *name)
 {
Signature · 1 line
2.17.0
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Quoted 29 lines
---
  arch/arm/mm/ptdump_debugfs.c | 12 +-----------
  1 file changed, 1 insertion(+), 11 deletions(-)
arch/arm/mm/ptdump_debugfs.c +1 -11
index be8d87be4b93..201cd467a739 100644
@@ -12,17 +12,7 @@ static int ptdump_show(struct seq_file *m, void *v)
  	return 0;
  }
 
-static int ptdump_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, ptdump_show, inode->i_private);
-}
-
-static const struct file_operations ptdump_fops = {
-	.open		= ptdump_open,
-	.read		= seq_read,
-	.llseek		= seq_lseek,
-	.release	= single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(ptdump);
 
  int ptdump_debugfs_register(struct ptdump_info *info, const char *name)
  {
Reviewed-by
#2 lore raw
Quoted 24 lines · Laura Abbott
Quoted 3 lines · Yangtao Li

Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Quoted 16 lines
---
  arch/arm/mm/ptdump_debugfs.c | 12 +-----------
  1 file changed, 1 insertion(+), 11 deletions(-)
arch/arm/mm/ptdump_debugfs.c +0 -3
index be8d87be4b93..201cd467a739 100644
@@ -12,17 +12,7 @@ static int ptdump_show(struct seq_file *m, void *v)
        return 0;
  }
  -static int ptdump_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, ptdump_show, inode->i_private);
-}
Quoted 8 lines

arch/arm/mm/ptdump_debugfs.c static int ptdump_show(struct seq_file *m, void *v) · line 15

Quoted 8 lines
arch/arm/mm/ptdump_debugfs.c +1 -7
-
-static const struct file_operations ptdump_fops = {
-       .open           = ptdump_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(ptdump);

Nice! Can you do the same for arch/x86/mm/debug_pagetables.c too?

-Kees

Quoted 5 lines
Quoted 4 lines
arch/arm/mm/ptdump_debugfs.c +0 -0
    int ptdump_debugfs_register(struct ptdump_info *info, const char
 *name)
  {
Signature · 1 line
Kees Cook