[PATCH] net: bgmac: scope bgmac_enet_suspend() and bgmac_enet_resume() to CONFIG_PM

Pengpeng Hou posted 1 patch 1 month ago
[PATCH] net: bgmac: scope bgmac_enet_suspend() and bgmac_enet_resume() to CONFIG_PM
Posted by Pengpeng Hou 1 month ago
In current linux.git (1954c4f01220), bgmac_enet_suspend() and
bgmac_enet_resume() are defined and declared unconditionally. However,
their only in-tree callers are within the platform driver's PM callbacks
in bgmac-platform.c, which are already guarded by #ifdef CONFIG_PM.

Match the helper scope to their callers by wrapping the definitions in
CONFIG_PM and providing no-op stubs 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/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@
 EXPORT_SYMBOL_GPL(bgmac_enet_remove);
 
+#ifdef CONFIG_PM
 int bgmac_enet_suspend(struct bgmac *bgmac)
 {
 	if (!netif_running(bgmac->net_dev))
 		return 0;
@@
 }
 EXPORT_SYMBOL_GPL(bgmac_enet_suspend);
 
 int bgmac_enet_resume(struct bgmac *bgmac)
 {
 	int rc;
@@
 }
 EXPORT_SYMBOL_GPL(bgmac_enet_resume);
+#endif
diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h
--- a/drivers/net/ethernet/broadcom/bgmac.h
+++ b/drivers/net/ethernet/broadcom/bgmac.h
@@
 struct bgmac *bgmac_alloc(struct device *dev);
 int bgmac_enet_probe(struct bgmac *bgmac);
 void bgmac_enet_remove(struct bgmac *bgmac);
 void bgmac_adjust_link(struct net_device *net_dev);
 int bgmac_phy_connect_direct(struct bgmac *bgmac);
+#ifdef CONFIG_PM
 int bgmac_enet_suspend(struct bgmac *bgmac);
 int bgmac_enet_resume(struct bgmac *bgmac);
+#else
+static inline int bgmac_enet_suspend(struct bgmac *bgmac)
+{
+	return 0;
+}
+
+static inline int bgmac_enet_resume(struct bgmac *bgmac)
+{
+	return 0;
+}
+#endif
 
 struct mii_bus *bcma_mdio_mii_register(struct bgmac *bgmac);
 void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
Re: [PATCH] net: bgmac: scope bgmac_enet_suspend() and bgmac_enet_resume() to CONFIG_PM
Posted by Andrew Lunn 1 month ago
On Mon, Mar 09, 2026 at 09:02:38AM +0000, Pengpeng Hou wrote:
> In current linux.git (1954c4f01220), bgmac_enet_suspend() and
> bgmac_enet_resume() are defined and declared unconditionally. However,
> their only in-tree callers are within the platform driver's PM callbacks
> in bgmac-platform.c, which are already guarded by #ifdef CONFIG_PM.
> 
> Match the helper scope to their callers by wrapping the definitions in
> CONFIG_PM and providing no-op stubs in the header. This fixes the
> config-scope mismatch and avoids unnecessary code inclusion when
> power management is disabled.

Please use pm_ptr() instead. You should then be able to remove all
#ifdef CONFIG_PM. That is better for build testing.

    Andrew

---
pw-bot: cr