From: Cheng Lingfei <chenglingfei@foxmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>,
Felipe Balbi <balbi@kernel.org>, Peter Chen <peter.chen@nxp.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Cheng Lingfei <chenglingfei@foxmail.com>
Subject: [PATCH v3 1/2] usb: gadget: goku_udc: move debug output to debugfs
Date: Wed, 26 Aug 2026 17:15:06 +0800 [thread overview]
Message-ID: <tencent_D7673CCE71B03F2C90CD60873AB4A245D808@qq.com> (raw)
In-Reply-To: <20260826-b4-fix-usb-v3-0-b28366e817f3@foxmail.com>
goku_udc exposes diagnostic state through /proc/driver/udc. The single
global proc entry collides when more than one controller is probed and
triggers a proc registration warning.
The data is intended only for debugging and is not a userspace ABI. Move it
under the USB debugfs root and use the PCI device name for a per-device
directory. Create the file only after the UDC has been registered.
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/2026082616-glue-atlas-0cfd@gregkh
Assisted-by: Codex:gpt-5.6
Signed-off-by: Cheng Lingfei <chenglingfei@foxmail.com>
---
drivers/usb/gadget/udc/goku_udc.c | 47 +++++++++++++++++++++++++++------------
drivers/usb/gadget/udc/goku_udc.h | 5 ++++-
2 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c
index ac2a984c2f87..5ad8633f522b 100644
--- a/drivers/usb/gadget/udc/goku_udc.c
+++ b/drivers/usb/gadget/udc/goku_udc.c
@@ -20,6 +20,7 @@
// #define VERBOSE /* extra debug messages (success too) */
// #define USB_TRACE /* packet-level success messages */
+#include <linux/debugfs.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
@@ -30,9 +31,9 @@
#include <linux/timer.h>
#include <linux/list.h>
#include <linux/interrupt.h>
-#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/device.h>
+#include <linux/usb.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/prefetch.h>
@@ -1050,9 +1051,7 @@ static inline const char *dmastr(void)
return "(dma IN)";
}
-#ifdef CONFIG_USB_GADGET_DEBUG_FILES
-
-static const char proc_node_name [] = "driver/udc";
+#ifdef CONFIG_USB_GADGET_DEBUG_FS
#define FOURBITS "%s%s%s%s"
#define EIGHTBITS FOURBITS FOURBITS
@@ -1134,7 +1133,7 @@ static const char *udc_ep_status(u32 status)
return "?";
}
-static int udc_proc_read(struct seq_file *m, void *v)
+static int goku_debugfs_show(struct seq_file *m, void *v)
{
struct goku_udc *dev = m->private;
struct goku_udc_regs __iomem *regs = dev->regs;
@@ -1246,7 +1245,33 @@ static int udc_proc_read(struct seq_file *m, void *v)
local_irq_restore(flags);
return 0;
}
-#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
+DEFINE_SHOW_ATTRIBUTE(goku_debugfs);
+
+static void goku_debugfs_create(struct goku_udc *dev)
+{
+ dev->debugfs_root =
+ debugfs_create_dir(dev_name(&dev->pdev->dev), usb_debug_root);
+ debugfs_create_file("goku_udc_state", 0400, dev->debugfs_root, dev,
+ &goku_debugfs_fops);
+}
+
+static void goku_debugfs_remove(struct goku_udc *dev)
+{
+ debugfs_remove_recursive(dev->debugfs_root);
+ dev->debugfs_root = NULL;
+}
+
+#else
+
+static inline void goku_debugfs_create(struct goku_udc *dev)
+{
+}
+
+static inline void goku_debugfs_remove(struct goku_udc *dev)
+{
+}
+
+#endif /* CONFIG_USB_GADGET_DEBUG_FS */
/*-------------------------------------------------------------------------*/
@@ -1718,9 +1743,7 @@ static void goku_remove(struct pci_dev *pdev)
BUG_ON(dev->driver);
-#ifdef CONFIG_USB_GADGET_DEBUG_FILES
- remove_proc_entry(proc_node_name, NULL);
-#endif
+ goku_debugfs_remove(dev);
if (dev->regs)
udc_reset(dev);
if (dev->got_irq)
@@ -1813,15 +1836,11 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (use_dma)
pci_set_master(pdev);
-
-#ifdef CONFIG_USB_GADGET_DEBUG_FILES
- proc_create_single_data(proc_node_name, 0, NULL, udc_proc_read, dev);
-#endif
-
retval = usb_add_gadget_udc_release(&pdev->dev, &dev->gadget,
gadget_release);
if (retval)
goto err;
+ goku_debugfs_create(dev);
return 0;
diff --git a/drivers/usb/gadget/udc/goku_udc.h b/drivers/usb/gadget/udc/goku_udc.h
index 70023d401079..4885b1dae928 100644
--- a/drivers/usb/gadget/udc/goku_udc.h
+++ b/drivers/usb/gadget/udc/goku_udc.h
@@ -249,6 +249,10 @@ struct goku_udc {
configured:1,
enabled:1;
+#ifdef CONFIG_USB_GADGET_DEBUG_FS
+ struct dentry *debugfs_root;
+#endif
+
/* pci state used to access those endpoints */
struct pci_dev *pdev;
struct goku_udc_regs __iomem *regs;
@@ -286,4 +290,3 @@ struct goku_udc {
xprintk(dev , KERN_WARNING , fmt , ## args)
#define INFO(dev,fmt,args...) \
xprintk(dev , KERN_INFO , fmt , ## args)
-
--
2.53.0
next parent reply other threads:[~2026-08-26 9:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260826-b4-fix-usb-v3-0-b28366e817f3@foxmail.com>
2026-08-26 9:15 ` Cheng Lingfei [this message]
2026-08-26 9:25 ` [PATCH v3 1/2] usb: gadget: goku_udc: move debug output to debugfs Greg Kroah-Hartman
2026-08-26 10:49 ` Cheng Lingfei
2026-08-26 9:27 ` Greg Kroah-Hartman
2026-08-26 9:15 ` [PATCH v3 2/2] usb: gadget: goku_udc: fix kobject warning on probe failure Cheng Lingfei
2026-08-26 9:27 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_D7673CCE71B03F2C90CD60873AB4A245D808@qq.com \
--to=chenglingfei@foxmail.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@nxp.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox