[PATCH] usb: chipidea: use IS_REACHABLE() for CONFIG_USB_OTG_FSM guards

From: Pengpeng Hou

Date: Thu Dec 03 2026 - 20:53:28 EST


The ChipIdea OTG work and initialization paths use different tests for
USB_OTG_FSM. With both components modular, a plain CONFIG_USB_OTG_FSM
test selects the stub even though the FSM code is reachable.

Use the same reachability test for the declaration and the
implementation path. A built-in consumer must still not reference a
module-only provider.

The issue was found by our static-analysis tool and manually reviewed.

Fixes: 57677be5ef83 ("usb: chipidea: usb OTG fsm initialization.")
Fixes: cf4f21938e13 ("kbuild: Allow to specify composite modules with modname-m")
Signed-off-by: Pengpeng Hou <hppiscas@xxxxxxx>
---
The original patch was prepared with Gemini. Codex assisted with this
review and revision (Assisted-by: gpt 5).
Built ci_hdrc.o on x86-64 with GCC 11.4 and W=1 (CONFIG_USB_CHIPIDEA=m,
CONFIG_USB_OTG_FSM=m). No runtime or hardware test was performed.

drivers/usb/chipidea/ci.h | 2 +-
drivers/usb/chipidea/otg_fsm.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 97437de52ef681a70cbab1c0f4d94eab5139e7e2..f0151b4711547430fb142bfe28edeb4550ff108f 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -460,7 +460,7 @@ static inline u32 hw_test_and_write(struct ci_hdrc *ci, enum ci_hw_regs reg,
*/
static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci)
{
-#ifdef CONFIG_USB_OTG_FSM
+#if IS_REACHABLE(CONFIG_USB_OTG_FSM)
struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps;

return ci->is_otg && ci->roles[CI_ROLE_HOST] &&
diff --git a/drivers/usb/chipidea/otg_fsm.h b/drivers/usb/chipidea/otg_fsm.h
index 1f5c5ae0e71e782d76ab66390e465affaf8a1bd5..409c6b566886237f26dac107ce8b883c4d969655 100644
--- a/drivers/usb/chipidea/otg_fsm.h
+++ b/drivers/usb/chipidea/otg_fsm.h
@@ -61,7 +61,7 @@

#define TB_AIDL_BDIS (20) /* 4ms ~ 150ms, section 5.2.1 */

-#if IS_ENABLED(CONFIG_USB_OTG_FSM)
+#if IS_REACHABLE(CONFIG_USB_OTG_FSM)

int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci);
int ci_otg_fsm_work(struct ci_hdrc *ci);

base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106