[PATCH] x86/mm/pat: use DEFINE_SHOW_ATTRIBUTE to simplify cpastats

From: Liu Shixin
Date: Wed Sep 14 2022 - 21:52:42 EST


Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code.

Signed-off-by: Liu Shixin <liushixin2@xxxxxxxxxx>
---
arch/x86/mm/pat/set_memory.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index 1a2d6376251c..b68408ffa8df 100644
--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -176,18 +176,7 @@ static int cpastats_show(struct seq_file *m, void *p)
seq_printf(m, "4K pages set-checked: %16lu\n", cpa_4k_install);
return 0;
}
-
-static int cpastats_open(struct inode *inode, struct file *file)
-{
- return single_open(file, cpastats_show, NULL);
-}
-
-static const struct file_operations cpastats_fops = {
- .open = cpastats_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(cpastats);

static int __init cpa_stats_init(void)
{
--
2.25.1