Re: [PATCH v3 1/2] usb: gadget: goku_udc: move debug output to debugfs

From: Cheng Lingfei

Date: Mon Aug 31 2026 - 22:30:21 EST


On 8/26/2026 5:27 PM, Greg Kroah-Hartman wrote:
On Wed, Aug 26, 2026 at 05:15:06PM +0800, Cheng Lingfei wrote:
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@xxxxxxxxxxxxxxxxxxx>
Link: https://lore.kernel.org/2026082616-glue-atlas-0cfd@gregkh
Assisted-by: Codex:gpt-5.6
Signed-off-by: Cheng Lingfei <chenglingfei@xxxxxxxxxxx>
---
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

Why do you need this config option check anymore?

Thank you for your review. This driver follows the existing UDC driver pattern (e.g., gr_udc.c), but the additional config option check is unnecessary here. The debugfs subsystem already provides stub functions when CONFIG_DEBUG_FS is disabled: debugfs_create_dir() returns ERR_PTR(-ENODEV), and the removal helpers are safe no-ops.

I'll remove the CONFIG_USB_GADGET_DEBUG_FS conditional from this driver in the next revision.

I also noticed that several other UDC drivers still rely on this Kconfig option. Some of those checks may be redundant for the same reason, though in certain drivers the option also guards debug-only state or code. Would it be worthwhile to audit the remaining users in a separate follow-up series and, if none require compile-time gating, consider removing CONFIG_USB_GADGET_DEBUG_FS entirely?

--
Best regards,
Cheng Lingfei