[PATCH v2 16/19] platform/x86/intel/tpmi: Use DEFINE_SHOW_STORE_ATTRIBUTE() for mem_write
From: Kuppuswamy Sathyanarayanan
Date: Thu Sep 24 2026 - 14:34:43 EST
The mem_write debugfs file open handler and file_operations are written
out by hand, which is what DEFINE_SHOW_STORE_ATTRIBUTE() exists for. Use
it, and rename the write callback to mem_write_write() to match the name
the macro derives.
The other two files in this driver already come from
DEFINE_SHOW_ATTRIBUTE(), so this also gives mem_write the
.owner = THIS_MODULE that the open coded file_operations was missing.
Suggested-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
---
drivers/platform/x86/intel/tpmi_common.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/drivers/platform/x86/intel/tpmi_common.c b/drivers/platform/x86/intel/tpmi_common.c
index a91938024d09..b4d361f0ec44 100644
--- a/drivers/platform/x86/intel/tpmi_common.c
+++ b/drivers/platform/x86/intel/tpmi_common.c
@@ -432,7 +432,8 @@ static int tpmi_mem_dump_show(struct seq_file *s, void *unused)
}
DEFINE_SHOW_ATTRIBUTE(tpmi_mem_dump);
-static ssize_t mem_write(struct file *file, const char __user *userbuf, size_t len, loff_t *ppos)
+static ssize_t mem_write_write(struct file *file, const char __user *userbuf, size_t len,
+ loff_t *ppos)
{
struct seq_file *m = file->private_data;
struct intel_tpmi_pm_feature *pfs = m->private;
@@ -484,19 +485,7 @@ static int mem_write_show(struct seq_file *s, void *unused)
{
return 0;
}
-
-static int mem_write_open(struct inode *inode, struct file *file)
-{
- return single_open(file, mem_write_show, inode->i_private);
-}
-
-static const struct file_operations mem_write_ops = {
- .open = mem_write_open,
- .read = seq_read,
- .write = mem_write,
- .llseek = seq_lseek,
- .release = single_release,
-};
+DEFINE_SHOW_STORE_ATTRIBUTE(mem_write);
static void tpmi_dbgfs_register(struct intel_tpmi_info *tpmi_info)
{
@@ -517,7 +506,7 @@ static void tpmi_dbgfs_register(struct intel_tpmi_info *tpmi_info)
dir = debugfs_create_dir(name, tpmi_info->dbgfs_dir);
debugfs_create_file("mem_dump", 0444, dir, pfs, &tpmi_mem_dump_fops);
- debugfs_create_file("mem_write", 0644, dir, pfs, &mem_write_ops);
+ debugfs_create_file("mem_write", 0644, dir, pfs, &mem_write_fops);
}
}
--
2.43.0