Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: dwc: Use DEFINE_SHOW_ATTRIBUTE for ltssm_status debugfs
@ 2026-05-08 13:34 Hans Zhang
  2026-05-08 20:51 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Zhang @ 2026-05-08 13:34 UTC (permalink / raw)
  To: bhelgaas, lpieralisi, kwilczynski, mani, jingoohan1
  Cc: robh, linux-pci, linux-kernel, Hans Zhang

Replace the custom open function and file_operations with the
standard DEFINE_SHOW_ATTRIBUTE macro to reduce boilerplate code.

No functional change intended.

Signed-off-by: Hans Zhang <18255117159@163.com>
---
 drivers/pci/controller/dwc/pcie-designware-debugfs.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-debugfs.c b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
index d0884253be97..87f5ec9c48eb 100644
--- a/drivers/pci/controller/dwc/pcie-designware-debugfs.c
+++ b/drivers/pci/controller/dwc/pcie-designware-debugfs.c
@@ -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 @@ static int dwc_pcie_rasdes_debugfs_init(struct dw_pcie *pci, struct dentry *dir)
 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)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] PCI: dwc: Use DEFINE_SHOW_ATTRIBUTE for ltssm_status debugfs
  2026-05-08 13:34 [PATCH] PCI: dwc: Use DEFINE_SHOW_ATTRIBUTE for ltssm_status debugfs Hans Zhang
@ 2026-05-08 20:51 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-05-08 20:51 UTC (permalink / raw)
  To: Hans Zhang; +Cc: linux-pci

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The commit message inaccurately claims 'No functional change intended', while the patch implicitly fixes a memory leak and module unload race condition.
--

commit 3ba9e0fae6d8b7784978dea48b58611a119ad5c9
Author: Hans Zhang <18255117159@163.com>

PCI: dwc: Use DEFINE_SHOW_ATTRIBUTE for ltssm_status debugfs

This commit replaces the custom open function and file operations for
the ltssm_status debugfs file with the DEFINE_SHOW_ATTRIBUTE macro to
reduce boilerplate.

> Replace the custom open function and file_operations with the
> standard DEFINE_SHOW_ATTRIBUTE macro to reduce boilerplate code.
> 
> No functional change intended.

Is the "No functional change intended" description accurate here?

The original code used single_open() but did not provide a .release
callback, which leaks the seq_file on close:

> -static int ltssm_status_open(struct inode *inode, struct file *file)
> -{
> -	return single_open(file, ltssm_status_show, inode->i_private);
> -}

[ ... ]

> -static const struct file_operations dwc_pcie_ltssm_status_ops = {
> -	.open = ltssm_status_open,
> -	.read = seq_read,
> -};
> +DEFINE_SHOW_ATTRIBUTE(ltssm_status);

By migrating to DEFINE_SHOW_ATTRIBUTE(), the new file operations
automatically include .release = single_release and .owner = THIS_MODULE.

Could the commit message be updated to reflect that this implicitly fixes
a seq_file memory leak and a module unload race condition?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260508133432.1964491-1-18255117159@163.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-08 20:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 13:34 [PATCH] PCI: dwc: Use DEFINE_SHOW_ATTRIBUTE for ltssm_status debugfs Hans Zhang
2026-05-08 20:51 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox