* [PATCH] usb: dwc3: qcom: use IS_REACHABLE(CONFIG_USB) for hub speed lookup
@ 2026-12-04 2:24 Pengpeng Hou
2026-12-04 2:45 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-12-04 2:24 UTC (permalink / raw)
To: Thinh Nguyen, Greg Kroah-Hartman; +Cc: linux-usb, linux-arm-msm, Pengpeng Hou
The Qualcomm DWC3 suspend path needs the attached USB2 device speed when
selecting wake signals. The normal and legacy drivers both bypass the
host-side query if USB host support is modular.
Use IS_REACHABLE so modular host consumers can make the query without
introducing a built-in reference to a module.
The issue was found by our static-analysis tool and manually reviewed.
Fixes: c06795f114a6 ("usb: dwc3: qcom: fix gadget-only builds")
Fixes: b958b03c82d2 ("usb: dwc3: qcom: Snapshot driver for backwards compatibilty")
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
The original patch was prepared with Gemini. Codex assisted with this
review and revision (Assisted-by: gpt 5).
Built both dwc3-qcom.o and dwc3-qcom-legacy.o on x86-64 with GCC and
W=1, USB=m and USB_DWC3_QCOM=m. With the same configuration neither
object referenced usb_hub_find_child before the change; both referenced
it afterwards. No USB suspend or hardware test was run.
drivers/usb/dwc3/dwc3-qcom-legacy.c | 2 +-
drivers/usb/dwc3/dwc3-qcom.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-qcom-legacy.c b/drivers/usb/dwc3/dwc3-qcom-legacy.c
index 189f5447aa786ce1e9ee89dd6efa215f3e956a5c..47a0f717fd53e49ecb966949b913b7c2fbaea59b 100644
--- a/drivers/usb/dwc3/dwc3-qcom-legacy.c
+++ b/drivers/usb/dwc3/dwc3-qcom-legacy.c
@@ -328,7 +328,7 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom, i
*/
hcd = platform_get_drvdata(dwc->xhci);
-#ifdef CONFIG_USB
+#if IS_REACHABLE(CONFIG_USB)
udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
#else
udev = NULL;
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index a2608416e04ecb8d3421421082ddbf7cae582de5..6501c00090c886b333599c0fee4dc919c16f2b68 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -240,7 +240,7 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom, i
*/
hcd = platform_get_drvdata(dwc->xhci);
-#ifdef CONFIG_USB
+#if IS_REACHABLE(CONFIG_USB)
udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
#else
udev = NULL;
base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: dwc3: qcom: use IS_REACHABLE(CONFIG_USB) for hub speed lookup
2026-12-04 2:24 [PATCH] usb: dwc3: qcom: use IS_REACHABLE(CONFIG_USB) for hub speed lookup Pengpeng Hou
@ 2026-12-04 2:45 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-04 2:45 UTC (permalink / raw)
To: Pengpeng Hou; +Cc: linux-usb
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] usb: dwc3: qcom: unnecessary usbcore dependency in gadget-only
builds
--
commit 8d368bc1212d1c6dd44f3c214755c23434636cce
Author: Pengpeng Hou <hppiscas@163.com>
usb: dwc3: qcom: use IS_REACHABLE(CONFIG_USB) for hub speed lookup
This commit replaces #ifdef CONFIG_USB with #if IS_REACHABLE(CONFIG_USB)
around the usb_hub_find_child() call in dwc3_qcom_read_usb2_speed() in
both the normal and legacy Qualcomm DWC3 glue drivers.
> diff --git a/drivers/usb/dwc3/dwc3-qcom-legacy.c b/drivers/usb/dwc3/dwc3-qcom-legacy.c
> index 189f5447aa786..47a0f717fd53e 100644
> --- a/drivers/usb/dwc3/dwc3-qcom-legacy.c
> +++ b/drivers/usb/dwc3/dwc3-qcom-legacy.c
> @@ -328,7 +328,7 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom, i
> */
> hcd = platform_get_drvdata(dwc->xhci);
>
> -#ifdef CONFIG_USB
> +#if IS_REACHABLE(CONFIG_USB)
> udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
> #else
> udev = NULL;
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index a2608416e04ec..6501c00090c88 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -240,7 +240,7 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom, i
> */
> hcd = platform_get_drvdata(dwc->xhci);
>
> -#ifdef CONFIG_USB
> +#if IS_REACHABLE(CONFIG_USB)
> udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
> #else
> udev = NULL;
[Severity: Low]
Does this add an unnecessary module dependency on usbcore.ko in
gadget-only DWC3 builds?
When CONFIG_USB=m, CONFIG_USB_DWC3=m, CONFIG_USB_DWC3_GADGET=y, and
CONFIG_USB_DWC3_QCOM=m, both modules now reference usb_hub_find_child()
even though DWC3 host support is compiled out and dwc->xhci is always
NULL, preventing them from loading without usbcore.ko in an initramfs.
Guarding the lookup with IS_ENABLED(CONFIG_USB_DWC3_HOST) ||
IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE), matching dwc3_host_init() in
drivers/usb/dwc3/core.h, avoids pulling in usbcore.ko in gadget-only
builds while Kconfig still guarantees CONFIG_USB is reachable.
--
Sashiko AI review · https://sashiko.dev/#/patchset/179635104069.74470.7311513117268429199@163.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 2:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 2:24 [PATCH] usb: dwc3: qcom: use IS_REACHABLE(CONFIG_USB) for hub speed lookup Pengpeng Hou
2026-12-04 2:45 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox