]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PCI: dwc: Use DEFINE_SHOW_ATTRIBUTE for ltssm_status debugfs
authorHans Zhang <18255117159@163.com>
Fri, 8 May 2026 13:34:32 +0000 (21:34 +0800)
committerManivannan Sadhasivam <mani@kernel.org>
Tue, 19 May 2026 13:30:40 +0000 (19:00 +0530)
Replace the custom open function and file_operations with the standard
DEFINE_SHOW_ATTRIBUTE macro to reduce boilerplate code.

This also adds the previously missing .release() callback and fixes the
seq_file leak during close.

Signed-off-by: Hans Zhang <18255117159@163.com>
[mani: added a note about implicit release callback change spotted by Sashiko]
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Link: https://patch.msgid.link/20260508133432.1964491-1-18255117159@163.com
drivers/pci/controller/dwc/pcie-designware-debugfs.c

index d0884253be97e4a5f5e2d378b7afa97f614c5ea2..87f5ec9c48ebf6c8d5e58b52982f72851fd22fd7 100644 (file)
@@ -507,11 +507,6 @@ static int ltssm_status_show(struct seq_file *s, void *v)
        return 0;
 }
 
-static int ltssm_status_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, ltssm_status_show, inode->i_private);
-}
-
 #define dwc_debugfs_create(name)                       \
 debugfs_create_file(#name, 0644, rasdes_debug, pci,    \
                        &dbg_ ## name ## _fops)
@@ -548,10 +543,7 @@ static const struct file_operations dwc_pcie_counter_value_ops = {
        .read = counter_value_read,
 };
 
-static const struct file_operations dwc_pcie_ltssm_status_ops = {
-       .open = ltssm_status_open,
-       .read = seq_read,
-};
+DEFINE_SHOW_ATTRIBUTE(ltssm_status);
 
 static void dwc_pcie_rasdes_debugfs_deinit(struct dw_pcie *pci)
 {
@@ -642,7 +634,7 @@ err_deinit:
 static void dwc_pcie_ltssm_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
 {
        debugfs_create_file("ltssm_status", 0444, dir, pci,
-                           &dwc_pcie_ltssm_status_ops);
+                           &ltssm_status_fops);
 }
 
 static int dw_pcie_ptm_check_capability(void *drvdata)