Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: chipidea: use IS_REACHABLE() for CONFIG_USB_OTG_FSM guards
@ 2026-12-04  1:53 Pengpeng Hou
  2026-12-04  2:07 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-12-04  1:53 UTC (permalink / raw)
  To: Peter Chen, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel, Pengpeng Hou

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@163.com>
---
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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04  2:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04  1:53 [PATCH] usb: chipidea: use IS_REACHABLE() for CONFIG_USB_OTG_FSM guards Pengpeng Hou
2026-12-04  2:07 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox