]> www.infradead.org Git - users/hch/misc.git/commitdiff
usb: dwc3: Refactor dwc3_mode_show
authorKuen-Han Tsai <khtsai@google.com>
Fri, 22 Aug 2025 09:23:46 +0000 (17:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Sep 2025 13:21:59 +0000 (15:21 +0200)
Use dwc3_mode_string as the single source of truth for mode-to-string
conversion.

Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/20250822092411.173519-2-khtsai@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/debugfs.c

index ebf03468fac4a9f89cefa093c6ba346f0b1035dd..d18bf5e32cc8c9cd30088a14330208ed833fd5e1 100644 (file)
@@ -402,6 +402,7 @@ static int dwc3_mode_show(struct seq_file *s, void *unused)
        struct dwc3             *dwc = s->private;
        unsigned long           flags;
        u32                     reg;
+       u32                     mode;
        int                     ret;
 
        ret = pm_runtime_resume_and_get(dwc->dev);
@@ -412,18 +413,15 @@ static int dwc3_mode_show(struct seq_file *s, void *unused)
        reg = dwc3_readl(dwc->regs, DWC3_GCTL);
        spin_unlock_irqrestore(&dwc->lock, flags);
 
-       switch (DWC3_GCTL_PRTCAP(reg)) {
+       mode = DWC3_GCTL_PRTCAP(reg);
+       switch (mode) {
        case DWC3_GCTL_PRTCAP_HOST:
-               seq_puts(s, "host\n");
-               break;
        case DWC3_GCTL_PRTCAP_DEVICE:
-               seq_puts(s, "device\n");
-               break;
        case DWC3_GCTL_PRTCAP_OTG:
-               seq_puts(s, "otg\n");
+               seq_printf(s, "%s\n", dwc3_mode_string(mode));
                break;
        default:
-               seq_printf(s, "UNKNOWN %08x\n", DWC3_GCTL_PRTCAP(reg));
+               seq_printf(s, "UNKNOWN %08x\n", mode);
        }
 
        pm_runtime_put_sync(dwc->dev);