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
This commit is contained in:
parent
3c567356db
commit
6848ac7ca3
@ -10,20 +10,9 @@ static int ptdump_show(struct seq_file *m, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ptdump_open(struct inode *inode, struct file *filp)
|
DEFINE_SHOW_ATTRIBUTE(ptdump);
|
||||||
{
|
|
||||||
return single_open(filp, ptdump_show, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations ptdump_fops = {
|
static int ptdump_curknl_show(struct seq_file *m, void *v)
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.open = ptdump_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int ptdump_show_curknl(struct seq_file *m, void *v)
|
|
||||||
{
|
{
|
||||||
if (current->mm->pgd) {
|
if (current->mm->pgd) {
|
||||||
down_read(¤t->mm->mmap_sem);
|
down_read(¤t->mm->mmap_sem);
|
||||||
@ -33,23 +22,12 @@ static int ptdump_show_curknl(struct seq_file *m, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ptdump_open_curknl(struct inode *inode, struct file *filp)
|
DEFINE_SHOW_ATTRIBUTE(ptdump_curknl);
|
||||||
{
|
|
||||||
return single_open(filp, ptdump_show_curknl, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations ptdump_curknl_fops = {
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.open = ptdump_open_curknl,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release,
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef CONFIG_PAGE_TABLE_ISOLATION
|
#ifdef CONFIG_PAGE_TABLE_ISOLATION
|
||||||
static struct dentry *pe_curusr;
|
static struct dentry *pe_curusr;
|
||||||
|
|
||||||
static int ptdump_show_curusr(struct seq_file *m, void *v)
|
static int ptdump_curusr_show(struct seq_file *m, void *v)
|
||||||
{
|
{
|
||||||
if (current->mm->pgd) {
|
if (current->mm->pgd) {
|
||||||
down_read(¤t->mm->mmap_sem);
|
down_read(¤t->mm->mmap_sem);
|
||||||
@ -59,42 +37,20 @@ static int ptdump_show_curusr(struct seq_file *m, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ptdump_open_curusr(struct inode *inode, struct file *filp)
|
DEFINE_SHOW_ATTRIBUTE(ptdump_curusr);
|
||||||
{
|
|
||||||
return single_open(filp, ptdump_show_curusr, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations ptdump_curusr_fops = {
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.open = ptdump_open_curusr,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release,
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_EFI) && defined(CONFIG_X86_64)
|
#if defined(CONFIG_EFI) && defined(CONFIG_X86_64)
|
||||||
static struct dentry *pe_efi;
|
static struct dentry *pe_efi;
|
||||||
|
|
||||||
static int ptdump_show_efi(struct seq_file *m, void *v)
|
static int ptdump_efi_show(struct seq_file *m, void *v)
|
||||||
{
|
{
|
||||||
if (efi_mm.pgd)
|
if (efi_mm.pgd)
|
||||||
ptdump_walk_pgd_level_debugfs(m, efi_mm.pgd, false);
|
ptdump_walk_pgd_level_debugfs(m, efi_mm.pgd, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ptdump_open_efi(struct inode *inode, struct file *filp)
|
DEFINE_SHOW_ATTRIBUTE(ptdump_efi);
|
||||||
{
|
|
||||||
return single_open(filp, ptdump_show_efi, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations ptdump_efi_fops = {
|
|
||||||
.owner = THIS_MODULE,
|
|
||||||
.open = ptdump_open_efi,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release,
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct dentry *dir, *pe_knl, *pe_curknl;
|
static struct dentry *dir, *pe_knl, *pe_curknl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user