[PATCH] net: dsa: scope dsa_user_suspend() and

From: Pengpeng Hou

Date: Mon Mar 09 2026 - 03:52:31 EST


From: pengpeng@xxxxxxxxxxx

In current linux.git (1954c4f01220), the helpers dsa_user_suspend()
and dsa_user_resume() are defined and declared unconditionally. However,
their only in-tree callers are within dsa_switch_suspend() and
dsa_switch_resume() in net/dsa/dsa.c, which are already guarded by
CONFIG_PM_SLEEP.

Match the helper scope to their callers by wrapping the definitions in
"#ifdef CONFIG_PM_SLEEP" and providing no-op stubs in the header. This
fixes the config-scope mismatch and reduces unnecessary code footprint
when PM_SLEEP is disabled.

Signed-off-by: pengpeng@xxxxxxxxxxx
---
diff --git a/net/dsa/user.c b/net/dsa/user.c
--- a/net/dsa/user.c
+++ b/net/dsa/user.c
@@
-int dsa_user_suspend(struct net_device *user_dev)
+#ifdef CONFIG_PM_SLEEP
+int dsa_user_suspend(struct net_device *user_dev)
{
struct dsa_port *dp = dsa_user_to_port(user_dev);
@@
int dsa_user_resume(struct net_device *user_dev)
{
struct dsa_port *dp = dsa_user_to_port(user_dev);
@@

return 0;
}
+#endif

int dsa_user_create(struct dsa_port *port)
{
diff --git a/net/dsa/user.h b/net/dsa/user.h
--- a/net/dsa/user.h
+++ b/net/dsa/user.h
@@
int dsa_user_create(struct dsa_port *dp);
void dsa_user_destroy(struct net_device *user_dev);
+#ifdef CONFIG_PM_SLEEP
int dsa_user_suspend(struct net_device *user_dev);
int dsa_user_resume(struct net_device *user_dev);
+#else
+static inline int dsa_user_suspend(struct net_device *user_dev)
+{
+ return 0;
+}
+
+static inline int dsa_user_resume(struct net_device *user_dev)
+{
+ return 0;
+}
+#endif
int dsa_user_register_notifier(void);
void dsa_user_unregister_notifier(void);