[PATCH] usb: chipidea: scope ci_ulpi_resume() to CONFIG_PM

Pengpeng Hou posted 1 patch 1 month ago
[PATCH] usb: chipidea: scope ci_ulpi_resume() to CONFIG_PM
Posted by Pengpeng Hou 1 month ago
In current linux.git (1954c4f01220), ci_ulpi_resume() is defined
and declared unconditionally. However, its only in-tree caller is within
ci_controller_resume() in drivers/usb/chipidea/core.c, which is already
guarded by #ifdef CONFIG_PM.

Match the helper scope to its caller by wrapping the definition in
CONFIG_PM and providing a no-op stub in the header. This fixes the
config-scope mismatch and avoids unnecessary code inclusion when
power management is disabled.

Signed-off-by: Pengpeng Hou <pengpeng.hou@isrc.iscas.ac.cn>
---
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@
 int ci_ulpi_init(struct ci_hdrc *ci);
 void ci_ulpi_exit(struct ci_hdrc *ci);
+#ifdef CONFIG_PM
 int ci_ulpi_resume(struct ci_hdrc *ci);
+#else
+static inline int ci_ulpi_resume(struct ci_hdrc *ci)
+{
+	return 0;
+}
+#endif
 
 u32 hw_read_intr_enable(struct ci_hdrc *ci);
diff --git a/drivers/usb/chipidea/ulpi.c b/drivers/usb/chipidea/ulpi.c
--- a/drivers/usb/chipidea/ulpi.c
+++ b/drivers/usb/chipidea/ulpi.c
@@
 void ci_ulpi_exit(struct ci_hdrc *ci)
 {
 	if (ci->ulpi) {
 		ulpi_unregister_interface(ci->ulpi);
 		ci->ulpi = NULL;
 	}
 }
 
+#ifdef CONFIG_PM
 int ci_ulpi_resume(struct ci_hdrc *ci)
 {
 	int cnt = 100000;
@@
 
 	return -ETIMEDOUT;
 }
+#endif
Re: [PATCH] usb: chipidea: scope ci_ulpi_resume() to CONFIG_PM
Posted by Greg KH 1 month ago
On Mon, Mar 09, 2026 at 08:45:23AM +0000, Pengpeng Hou wrote:
> In current linux.git (1954c4f01220), ci_ulpi_resume() is defined

No need to reference the tree like this, that's not the normal way.

> and declared unconditionally. However, its only in-tree caller is within
> ci_controller_resume() in drivers/usb/chipidea/core.c, which is already
> guarded by #ifdef CONFIG_PM.
> 
> Match the helper scope to its caller by wrapping the definition in
> CONFIG_PM and providing a no-op stub in the header. This fixes the
> config-scope mismatch and avoids unnecessary code inclusion when
> power management is disabled.

How much does this actually save?  Why is only resume() needed to be
#ifdef here, not suspend?

thanks,

greg k-h