Skip to content

Commit 6848ac7

Browse files
TinyWindzzKAGA-KOKO
authored andcommitted
x86/mm/dump_pagetables: Use DEFINE_SHOW_ATTRIBUTE()
Use DEFINE_SHOW_ATTRIBUTE() instead of open coding it. Signed-off-by: Yangtao Li <tiny.windzz@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> Cc: keescook@chromium.org Cc: luto@kernel.org Cc: peterz@infradead.org Cc: bp@alien8.de Cc: hpa@zytor.com Link: https://lkml.kernel.org/r/20181119154334.18265-1-tiny.windzz@gmail.com
1 parent 3c56735 commit 6848ac7

File tree

1 file changed

+7
-51
lines changed

1 file changed

+7
-51
lines changed

arch/x86/mm/debug_pagetables.c

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,9 @@ static int ptdump_show(struct seq_file *m, void *v)
1010
return 0;
1111
}
1212

13-
static int ptdump_open(struct inode *inode, struct file *filp)
14-
{
15-
return single_open(filp, ptdump_show, NULL);
16-
}
17-
18-
static const struct file_operations ptdump_fops = {
19-
.owner = THIS_MODULE,
20-
.open = ptdump_open,
21-
.read = seq_read,
22-
.llseek = seq_lseek,
23-
.release = single_release,
24-
};
13+
DEFINE_SHOW_ATTRIBUTE(ptdump);
2514

26-
static int ptdump_show_curknl(struct seq_file *m, void *v)
15+
static int ptdump_curknl_show(struct seq_file *m, void *v)
2716
{
2817
if (current->mm->pgd) {
2918
down_read(&current->mm->mmap_sem);
@@ -33,23 +22,12 @@ static int ptdump_show_curknl(struct seq_file *m, void *v)
3322
return 0;
3423
}
3524

36-
static int ptdump_open_curknl(struct inode *inode, struct file *filp)
37-
{
38-
return single_open(filp, ptdump_show_curknl, NULL);
39-
}
40-
41-
static const struct file_operations ptdump_curknl_fops = {
42-
.owner = THIS_MODULE,
43-
.open = ptdump_open_curknl,
44-
.read = seq_read,
45-
.llseek = seq_lseek,
46-
.release = single_release,
47-
};
25+
DEFINE_SHOW_ATTRIBUTE(ptdump_curknl);
4826

4927
#ifdef CONFIG_PAGE_TABLE_ISOLATION
5028
static struct dentry *pe_curusr;
5129

52-
static int ptdump_show_curusr(struct seq_file *m, void *v)
30+
static int ptdump_curusr_show(struct seq_file *m, void *v)
5331
{
5432
if (current->mm->pgd) {
5533
down_read(&current->mm->mmap_sem);
@@ -59,42 +37,20 @@ static int ptdump_show_curusr(struct seq_file *m, void *v)
5937
return 0;
6038
}
6139

62-
static int ptdump_open_curusr(struct inode *inode, struct file *filp)
63-
{
64-
return single_open(filp, ptdump_show_curusr, NULL);
65-
}
66-
67-
static const struct file_operations ptdump_curusr_fops = {
68-
.owner = THIS_MODULE,
69-
.open = ptdump_open_curusr,
70-
.read = seq_read,
71-
.llseek = seq_lseek,
72-
.release = single_release,
73-
};
40+
DEFINE_SHOW_ATTRIBUTE(ptdump_curusr);
7441
#endif
7542

7643
#if defined(CONFIG_EFI) && defined(CONFIG_X86_64)
7744
static struct dentry *pe_efi;
7845

79-
static int ptdump_show_efi(struct seq_file *m, void *v)
46+
static int ptdump_efi_show(struct seq_file *m, void *v)
8047
{
8148
if (efi_mm.pgd)
8249
ptdump_walk_pgd_level_debugfs(m, efi_mm.pgd, false);
8350
return 0;
8451
}
8552

86-
static int ptdump_open_efi(struct inode *inode, struct file *filp)
87-
{
88-
return single_open(filp, ptdump_show_efi, NULL);
89-
}
90-
91-
static const struct file_operations ptdump_efi_fops = {
92-
.owner = THIS_MODULE,
93-
.open = ptdump_open_efi,
94-
.read = seq_read,
95-
.llseek = seq_lseek,
96-
.release = single_release,
97-
};
53+
DEFINE_SHOW_ATTRIBUTE(ptdump_efi);
9854
#endif
9955

10056
static struct dentry *dir, *pe_knl, *pe_curknl;

0 commit comments

Comments
 (0)