Skip to contentSkip to conversation

mmc: host: use modern PM macros

PATCH In review Jisheng Zhang 8 participants 52 messages Aug 15, 2025 – Aug 22, 2025

Subsystems (31)
lore
Share & tools
lore
#0 lore raw

cover mmc: host: use modern PM macros

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards or __maybe_unused.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

Previously, I only cleaned up the host drivers which I used, e.g sdhci-of-dwcmshc, sdhci-pxav3 and sdhci-xenon, these are both compile tested and functionality tested. But then I also cleaned up other host drivers, but they are compile-tested only.

Jisheng Zhang (38):
sdhci: add some simple inline functions for !CONFIG_PM
mmc: sdhci-of-dwcmshc: use modern PM macros
mmc: sdhci-xenon: use modern PM macros
mmc: sdhci-pxav3: use modern PM macros
mmc: sunxi: use modern PM macros
mmc: alcor: use modern PM macros
mmc: atmel: use modern PM macros
mmc: au1xmmc: use modern PM macros
mmc: cb710-mmc: use modern PM macros
mmc: davinci_mmc: use modern PM macros
mmc: mmci: use modern PM macros
mmc: mxs-mmc: use modern PM macros
mmc: omap_hsmmc: use modern PM macros
mmc: rtsx_usb_sdmmc: use modern PM macros
mmc: sdhci-acpi: use modern PM macros
mmc: sdhci_am654: use modern PM macros
mmc: sdhci-brcmstb: use modern PM macros
mmc: sdhci-esdhc-imx: use modern PM macros
mmc: sdhci-of-arasan: use modern PM macros
mmc: sdhci-of-at91: use modern PM macros
mmc: sdhci-of-esdhc: use modern PM macros
mmc: sdhci-omap: use modern PM macros
mmc: sdhci-cadence: use modern PM macros
mmc: sdhci-s3c: use modern PM macros
mmc: sdhci-spear: use modern PM macros
mmc: sdhci-sprd: use modern PM macros
mmc: sdhci-st: use modern PM macros
mmc: sdhci-tegra: use modern PM macros
mmc: sh_mmicf: use modern PM macros
mmc: toshsd: use modern PM macros
mmc: wmt-sdmmc: use modern PM macros
mmc: mtk-sd: use modern PM macros
mmc: sdhci-msm: use modern PM macros
mmc: via-sdmmc: use modern PM macros
mmc: dw_mmc: exynos: use modern PM macros
mmc: dw_mmc-k3: use modern PM macros
mmc: dw_mmc-pci: use modern PM macros
mmc: dw_mmc-rockchip: use modern PM macros

 drivers/mmc/host/alcor.c            |  8 +++-----
 drivers/mmc/host/atmel-mci.c        |  9 +++------
 drivers/mmc/host/au1xmmc.c          | 18 +++++++-----------
 drivers/mmc/host/cb710-mmc.c        | 19 +++++++++----------
 drivers/mmc/host/davinci_mmc.c      | 14 +++-----------
 drivers/mmc/host/dw_mmc-exynos.c    | 13 +++----------
 drivers/mmc/host/dw_mmc-k3.c        |  9 +++------
 drivers/mmc/host/dw_mmc-pci.c       |  9 +++------
 drivers/mmc/host/dw_mmc-rockchip.c  |  9 +++------
 drivers/mmc/host/dw_mmc.h           |  3 +++
 drivers/mmc/host/mmci.c             |  9 +++------
 drivers/mmc/host/mtk-sd.c           | 14 +++++++-------
 drivers/mmc/host/mxs-mmc.c          |  6 ++----
 drivers/mmc/host/omap_hsmmc.c       | 13 ++++---------
 drivers/mmc/host/rtsx_usb_sdmmc.c   |  7 ++-----
 drivers/mmc/host/sdhci-acpi.c       | 18 ++++--------------
 drivers/mmc/host/sdhci-brcmstb.c    |  8 ++------
 drivers/mmc/host/sdhci-cadence.c    |  8 ++------
 drivers/mmc/host/sdhci-esdhc-imx.c  | 13 +++----------
 drivers/mmc/host/sdhci-msm.c        | 21 +++++++++------------
 drivers/mmc/host/sdhci-of-arasan.c  |  8 +++-----
 drivers/mmc/host/sdhci-of-at91.c    | 12 +++---------
 drivers/mmc/host/sdhci-of-dwcmshc.c | 13 +++----------
 drivers/mmc/host/sdhci-of-esdhc.c   |  8 ++------
 drivers/mmc/host/sdhci-omap.c       | 18 +++++++-----------
 drivers/mmc/host/sdhci-pxav3.c      | 11 +++--------
 drivers/mmc/host/sdhci-s3c.c        | 11 +++--------
 drivers/mmc/host/sdhci-spear.c      |  6 ++----
 drivers/mmc/host/sdhci-sprd.c       | 10 +++-------
 drivers/mmc/host/sdhci-st.c         |  6 ++----
 drivers/mmc/host/sdhci-tegra.c      | 13 +++++--------
 drivers/mmc/host/sdhci-xenon.c      | 13 +++----------
 drivers/mmc/host/sdhci.h            |  7 +++++++
 drivers/mmc/host/sdhci_am654.c      | 10 +++-------
 drivers/mmc/host/sh_mmcif.c         |  8 ++------
 drivers/mmc/host/sunxi-mmc.c        | 11 +++--------
 drivers/mmc/host/toshsd.c           |  8 ++------
 drivers/mmc/host/via-sdmmc.c        | 10 +++++-----
 drivers/mmc/host/wmt-sdmmc.c        | 16 ++--------------
 39 files changed, 141 insertions(+), 286 deletions(-)
Signature · 1 line
2.50.0
#1 lore raw

PATCH 1/38 sdhci: add some simple inline functions for !CONFIG_PM

In next commits, we will switch to the modern PM macros.

---
 drivers/mmc/host/sdhci.h | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/mmc/host/sdhci.h +7 -0
index 58fcbeaf281e..5b699af04bfe 100644
@@ -880,6 +880,13 @@ int sdhci_suspend_host(struct sdhci_host *host);
 int sdhci_resume_host(struct sdhci_host *host);
 void sdhci_runtime_suspend_host(struct sdhci_host *host);
 void sdhci_runtime_resume_host(struct sdhci_host *host, int soft_reset);
+#else
+static inline bool sdhci_enable_irq_wakeups(struct sdhci_host *host) { return false; }
+static inline void sdhci_disable_irq_wakeups(struct sdhci_host *host) {}
+static inline int sdhci_suspend_host(struct sdhci_host *host) { return -EOPNOTSUPP; }
+static inline int sdhci_resume_host(struct sdhci_host *host) { return -EOPNOTSUPP; }
+static inline void sdhci_runtime_suspend_host(struct sdhci_host *host) {}
+static inline void sdhci_runtime_resume_host(struct sdhci_host *host, int soft_reset) {}
 #endif
 
 void sdhci_cqe_enable(struct mmc_host *mmc);
Signature · 1 line
2.50.0
maintainer Acked-by on v1 1/38
#2 lore raw

Re: [PATCH 01/38] sdhci: add some simple inline functions for !CONFIG_PM

Quoted 3 lines · Jisheng Zhang

In next commits, we will switch to the modern PM macros.

Subject would normally begin: "mmc: sdhci: ", otherwise:

Quoted 22 lines
---
 drivers/mmc/host/sdhci.h | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/mmc/host/sdhci.h +7 -0
index 58fcbeaf281e..5b699af04bfe 100644
@@ -880,6 +880,13 @@ int sdhci_suspend_host(struct sdhci_host *host);
 int sdhci_resume_host(struct sdhci_host *host);
 void sdhci_runtime_suspend_host(struct sdhci_host *host);
 void sdhci_runtime_resume_host(struct sdhci_host *host, int soft_reset);
+#else
+static inline bool sdhci_enable_irq_wakeups(struct sdhci_host *host) { return false; }
+static inline void sdhci_disable_irq_wakeups(struct sdhci_host *host) {}
+static inline int sdhci_suspend_host(struct sdhci_host *host) { return -EOPNOTSUPP; }
+static inline int sdhci_resume_host(struct sdhci_host *host) { return -EOPNOTSUPP; }
+static inline void sdhci_runtime_suspend_host(struct sdhci_host *host) {}
+static inline void sdhci_runtime_resume_host(struct sdhci_host *host, int soft_reset) {}
 #endif
 
 void sdhci_cqe_enable(struct mmc_host *mmc);
#3 lore raw

PATCH 2/38 mmc: sdhci-of-dwcmshc: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-of-dwcmshc.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/mmc/host/sdhci-of-dwcmshc.c +3 -10
index ee6b1096f709..eebd45389956 100644
@@ -1499,7 +1499,6 @@ static void dwcmshc_remove(struct platform_device *pdev)
 	clk_bulk_disable_unprepare(priv->num_other_clks, priv->other_clks);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int dwcmshc_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -1570,9 +1569,6 @@ static int dwcmshc_resume(struct device *dev)
 	clk_disable_unprepare(pltfm_host->clk);
 	return ret;
 }
-#endif
-
-#ifdef CONFIG_PM
 
 static void dwcmshc_enable_card_clk(struct sdhci_host *host)
 {
@@ -1603,12 +1599,9 @@ static int dwcmshc_runtime_resume(struct device *dev)
 	return 0;
 }
 
-#endif
-
 static const struct dev_pm_ops dwcmshc_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(dwcmshc_suspend, dwcmshc_resume)
-	SET_RUNTIME_PM_OPS(dwcmshc_runtime_suspend,
-			   dwcmshc_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(dwcmshc_suspend, dwcmshc_resume)
+	RUNTIME_PM_OPS(dwcmshc_runtime_suspend, dwcmshc_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_dwcmshc_driver = {
@@ -1617,7 +1610,7 @@ static struct platform_driver sdhci_dwcmshc_driver = {
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = sdhci_dwcmshc_dt_ids,
 		.acpi_match_table = ACPI_PTR(sdhci_dwcmshc_acpi_ids),
-		.pm = &dwcmshc_pmops,
+		.pm = pm_ptr(&dwcmshc_pmops),
 	},
 	.probe	= dwcmshc_probe,
 	.remove = dwcmshc_remove,
Signature · 1 line
2.50.0
Tested-by on v1 2/38
#4 lore raw

Re: [PATCH 02/38] mmc: sdhci-of-dwcmshc: use modern PM macros

Quoted 4 lines · Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

Quoted 8 lines

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-of-dwcmshc.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
#5 lore raw

PATCH 3/38 mmc: sdhci-xenon: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-xenon.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/mmc/host/sdhci-xenon.c +3 -10
index b12bee8342bd..046e8100dd08 100644
@@ -622,7 +622,6 @@ static void xenon_remove(struct platform_device *pdev)
 	clk_disable_unprepare(pltfm_host->clk);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int xenon_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -635,9 +634,7 @@ static int xenon_suspend(struct device *dev)
 	priv->restore_needed = true;
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int xenon_runtime_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -685,14 +682,10 @@ static int xenon_runtime_resume(struct device *dev)
 	clk_disable_unprepare(pltfm_host->clk);
 	return ret;
 }
-#endif /* CONFIG_PM */
 
 static const struct dev_pm_ops sdhci_xenon_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(xenon_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(xenon_runtime_suspend,
-			   xenon_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(xenon_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(xenon_runtime_suspend, xenon_runtime_resume, NULL)
 };
 
 static const struct of_device_id sdhci_xenon_dt_ids[] = {
@@ -721,7 +714,7 @@ static struct platform_driver sdhci_xenon_driver = {
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = sdhci_xenon_dt_ids,
 		.acpi_match_table = ACPI_PTR(sdhci_xenon_acpi_ids),
-		.pm = &sdhci_xenon_dev_pm_ops,
+		.pm = pm_ptr(&sdhci_xenon_dev_pm_ops),
 	},
 	.probe	= xenon_probe,
 	.remove = xenon_remove,
Signature · 1 line
2.50.0
#6 lore raw

PATCH 4/38 mmc: sdhci-pxav3: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-pxav3.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/mmc/host/sdhci-pxav3.c +3 -8
index 1371960e34eb..6fb461cdd904 100644
@@ -484,7 +484,6 @@ static void sdhci_pxav3_remove(struct platform_device *pdev)
 	clk_disable_unprepare(pxa->clk_core);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_pxav3_suspend(struct device *dev)
 {
 	int ret;
@@ -510,9 +509,7 @@ static int sdhci_pxav3_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int sdhci_pxav3_runtime_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -544,12 +541,10 @@ static int sdhci_pxav3_runtime_resume(struct device *dev)
 	sdhci_runtime_resume_host(host, 0);
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops sdhci_pxav3_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_pxav3_suspend, sdhci_pxav3_resume)
-	SET_RUNTIME_PM_OPS(sdhci_pxav3_runtime_suspend,
-		sdhci_pxav3_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_pxav3_suspend, sdhci_pxav3_resume)
+	RUNTIME_PM_OPS(sdhci_pxav3_runtime_suspend, sdhci_pxav3_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_pxav3_driver = {
@@ -557,7 +552,7 @@ static struct platform_driver sdhci_pxav3_driver = {
 		.name	= "sdhci-pxav3",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = of_match_ptr(sdhci_pxav3_of_match),
-		.pm	= &sdhci_pxav3_pmops,
+		.pm	= pm_ptr(&sdhci_pxav3_pmops),
 	},
 	.probe		= sdhci_pxav3_probe,
 	.remove		= sdhci_pxav3_remove,
Signature · 1 line
2.50.0
#7 lore raw

PATCH 5/38 mmc: sunxi: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sunxi-mmc.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/mmc/host/sunxi-mmc.c +3 -8
index ee4a65b0a22d..8dbcff53a631 100644
@@ -1495,7 +1495,6 @@ static void sunxi_mmc_remove(struct platform_device *pdev)
 	dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
 }
 
-#ifdef CONFIG_PM
 static int sunxi_mmc_runtime_resume(struct device *dev)
 {
 	struct mmc_host	*mmc = dev_get_drvdata(dev);
@@ -1530,14 +1529,10 @@ static int sunxi_mmc_runtime_suspend(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops sunxi_mmc_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(sunxi_mmc_runtime_suspend,
-			   sunxi_mmc_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(sunxi_mmc_runtime_suspend, sunxi_mmc_runtime_resume, NULL)
 };
 
 static struct platform_driver sunxi_mmc_driver = {
@@ -1545,7 +1540,7 @@ static struct platform_driver sunxi_mmc_driver = {
 		.name	= "sunxi-mmc",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = sunxi_mmc_of_match,
-		.pm = &sunxi_mmc_pm_ops,
+		.pm = pm_ptr(&sunxi_mmc_pm_ops),
 	},
 	.probe		= sunxi_mmc_probe,
 	.remove		= sunxi_mmc_remove,
Signature · 1 line
2.50.0
#8 lore raw

PATCH 6/38 mmc: alcor: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/alcor.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/mmc/host/alcor.c +3 -5
index 288c3a91a0af..721db54739c1 100644
@@ -1129,7 +1129,6 @@ static void alcor_pci_sdmmc_drv_remove(struct platform_device *pdev)
 	mmc_remove_host(mmc);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int alcor_pci_sdmmc_suspend(struct device *dev)
 {
 	struct alcor_sdmmc_host *host = dev_get_drvdata(dev);
@@ -1150,10 +1149,9 @@ static int alcor_pci_sdmmc_resume(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM_SLEEP */
 
-static SIMPLE_DEV_PM_OPS(alcor_mmc_pm_ops, alcor_pci_sdmmc_suspend,
-			 alcor_pci_sdmmc_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(alcor_mmc_pm_ops, alcor_pci_sdmmc_suspend,
+				alcor_pci_sdmmc_resume);
 
 static const struct platform_device_id alcor_pci_sdmmc_ids[] = {
 	{
@@ -1171,7 +1169,7 @@ static struct platform_driver alcor_pci_sdmmc_driver = {
 	.driver		= {
 		.name	= DRV_NAME_ALCOR_PCI_SDMMC,
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm	= &alcor_mmc_pm_ops
+		.pm	= pm_sleep_ptr(&alcor_mmc_pm_ops),
 	},
 };
 module_platform_driver(alcor_pci_sdmmc_driver);
Signature · 1 line
2.50.0
#9 lore raw

PATCH 7/38 mmc: atmel: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/atmel-mci.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mmc/host/atmel-mci.c +3 -6
index 777342fb7657..d1fbc6811563 100644
@@ -2622,7 +2622,6 @@ static void atmci_remove(struct platform_device *pdev)
 	pm_runtime_put_noidle(dev);
 }
 
-#ifdef CONFIG_PM
 static int atmci_runtime_suspend(struct device *dev)
 {
 	struct atmel_mci *host = dev_get_drvdata(dev);
@@ -2642,12 +2641,10 @@ static int atmci_runtime_resume(struct device *dev)
 
 	return clk_prepare_enable(host->mck);
 }
-#endif
 
 static const struct dev_pm_ops atmci_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(atmci_runtime_suspend, atmci_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(atmci_runtime_suspend, atmci_runtime_resume, NULL)
 };
 
 static struct platform_driver atmci_driver = {
@@ -2657,7 +2654,7 @@ static struct platform_driver atmci_driver = {
 		.name		= "atmel_mci",
 		.probe_type	= PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table	= atmci_dt_ids,
-		.pm		= &atmci_dev_pm_ops,
+		.pm		= pm_ptr(&atmci_dev_pm_ops),
 	},
 };
 module_platform_driver(atmci_driver);
Signature · 1 line
2.50.0
#10 lore raw

PATCH 8/38 mmc: au1xmmc: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

At the same time, replace the platform_driver's .suspend and .resume usage with modern device_driver's .pm usage.

---
 drivers/mmc/host/au1xmmc.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/mmc/host/au1xmmc.c +7 -11
index 85470773650d..cc6e05f9b96f 100644
@@ -1150,10 +1150,9 @@ static void au1xmmc_remove(struct platform_device *pdev)
 	}
 }
 
-#ifdef CONFIG_PM
-static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state)
+static int au1xmmc_suspend(struct device *dev)
 {
-	struct au1xmmc_host *host = platform_get_drvdata(pdev);
+	struct au1xmmc_host *host = dev_get_drvdata(dev);
 
 	__raw_writel(0, HOST_CONFIG2(host));
 	__raw_writel(0, HOST_CONFIG(host));
@@ -1164,27 +1163,24 @@ static int au1xmmc_suspend(struct platform_device *pdev, pm_message_t state)
 	return 0;
 }
 
-static int au1xmmc_resume(struct platform_device *pdev)
+static int au1xmmc_resume(struct device *dev)
 {
-	struct au1xmmc_host *host = platform_get_drvdata(pdev);
+	struct au1xmmc_host *host = dev_get_drvdata(dev);
 
 	au1xmmc_reset_controller(host);
 
 	return 0;
 }
-#else
-#define au1xmmc_suspend NULL
-#define au1xmmc_resume NULL
-#endif
+
+static DEFINE_SIMPLE_DEV_PM_OPS(au1xmmc_pmops, au1xmmc_suspend, au1xmmc_resume);
 
 static struct platform_driver au1xmmc_driver = {
 	.probe         = au1xmmc_probe,
 	.remove        = au1xmmc_remove,
-	.suspend       = au1xmmc_suspend,
-	.resume        = au1xmmc_resume,
 	.driver        = {
 		.name  = DRIVER_NAME,
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
+		.pm = pm_sleep_ptr(&au1xmmc_pmops),
 	},
 };
 
Signature · 1 line
2.50.0
#11 lore raw

PATCH 9/38 mmc: cb710-mmc: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

At the same time, replace the platform_driver's .suspend and .resume usage with modern device_driver's .pm usage.

---
 drivers/mmc/host/cb710-mmc.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/mmc/host/cb710-mmc.c +9 -10
index 448d2f9159ea..31daec787495 100644
@@ -664,25 +664,25 @@ static const struct mmc_host_ops cb710_mmc_host = {
 	.get_cd = cb710_mmc_get_cd,
 };
 
-#ifdef CONFIG_PM
-
-static int cb710_mmc_suspend(struct platform_device *pdev, pm_message_t state)
+static int cb710_mmc_suspend(struct device *dev)
 {
+	struct platform_device *pdev = to_platform_device(dev);
 	struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
 
 	cb710_mmc_enable_irq(slot, 0, ~0);
 	return 0;
 }
 
-static int cb710_mmc_resume(struct platform_device *pdev)
+static int cb710_mmc_resume(struct device *dev)
 {
+	struct platform_device *pdev = to_platform_device(dev);
 	struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
 
 	cb710_mmc_enable_irq(slot, 0, ~0);
 	return 0;
 }
 
-#endif /* CONFIG_PM */
+static DEFINE_SIMPLE_DEV_PM_OPS(cb710_mmc_pmops, cb710_mmc_suspend, cb710_mmc_resume);
 
 static int cb710_mmc_init(struct platform_device *pdev)
 {
@@ -767,13 +767,12 @@ static void cb710_mmc_exit(struct platform_device *pdev)
 }
 
 static struct platform_driver cb710_mmc_driver = {
-	.driver.name = "cb710-mmc",
+	.driver = {
+		.name = "cb710-mmc",
+		.pm = pm_sleep_ptr(&cb710_mmc_pmops),
+	},
 	.probe = cb710_mmc_init,
 	.remove = cb710_mmc_exit,
-#ifdef CONFIG_PM
-	.suspend = cb710_mmc_suspend,
-	.resume = cb710_mmc_resume,
-#endif
 };
 
 module_platform_driver(cb710_mmc_driver);
Signature · 1 line
2.50.0
maintainer Acked-by on v1 9/38
#12 lore raw

Re: [PATCH 09/38] mmc: cb710-mmc: use modern PM macros

Quoted 72 lines · Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

At the same time, replace the platform_driver's .suspend and .resume usage with modern device_driver's .pm usage.

---
 drivers/mmc/host/cb710-mmc.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/mmc/host/cb710-mmc.c +9 -10
index 448d2f9159ea..31daec787495 100644
@@ -664,25 +664,25 @@ static const struct mmc_host_ops cb710_mmc_host = {
 	.get_cd = cb710_mmc_get_cd,
 };
 
-#ifdef CONFIG_PM
-
-static int cb710_mmc_suspend(struct platform_device *pdev, pm_message_t state)
+static int cb710_mmc_suspend(struct device *dev)
 {
+	struct platform_device *pdev = to_platform_device(dev);
 	struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
 
 	cb710_mmc_enable_irq(slot, 0, ~0);
 	return 0;
 }
 
-static int cb710_mmc_resume(struct platform_device *pdev)
+static int cb710_mmc_resume(struct device *dev)
 {
+	struct platform_device *pdev = to_platform_device(dev);
 	struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
 
 	cb710_mmc_enable_irq(slot, 0, ~0);
 	return 0;
 }
 
-#endif /* CONFIG_PM */
+static DEFINE_SIMPLE_DEV_PM_OPS(cb710_mmc_pmops, cb710_mmc_suspend, cb710_mmc_resume);
 
 static int cb710_mmc_init(struct platform_device *pdev)
 {
@@ -767,13 +767,12 @@ static void cb710_mmc_exit(struct platform_device *pdev)
 }
 
 static struct platform_driver cb710_mmc_driver = {
-	.driver.name = "cb710-mmc",
+	.driver = {
+		.name = "cb710-mmc",
+		.pm = pm_sleep_ptr(&cb710_mmc_pmops),
+	},
 	.probe = cb710_mmc_init,
 	.remove = cb710_mmc_exit,
-#ifdef CONFIG_PM
-	.suspend = cb710_mmc_suspend,
-	.resume = cb710_mmc_resume,
-#endif
 };
 
 module_platform_driver(cb710_mmc_driver);
Signature · 1 line
2.50.0
#13 lore raw

PATCH 10/38 mmc: davinci_mmc: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/davinci_mmc.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/mmc/host/davinci_mmc.c +3 -11
index c691f1b60395..75fd00fc51ed 100644
@@ -1347,7 +1347,6 @@ static void davinci_mmcsd_remove(struct platform_device *pdev)
 	clk_disable_unprepare(host->clk);
 }
 
-#ifdef CONFIG_PM
 static int davinci_mmcsd_suspend(struct device *dev)
 {
 	struct mmc_davinci_host *host = dev_get_drvdata(dev);
@@ -1373,21 +1372,14 @@ static int davinci_mmcsd_resume(struct device *dev)
 	return 0;
 }
 
-static const struct dev_pm_ops davinci_mmcsd_pm = {
-	.suspend        = davinci_mmcsd_suspend,
-	.resume         = davinci_mmcsd_resume,
-};
-
-#define davinci_mmcsd_pm_ops (&davinci_mmcsd_pm)
-#else
-#define davinci_mmcsd_pm_ops NULL
-#endif
+static DEFINE_SIMPLE_DEV_PM_OPS(davinci_mmcsd_pm_ops,
+				davinci_mmcsd_suspend, davinci_mmcsd_resume);
 
 static struct platform_driver davinci_mmcsd_driver = {
 	.driver		= {
 		.name	= "davinci_mmc",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm	= davinci_mmcsd_pm_ops,
+		.pm	= pm_sleep_ptr(&davinci_mmcsd_pm_ops),
 		.of_match_table = davinci_mmc_dt_ids,
 	},
 	.probe		= davinci_mmcsd_probe,
Signature · 1 line
2.50.0
#14 lore raw

PATCH 11/38 mmc: mmci: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/mmci.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mmc/host/mmci.c +3 -6
index 8367283647a9..e500051bd572 100644
@@ -2516,7 +2516,6 @@ static void mmci_remove(struct amba_device *dev)
 	}
 }
 
-#ifdef CONFIG_PM
 static void mmci_save(struct mmci_host *host)
 {
 	unsigned long flags;
@@ -2581,12 +2580,10 @@ static int mmci_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops mmci_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL)
 };
 
 static const struct amba_id mmci_ids[] = {
@@ -2675,7 +2672,7 @@ MODULE_DEVICE_TABLE(amba, mmci_ids);
 static struct amba_driver mmci_driver = {
 	.drv		= {
 		.name	= DRIVER_NAME,
-		.pm	= &mmci_dev_pm_ops,
+		.pm	= pm_ptr(&mmci_dev_pm_ops),
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 	},
 	.probe		= mmci_probe,
Signature · 1 line
2.50.0
#15 lore raw

PATCH 12/38 mmc: mxs-mmc: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/mxs-mmc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mmc/host/mxs-mmc.c +2 -4
index a6e44e406106..7c7c52d9e8e7 100644
@@ -680,7 +680,6 @@ static void mxs_mmc_remove(struct platform_device *pdev)
 	clk_disable_unprepare(ssp->clk);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int mxs_mmc_suspend(struct device *dev)
 {
 	struct mmc_host *mmc = dev_get_drvdata(dev);
@@ -699,9 +698,8 @@ static int mxs_mmc_resume(struct device *dev)
 
 	return clk_prepare_enable(ssp->clk);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(mxs_mmc_pm_ops, mxs_mmc_suspend, mxs_mmc_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(mxs_mmc_pm_ops, mxs_mmc_suspend, mxs_mmc_resume);
 
 static struct platform_driver mxs_mmc_driver = {
 	.probe		= mxs_mmc_probe,
@@ -709,7 +707,7 @@ static struct platform_driver mxs_mmc_driver = {
 	.driver		= {
 		.name	= DRIVER_NAME,
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm	= &mxs_mmc_pm_ops,
+		.pm	= pm_sleep_ptr(&mxs_mmc_pm_ops),
 		.of_match_table = mxs_mmc_dt_ids,
 	},
 };
Signature · 1 line
2.50.0
#16 lore raw

PATCH 13/38 mmc: omap_hsmmc: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/omap_hsmmc.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/mmc/host/omap_hsmmc.c +4 -9
index adc0d0b6ae37..09e4354d1f1d 100644
@@ -620,8 +620,6 @@ static void omap_hsmmc_set_bus_mode(struct omap_hsmmc_host *host)
 		OMAP_HSMMC_WRITE(host->base, CON, con & ~OD);
 }
 
-#ifdef CONFIG_PM
-
 /*
  * Restore the MMC host context, if it was lost as result of a
  * power state change.
@@ -689,6 +687,7 @@ static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host)
 	return 0;
 }
 
+#ifdef CONFIG_PM
 /*
  * Save the MMC host context (store the number of power state changes so far).
  */
@@ -1990,7 +1989,6 @@ static void omap_hsmmc_remove(struct platform_device *pdev)
 	clk_disable_unprepare(host->dbclk);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int omap_hsmmc_suspend(struct device *dev)
 {
 	struct omap_hsmmc_host *host = dev_get_drvdata(dev);
@@ -2032,9 +2030,7 @@ static int omap_hsmmc_resume(struct device *dev)
 	pm_runtime_put_autosuspend(host->dev);
 	return 0;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int omap_hsmmc_runtime_suspend(struct device *dev)
 {
 	struct omap_hsmmc_host *host;
@@ -2102,11 +2098,10 @@ static int omap_hsmmc_runtime_resume(struct device *dev)
 	spin_unlock_irqrestore(&host->irq_lock, flags);
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops omap_hsmmc_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(omap_hsmmc_suspend, omap_hsmmc_resume)
-	SET_RUNTIME_PM_OPS(omap_hsmmc_runtime_suspend, omap_hsmmc_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(omap_hsmmc_suspend, omap_hsmmc_resume)
+	RUNTIME_PM_OPS(omap_hsmmc_runtime_suspend, omap_hsmmc_runtime_resume, NULL)
 };
 
 static struct platform_driver omap_hsmmc_driver = {
@@ -2115,7 +2110,7 @@ static struct platform_driver omap_hsmmc_driver = {
 	.driver		= {
 		.name = DRIVER_NAME,
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm = &omap_hsmmc_dev_pm_ops,
+		.pm = pm_ptr(&omap_hsmmc_dev_pm_ops),
 		.of_match_table = of_match_ptr(omap_mmc_of_match),
 	},
 };
Signature · 1 line
2.50.0
#17 lore raw

PATCH 14/38 mmc: rtsx_usb_sdmmc: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mmc/host/rtsx_usb_sdmmc.c +2 -5
index c5f6b9df066b..98184b140a41 100644
@@ -1428,7 +1428,6 @@ static void rtsx_usb_sdmmc_drv_remove(struct platform_device *pdev)
 		": Realtek USB SD/MMC module has been removed\n");
 }
 
-#ifdef CONFIG_PM
 static int rtsx_usb_sdmmc_runtime_suspend(struct device *dev)
 {
 	struct rtsx_usb_sdmmc *host = dev_get_drvdata(dev);
@@ -1446,11 +1445,9 @@ static int rtsx_usb_sdmmc_runtime_resume(struct device *dev)
 		mmc_detect_change(host->mmc, 0);
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops rtsx_usb_sdmmc_dev_pm_ops = {
-	SET_RUNTIME_PM_OPS(rtsx_usb_sdmmc_runtime_suspend,
-			   rtsx_usb_sdmmc_runtime_resume, NULL)
+	RUNTIME_PM_OPS(rtsx_usb_sdmmc_runtime_suspend, rtsx_usb_sdmmc_runtime_resume, NULL)
 };
 
 static const struct platform_device_id rtsx_usb_sdmmc_ids[] = {
@@ -1469,7 +1466,7 @@ static struct platform_driver rtsx_usb_sdmmc_driver = {
 	.driver		= {
 		.name	= "rtsx_usb_sdmmc",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm	= &rtsx_usb_sdmmc_dev_pm_ops,
+		.pm	= pm_ptr(&rtsx_usb_sdmmc_dev_pm_ops),
 	},
 };
 module_platform_driver(rtsx_usb_sdmmc_driver);
Signature · 1 line
2.50.0
#18 lore raw

PATCH 15/38 mmc: sdhci-acpi: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-acpi.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/mmc/host/sdhci-acpi.c +4 -14
index 2d46d4854fa1..84c7054607fc 100644
@@ -973,8 +973,7 @@ static void sdhci_acpi_remove(struct platform_device *pdev)
 		c->slot->free_slot(pdev);
 }
 
-static void __maybe_unused sdhci_acpi_reset_signal_voltage_if_needed(
-	struct device *dev)
+static void sdhci_acpi_reset_signal_voltage_if_needed(struct device *dev)
 {
 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
 	struct sdhci_host *host = c->host;
@@ -989,8 +988,6 @@ static void __maybe_unused sdhci_acpi_reset_signal_voltage_if_needed(
 	}
 }
 
-#ifdef CONFIG_PM_SLEEP
-
 static int sdhci_acpi_suspend(struct device *dev)
 {
 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
@@ -1017,10 +1014,6 @@ static int sdhci_acpi_resume(struct device *dev)
 	return sdhci_resume_host(c->host);
 }
 
-#endif
-
-#ifdef CONFIG_PM
-
 static int sdhci_acpi_runtime_suspend(struct device *dev)
 {
 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
@@ -1045,12 +1038,9 @@ static int sdhci_acpi_runtime_resume(struct device *dev)
 	return 0;
 }
 
-#endif
-
 static const struct dev_pm_ops sdhci_acpi_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_acpi_suspend, sdhci_acpi_resume)
-	SET_RUNTIME_PM_OPS(sdhci_acpi_runtime_suspend,
-			sdhci_acpi_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_acpi_suspend, sdhci_acpi_resume)
+	RUNTIME_PM_OPS(sdhci_acpi_runtime_suspend, sdhci_acpi_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_acpi_driver = {
@@ -1058,7 +1048,7 @@ static struct platform_driver sdhci_acpi_driver = {
 		.name			= "sdhci-acpi",
 		.probe_type		= PROBE_PREFER_ASYNCHRONOUS,
 		.acpi_match_table	= sdhci_acpi_ids,
-		.pm			= &sdhci_acpi_pm_ops,
+		.pm			= pm_ptr(&sdhci_acpi_pm_ops),
 	},
 	.probe	= sdhci_acpi_probe,
 	.remove = sdhci_acpi_remove,
Signature · 1 line
2.50.0
maintainer Acked-by on v1 15/38
#19 lore raw

Re: [PATCH 15/38] mmc: sdhci-acpi: use modern PM macros

Quoted 9 lines · Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

Quoted 62 lines
---
 drivers/mmc/host/sdhci-acpi.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/mmc/host/sdhci-acpi.c +4 -14
index 2d46d4854fa1..84c7054607fc 100644
@@ -973,8 +973,7 @@ static void sdhci_acpi_remove(struct platform_device *pdev)
 		c->slot->free_slot(pdev);
 }
 
-static void __maybe_unused sdhci_acpi_reset_signal_voltage_if_needed(
-	struct device *dev)
+static void sdhci_acpi_reset_signal_voltage_if_needed(struct device *dev)
 {
 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
 	struct sdhci_host *host = c->host;
@@ -989,8 +988,6 @@ static void __maybe_unused sdhci_acpi_reset_signal_voltage_if_needed(
 	}
 }
 
-#ifdef CONFIG_PM_SLEEP
-
 static int sdhci_acpi_suspend(struct device *dev)
 {
 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
@@ -1017,10 +1014,6 @@ static int sdhci_acpi_resume(struct device *dev)
 	return sdhci_resume_host(c->host);
 }
 
-#endif
-
-#ifdef CONFIG_PM
-
 static int sdhci_acpi_runtime_suspend(struct device *dev)
 {
 	struct sdhci_acpi_host *c = dev_get_drvdata(dev);
@@ -1045,12 +1038,9 @@ static int sdhci_acpi_runtime_resume(struct device *dev)
 	return 0;
 }
 
-#endif
-
 static const struct dev_pm_ops sdhci_acpi_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_acpi_suspend, sdhci_acpi_resume)
-	SET_RUNTIME_PM_OPS(sdhci_acpi_runtime_suspend,
-			sdhci_acpi_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_acpi_suspend, sdhci_acpi_resume)
+	RUNTIME_PM_OPS(sdhci_acpi_runtime_suspend, sdhci_acpi_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_acpi_driver = {
@@ -1058,7 +1048,7 @@ static struct platform_driver sdhci_acpi_driver = {
 		.name			= "sdhci-acpi",
 		.probe_type		= PROBE_PREFER_ASYNCHRONOUS,
 		.acpi_match_table	= sdhci_acpi_ids,
-		.pm			= &sdhci_acpi_pm_ops,
+		.pm			= pm_ptr(&sdhci_acpi_pm_ops),
 	},
 	.probe	= sdhci_acpi_probe,
 	.remove = sdhci_acpi_remove,
#20 lore raw

PATCH 16/38 mmc: sdhci_am654: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci_am654.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci_am654.c +3 -7
index e4fc345be7e5..48bf5532e571 100644
@@ -1018,7 +1018,6 @@ static void sdhci_am654_remove(struct platform_device *pdev)
 	pm_runtime_put_noidle(dev);
 }
 
-#ifdef CONFIG_PM
 static int sdhci_am654_restore(struct sdhci_host *host)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -1106,20 +1105,17 @@ static int sdhci_am654_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops sdhci_am654_dev_pm_ops = {
-	SET_RUNTIME_PM_OPS(sdhci_am654_runtime_suspend,
-			   sdhci_am654_runtime_resume, NULL)
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
+	RUNTIME_PM_OPS(sdhci_am654_runtime_suspend, sdhci_am654_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
 };
 
 static struct platform_driver sdhci_am654_driver = {
 	.driver = {
 		.name = "sdhci-am654",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm = &sdhci_am654_dev_pm_ops,
+		.pm = pm_ptr(&sdhci_am654_dev_pm_ops),
 		.of_match_table = sdhci_am654_of_match,
 	},
 	.probe = sdhci_am654_probe,
Signature · 1 line
2.50.0
#21 lore raw

PATCH 17/38 mmc: sdhci-brcmstb: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-brcmstb.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-brcmstb.c +2 -6
index efc2f3bdc631..15705e85417f 100644
@@ -496,7 +496,6 @@ static void sdhci_brcmstb_shutdown(struct platform_device *pdev)
 
 MODULE_DEVICE_TABLE(of, sdhci_brcm_of_match);
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_brcmstb_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -540,17 +539,14 @@ static int sdhci_brcmstb_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops sdhci_brcmstb_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_brcmstb_suspend, sdhci_brcmstb_resume)
-};
+static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_brcmstb_pmops, sdhci_brcmstb_suspend, sdhci_brcmstb_resume);
 
 static struct platform_driver sdhci_brcmstb_driver = {
 	.driver		= {
 		.name	= "sdhci-brcmstb",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm	= &sdhci_brcmstb_pmops,
+		.pm	= pm_sleep_ptr(&sdhci_brcmstb_pmops),
 		.of_match_table = of_match_ptr(sdhci_brcm_of_match),
 	},
 	.probe		= sdhci_brcmstb_probe,
Signature · 1 line
2.50.0
#22 lore raw

PATCH 18/38 mmc: sdhci-esdhc-imx: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +3 -10
index a040c0896a7b..a7a5df673b0f 100644
@@ -1650,7 +1650,6 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host)
 	}
 }
 
-#ifdef CONFIG_PM_SLEEP
 static void sdhc_esdhc_tuning_save(struct sdhci_host *host)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -1707,7 +1706,6 @@ static void sdhc_esdhc_tuning_restore(struct sdhci_host *host)
 		       host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
 	}
 }
-#endif
 
 static void esdhc_cqe_enable(struct mmc_host *mmc)
 {
@@ -2016,7 +2014,6 @@ static void sdhci_esdhc_imx_remove(struct platform_device *pdev)
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_esdhc_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -2112,9 +2109,7 @@ static int sdhci_esdhc_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int sdhci_esdhc_runtime_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -2188,12 +2183,10 @@ static int sdhci_esdhc_runtime_resume(struct device *dev)
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
 	return err;
 }
-#endif
 
 static const struct dev_pm_ops sdhci_esdhc_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
-	SET_RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
-				sdhci_esdhc_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
+	RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend, sdhci_esdhc_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_esdhc_imx_driver = {
@@ -2201,7 +2194,7 @@ static struct platform_driver sdhci_esdhc_imx_driver = {
 		.name	= "sdhci-esdhc-imx",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = imx_esdhc_dt_ids,
-		.pm	= &sdhci_esdhc_pmops,
+		.pm	= pm_ptr(&sdhci_esdhc_pmops),
 	},
 	.probe		= sdhci_esdhc_imx_probe,
 	.remove		= sdhci_esdhc_imx_remove,
Signature · 1 line
2.50.0
maintainer
#23 lore raw

RE: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 33 lines

-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: 2025年8月15日 9:34
To: Ulf Hansson <[email protected]>; Aubin Constans <[email protected]>; Nicolas Ferre <[email protected]>; Alexandre Belloni <[email protected]>; Claudiu Beznea <[email protected]>; Manuel Lauss <[email protected]>; Michał Mirosław <[email protected]>; Jaehoon Chung <[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>; Heiko Stuebner <[email protected]>; Russell King <[email protected]>; Chaotian Jing <[email protected]>; Matthias Brugger <[email protected]>; AngeloGioacchino Del Regno <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Adrian Hunter <[email protected]>; Kamal Dasu <[email protected]>; Al Cooper <[email protected]>; Broadcom internal kernel review list <[email protected]>; Florian Fainelli <[email protected]>; Bough Chen <[email protected]>; Michal Simek <[email protected]>; Eugen Hristev <[email protected]>; Vignesh Raghavendra <[email protected]>; Ben Dooks <[email protected]>; Viresh Kumar <[email protected]>; Orson Zhai <[email protected]>; Baolin Wang <[email protected]>; Chunyan Zhang <[email protected]>; Patrice Chotard <[email protected]>; Thierry Reding <[email protected]>; Jonathan Hunter <[email protected]>; Chen-Yu Tsai <[email protected]>; Jernej Skrabec <[email protected]>; Samuel Holland <[email protected]>; Alexey Charkov <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 7 lines

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

Hi Jisheng,

When I remove all the configs under Power management options I got the following build warning:

drivers/mmc/host/sdhci-esdhc-imx.c:2079:12: warning: ‘sdhci_esdhc_resume’ defined but not used [-Wunused-function]
2079 | static int sdhci_esdhc_resume(struct device *dev)

      |            ^~~~~~~~~~~~~~~~~~
  CC      drivers/mmc/host/cqhci-core.o
drivers/mmc/host/sdhci-esdhc-imx.c:2017:12: warning: ‘sdhci_esdhc_suspend’ defined but not used [-Wunused-function]
 2017 | static int sdhci_esdhc_suspend(struct device *dev)
      |            ^~~~~~~~~~~~~~~~~~~

Regards
Haibo Chen

Quoted 70 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +2 -2
index a040c0896a7b..a7a5df673b0f 100644
@@ -1650,7 +1650,6 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host
 *host)
 	}
 }
 
-#ifdef CONFIG_PM_SLEEP
 static void sdhc_esdhc_tuning_save(struct sdhci_host *host)  {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -1707,7
+1706,6 @@ static void sdhc_esdhc_tuning_restore(struct sdhci_host *host)
 		       host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
 	}
 }
-#endif
 
 static void esdhc_cqe_enable(struct mmc_host *mmc)  { @@ -2016,7
+2014,6 @@ static void sdhci_esdhc_imx_remove(struct platform_device

*pdev)

drivers/mmc/host/sdhci-esdhc-imx.c +0 -1
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_esdhc_suspend(struct device *dev)  {
 	struct sdhci_host *host = dev_get_drvdata(dev); @@ -2112,9 +2109,7 @@

static int sdhci_esdhc_resume(struct device *dev)

drivers/mmc/host/sdhci-esdhc-imx.c +0 -2
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int sdhci_esdhc_runtime_suspend(struct device *dev)  {
 	struct sdhci_host *host = dev_get_drvdata(dev); @@ -2188,12 +2183,10

@@ static int sdhci_esdhc_runtime_resume(struct device *dev)

drivers/mmc/host/sdhci-esdhc-imx.c +3 -4
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
 	return err;
 }
-#endif
 
 static const struct dev_pm_ops sdhci_esdhc_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
-	SET_RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
-				sdhci_esdhc_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
+	RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
+sdhci_esdhc_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_esdhc_imx_driver = { @@ -2201,7 +2194,7

@@ static struct platform_driver sdhci_esdhc_imx_driver = {

drivers/mmc/host/sdhci-esdhc-imx.c +1 -2
 		.name	= "sdhci-esdhc-imx",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = imx_esdhc_dt_ids,
-		.pm	= &sdhci_esdhc_pmops,
+		.pm	= pm_ptr(&sdhci_esdhc_pmops),
 	},
 	.probe		= sdhci_esdhc_imx_probe,
 	.remove		= sdhci_esdhc_imx_remove,
--

2.50.0

#24 lore raw

Re: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 37 lines · Bough Chen
Quoted 37 lines

-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: 2025Ҵ8��15�� 9:34
To: Ulf Hansson <[email protected]>; Aubin Constans <[email protected]>; Nicolas Ferre <[email protected]>; Alexandre Belloni <[email protected]>; Claudiu Beznea <[email protected]>; Manuel Lauss <[email protected]>; Micha�� Miros��aw <[email protected]>; Jaehoon Chung <[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>; Heiko Stuebner <[email protected]>; Russell King <[email protected]>; Chaotian Jing <[email protected]>; Matthias Brugger <[email protected]>; AngeloGioacchino Del Regno <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Adrian Hunter <[email protected]>; Kamal Dasu <[email protected]>; Al Cooper <[email protected]>; Broadcom internal kernel review list <[email protected]>; Florian Fainelli <[email protected]>; Bough Chen <[email protected]>; Michal Simek <[email protected]>; Eugen Hristev <[email protected]>; Vignesh Raghavendra <[email protected]>; Ben Dooks <[email protected]>; Viresh Kumar <[email protected]>; Orson Zhai <[email protected]>; Baolin Wang <[email protected]>; Chunyan Zhang <[email protected]>; Patrice Chotard <[email protected]>; Thierry Reding <[email protected]>; Jonathan Hunter <[email protected]>; Chen-Yu Tsai <[email protected]>; Jernej Skrabec <[email protected]>; Samuel Holland <[email protected]>; Alexey Charkov <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

Quoted 5 lines
Quoted 3 lines

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

Hi Jisheng,

Hi,

Quoted 10 lines

When I remove all the configs under Power management options I got the following build warning:

drivers/mmc/host/sdhci-esdhc-imx.c:2079:12: warning: ��sdhci_esdhc_resume�� defined but not used [-Wunused-function]
2079 | static int sdhci_esdhc_resume(struct device *dev)

      |            ^~~~~~~~~~~~~~~~~~
  CC      drivers/mmc/host/cqhci-core.o
drivers/mmc/host/sdhci-esdhc-imx.c:2017:12: warning: ��sdhci_esdhc_suspend�� defined but not used [-Wunused-function]
 2017 | static int sdhci_esdhc_suspend(struct device *dev)
      |            ^~~~~~~~~~~~~~~~~~~

Hmm interesting, what's test toolchain? I tested this patch with gcc14 with below three combinations before sending out, no warnings at all:
PM + PM_SLEEP
PM only
!PM + ! PM_SLEEP

The sdhci_esdhc_suspend|resume are referenced by SYSTEM_SLEEP_PM_OPS. The pm_sleep_ptr() macro does the tricky, when both PM and PM_SLEEP are disabled, they are optimized out.

So can you plz kindly show your toolchain? I will check

Thanks

Quoted 74 lines

Regards
Haibo Chen

Quoted 70 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +2 -2
index a040c0896a7b..a7a5df673b0f 100644
@@ -1650,7 +1650,6 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host
 *host)
 	}
 }
 
-#ifdef CONFIG_PM_SLEEP
 static void sdhc_esdhc_tuning_save(struct sdhci_host *host)  {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -1707,7
+1706,6 @@ static void sdhc_esdhc_tuning_restore(struct sdhci_host *host)
 		       host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
 	}
 }
-#endif
 
 static void esdhc_cqe_enable(struct mmc_host *mmc)  { @@ -2016,7
+2014,6 @@ static void sdhci_esdhc_imx_remove(struct platform_device

*pdev)

drivers/mmc/host/sdhci-esdhc-imx.c +0 -1
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_esdhc_suspend(struct device *dev)  {
 	struct sdhci_host *host = dev_get_drvdata(dev); @@ -2112,9 +2109,7 @@

static int sdhci_esdhc_resume(struct device *dev)

drivers/mmc/host/sdhci-esdhc-imx.c +0 -2
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int sdhci_esdhc_runtime_suspend(struct device *dev)  {
 	struct sdhci_host *host = dev_get_drvdata(dev); @@ -2188,12 +2183,10

@@ static int sdhci_esdhc_runtime_resume(struct device *dev)

drivers/mmc/host/sdhci-esdhc-imx.c +3 -4
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
 	return err;
 }
-#endif
 
 static const struct dev_pm_ops sdhci_esdhc_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
-	SET_RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
-				sdhci_esdhc_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
+	RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
+sdhci_esdhc_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_esdhc_imx_driver = { @@ -2201,7 +2194,7

@@ static struct platform_driver sdhci_esdhc_imx_driver = {

drivers/mmc/host/sdhci-esdhc-imx.c +1 -2
 		.name	= "sdhci-esdhc-imx",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = imx_esdhc_dt_ids,
-		.pm	= &sdhci_esdhc_pmops,
+		.pm	= pm_ptr(&sdhci_esdhc_pmops),
 	},
 	.probe		= sdhci_esdhc_imx_probe,
 	.remove		= sdhci_esdhc_imx_remove,
--

2.50.0

#25 lore raw

Re: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 63 lines · Jisheng Zhang
Quoted 37 lines · Bough Chen
Quoted 37 lines

-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: 2025Ҵ8??15?? 9:34
To: Ulf Hansson <[email protected]>; Aubin Constans <[email protected]>; Nicolas Ferre <[email protected]>; Alexandre Belloni <[email protected]>; Claudiu Beznea <[email protected]>; Manuel Lauss <[email protected]>; Micha?? Miros??aw <[email protected]>; Jaehoon Chung <[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>; Heiko Stuebner <[email protected]>; Russell King <[email protected]>; Chaotian Jing <[email protected]>; Matthias Brugger <[email protected]>; AngeloGioacchino Del Regno <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Adrian Hunter <[email protected]>; Kamal Dasu <[email protected]>; Al Cooper <[email protected]>; Broadcom internal kernel review list <[email protected]>; Florian Fainelli <[email protected]>; Bough Chen <[email protected]>; Michal Simek <[email protected]>; Eugen Hristev <[email protected]>; Vignesh Raghavendra <[email protected]>; Ben Dooks <[email protected]>; Viresh Kumar <[email protected]>; Orson Zhai <[email protected]>; Baolin Wang <[email protected]>; Chunyan Zhang <[email protected]>; Patrice Chotard <[email protected]>; Thierry Reding <[email protected]>; Jonathan Hunter <[email protected]>; Chen-Yu Tsai <[email protected]>; Jernej Skrabec <[email protected]>; Samuel Holland <[email protected]>; Alexey Charkov <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

Quoted 5 lines
Quoted 3 lines

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

Hi Jisheng,

Hi,

Quoted 10 lines

When I remove all the configs under Power management options I got the following build warning:

drivers/mmc/host/sdhci-esdhc-imx.c:2079:12: warning: ??sdhci_esdhc_resume?? defined but not used [-Wunused-function]
2079 | static int sdhci_esdhc_resume(struct device *dev)

      |            ^~~~~~~~~~~~~~~~~~
  CC      drivers/mmc/host/cqhci-core.o
drivers/mmc/host/sdhci-esdhc-imx.c:2017:12: warning: ??sdhci_esdhc_suspend?? defined but not used [-Wunused-function]
 2017 | static int sdhci_esdhc_suspend(struct device *dev)
      |            ^~~~~~~~~~~~~~~~~~~

Hmm interesting, what's test toolchain? I tested this patch with gcc14 with below three combinations before sending out, no warnings at all:
PM + PM_SLEEP
PM only
!PM + ! PM_SLEEP

Quoted 3 lines

The sdhci_esdhc_suspend|resume are referenced by SYSTEM_SLEEP_PM_OPS. The pm_sleep_ptr() macro does the tricky, when both PM and PM_SLEEP are disabled, they are optimized out.

Hi Haibo,

Could you plz share your toolchain information? And FYI, today I tested clang with the above three combinations, also no warnings. So I'm really interested how to reproduce your warnings.

And the kernel CI build robot hasn't sent out warning email so far.

Thanks

Quoted 78 lines

So can you plz kindly show your toolchain? I will check

Thanks

Quoted 74 lines

Regards
Haibo Chen

Quoted 70 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +2 -2
index a040c0896a7b..a7a5df673b0f 100644
@@ -1650,7 +1650,6 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host
 *host)
 	}
 }
 
-#ifdef CONFIG_PM_SLEEP
 static void sdhc_esdhc_tuning_save(struct sdhci_host *host)  {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -1707,7
+1706,6 @@ static void sdhc_esdhc_tuning_restore(struct sdhci_host *host)
 		       host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
 	}
 }
-#endif
 
 static void esdhc_cqe_enable(struct mmc_host *mmc)  { @@ -2016,7
+2014,6 @@ static void sdhci_esdhc_imx_remove(struct platform_device

*pdev)

drivers/mmc/host/sdhci-esdhc-imx.c +0 -1
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_esdhc_suspend(struct device *dev)  {
 	struct sdhci_host *host = dev_get_drvdata(dev); @@ -2112,9 +2109,7 @@

static int sdhci_esdhc_resume(struct device *dev)

drivers/mmc/host/sdhci-esdhc-imx.c +0 -2
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int sdhci_esdhc_runtime_suspend(struct device *dev)  {
 	struct sdhci_host *host = dev_get_drvdata(dev); @@ -2188,12 +2183,10

@@ static int sdhci_esdhc_runtime_resume(struct device *dev)

drivers/mmc/host/sdhci-esdhc-imx.c +3 -4
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
 	return err;
 }
-#endif
 
 static const struct dev_pm_ops sdhci_esdhc_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
-	SET_RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
-				sdhci_esdhc_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
+	RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
+sdhci_esdhc_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_esdhc_imx_driver = { @@ -2201,7 +2194,7

@@ static struct platform_driver sdhci_esdhc_imx_driver = {

drivers/mmc/host/sdhci-esdhc-imx.c +1 -2
 		.name	= "sdhci-esdhc-imx",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = imx_esdhc_dt_ids,
-		.pm	= &sdhci_esdhc_pmops,
+		.pm	= pm_ptr(&sdhci_esdhc_pmops),
 	},
 	.probe		= sdhci_esdhc_imx_probe,
 	.remove		= sdhci_esdhc_imx_remove,
--

2.50.0

maintainer
#26 lore raw

RE: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 109 lines

-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: 2025年8月18日 20:15
To: Bough Chen <[email protected]>
Cc: Ulf Hansson <[email protected]>; Aubin Constans <[email protected]>; Nicolas Ferre <[email protected]>; Alexandre Belloni <[email protected]>; Claudiu Beznea <[email protected]>; Manuel Lauss <[email protected]>; Micha�� Miros��aw <[email protected]>; Jaehoon Chung <[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>; Heiko Stuebner <[email protected]>; Russell King <[email protected]>; Chaotian Jing <[email protected]>; Matthias Brugger <[email protected]>; AngeloGioacchino Del Regno <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Adrian Hunter <[email protected]>; Kamal Dasu <[email protected]>; Al Cooper <[email protected]>; Broadcom internal kernel review list <[email protected]>; Florian Fainelli <[email protected]>; Michal Simek <[email protected]>; Eugen Hristev <[email protected]>; Vignesh Raghavendra <[email protected]>; Ben Dooks <[email protected]>; Viresh Kumar <[email protected]>; Orson Zhai <[email protected]>; Baolin Wang <[email protected]>; Chunyan Zhang <[email protected]>; Patrice Chotard <[email protected]>; Thierry Reding <[email protected]>; Jonathan Hunter <[email protected]>; Chen-Yu Tsai <[email protected]>; Jernej Skrabec <[email protected]>; Samuel Holland <[email protected]>; Alexey Charkov <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 42 lines · Jisheng Zhang
Quoted 41 lines · Bough Chen
Quoted 41 lines

-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: 2025Ҵ8??15?? 9:34
To: Ulf Hansson <[email protected]>; Aubin Constans <[email protected]>; Nicolas Ferre <[email protected]>; Alexandre Belloni <[email protected]>; Claudiu Beznea <[email protected]>; Manuel Lauss <[email protected]>; Micha?? Miros??aw <[email protected]>; Jaehoon Chung <[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>; Heiko Stuebner <[email protected]>; Russell King <[email protected]>; Chaotian Jing <[email protected]>; Matthias Brugger <[email protected]>; AngeloGioacchino Del Regno <[email protected]>;
Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Adrian Hunter <[email protected]>; Kamal Dasu <[email protected]>; Al Cooper <[email protected]>; Broadcom internal kernel review list <[email protected]>; Florian Fainelli <[email protected]>; Bough Chen <[email protected]>; Michal Simek <[email protected]>; Eugen Hristev <[email protected]>; Vignesh Raghavendra <[email protected]>; Ben Dooks <[email protected]>; Viresh Kumar <[email protected]>; Orson Zhai <[email protected]>; Baolin Wang <[email protected]>; Chunyan Zhang <[email protected]>; Patrice Chotard <[email protected]>; Thierry Reding <[email protected]>; Jonathan Hunter <[email protected]>; Chen-Yu Tsai <[email protected]>; Jernej Skrabec <[email protected]>; Samuel Holland <[email protected]>; Alexey Charkov <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

Hi Jisheng,

Hi,

Quoted 2 lines

When I remove all the configs under Power management options I got the

following build warning:

Quoted 11 lines
Quoted 10 lines

drivers/mmc/host/sdhci-esdhc-imx.c:2079:12: warning:
??sdhci_esdhc_resume?? defined but not used [-Wunused-function]
2079 | static int sdhci_esdhc_resume(struct device *dev)

      |            ^~~~~~~~~~~~~~~~~~

CC drivers/mmc/host/cqhci-core.o
drivers/mmc/host/sdhci-esdhc-imx.c:2017:12: warning:
??sdhci_esdhc_suspend?? defined but not used [-Wunused-function]
2017 | static int sdhci_esdhc_suspend(struct device *dev)

      |            ^~~~~~~~~~~~~~~~~~~
Quoted 7 lines

Hmm interesting, what's test toolchain? I tested this patch with gcc14 with below three combinations before sending out, no warnings at all:
PM + PM_SLEEP
PM only
!PM + ! PM_SLEEP

The sdhci_esdhc_suspend|resume are referenced by

SYSTEM_SLEEP_PM_OPS.

Quoted 2 lines

The pm_sleep_ptr() macro does the tricky, when both PM and PM_SLEEP are disabled, they are optimized out.

Quoted 7 lines

Hi Haibo,

Could you plz share your toolchain information? And FYI, today I tested clang with the above three combinations, also no warnings. So I'm really interested how to reproduce your warnings.

And the kernel CI build robot hasn't sent out warning email so far.

I'm not sure whether my test step is correct.
I find for ARM, it force to enable the CONFIG_PM. to test your patch, I force remove all the PM related configs in .config. then meet this warning. And also many other driver build warning. Seems this test method is not correct, can anyone confirm here?

I did another test today, I enable the COMPILE_TEST, and use x86, chose the usdhc in menuconfig, disable CONFIG_PM, and build kernel by the following command, do not meet any warning:
make ARCH=x86 CC=gcc -j64
Seems this means !PM + !PM_SLEEP verify ok.

What's your method to test these PM related combination?

Regards
Haibo chen

Quoted 86 lines

Thanks

Quoted 60 lines

So can you plz kindly show your toolchain? I will check

Thanks

Quoted 56 lines

Regards
Haibo Chen

Quoted 53 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -0
index a040c0896a7b..a7a5df673b0f 100644
@@ -1650,7 +1650,6 @@ static void sdhci_esdhc_imx_hwinit(struct

sdhci_host
*host)

drivers/mmc/host/sdhci-esdhc-imx.c +4 -3
 	}
 }
 
-#ifdef CONFIG_PM_SLEEP
 static void sdhc_esdhc_tuning_save(struct sdhci_host *host)  {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@
-1707,7
+1706,6 @@ static void sdhc_esdhc_tuning_restore(struct sdhci_host
+*host)
 		       host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
 	}
 }
-#endif
 
 static void esdhc_cqe_enable(struct mmc_host *mmc)  { @@ -2016,7
+2014,6 @@ static void sdhci_esdhc_imx_remove(struct
+platform_device

*pdev)

drivers/mmc/host/sdhci-esdhc-imx.c +2 -4
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_esdhc_suspend(struct device *dev)  {
 	struct sdhci_host *host = dev_get_drvdata(dev); @@ -2112,9
+2109,7 @@ static int sdhci_esdhc_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int sdhci_esdhc_runtime_suspend(struct device *dev)  {
 	struct sdhci_host *host = dev_get_drvdata(dev); @@ -2188,12
+2183,10 @@ static int sdhci_esdhc_runtime_resume(struct device *dev)
 		cpu_latency_qos_remove_request(&imx_data->pm_qos_req);
 	return err;
 }
-#endif
Quoted 2 lines
Quoted 2 lines

drivers/mmc/host/sdhci-esdhc-imx.c

Quoted 2 lines

static const struct dev_pm_ops sdhci_esdhc_pmops = {

drivers/mmc/host/sdhci-esdhc-imx.c +0 -1
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend,

sdhci_esdhc_resume)

Quoted 9 lines
Quoted 9 lines

drivers/mmc/host/sdhci-esdhc-imx.c static int sdhci_esdhc_runtime_resume(struct device *dev)

Quoted 9 lines
drivers/mmc/host/sdhci-esdhc-imx.c +3 -3
-	SET_RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
-				sdhci_esdhc_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
+	RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
+sdhci_esdhc_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_esdhc_imx_driver = { @@
-2201,7 +2194,7 @@ static struct platform_driver sdhci_esdhc_imx_driver

= {

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1 -2
 		.name	= "sdhci-esdhc-imx",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = imx_esdhc_dt_ids,
-		.pm	= &sdhci_esdhc_pmops,
+		.pm	= pm_ptr(&sdhci_esdhc_pmops),
 	},
 	.probe		= sdhci_esdhc_imx_probe,
 	.remove		= sdhci_esdhc_imx_remove,
--

2.50.0

#27 lore raw

Re: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 111 lines · Bough Chen
Quoted 111 lines

-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: 2025年8月18日 20:15
To: Bough Chen <[email protected]>
Cc: Ulf Hansson <[email protected]>; Aubin Constans <[email protected]>; Nicolas Ferre <[email protected]>; Alexandre Belloni <[email protected]>; Claudiu Beznea <[email protected]>; Manuel Lauss <[email protected]>; Micha�� Miros��aw <[email protected]>; Jaehoon Chung <[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>; Heiko Stuebner <[email protected]>; Russell King <[email protected]>; Chaotian Jing <[email protected]>; Matthias Brugger <[email protected]>; AngeloGioacchino Del Regno <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Adrian Hunter <[email protected]>; Kamal Dasu <[email protected]>; Al Cooper <[email protected]>; Broadcom internal kernel review list <[email protected]>; Florian Fainelli <[email protected]>; Michal Simek <[email protected]>; Eugen Hristev <[email protected]>; Vignesh Raghavendra <[email protected]>; Ben Dooks <[email protected]>; Viresh Kumar <[email protected]>; Orson Zhai <[email protected]>; Baolin Wang <[email protected]>; Chunyan Zhang <[email protected]>; Patrice Chotard <[email protected]>; Thierry Reding <[email protected]>; Jonathan Hunter <[email protected]>; Chen-Yu Tsai <[email protected]>; Jernej Skrabec <[email protected]>; Samuel Holland <[email protected]>; Alexey Charkov <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 42 lines · Jisheng Zhang
Quoted 41 lines · Bough Chen
Quoted 41 lines

-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: 2025Ҵ8??15?? 9:34
To: Ulf Hansson <[email protected]>; Aubin Constans <[email protected]>; Nicolas Ferre <[email protected]>; Alexandre Belloni <[email protected]>; Claudiu Beznea <[email protected]>; Manuel Lauss <[email protected]>; Micha?? Miros??aw <[email protected]>; Jaehoon Chung <[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>; Heiko Stuebner <[email protected]>; Russell King <[email protected]>; Chaotian Jing <[email protected]>; Matthias Brugger <[email protected]>; AngeloGioacchino Del Regno <[email protected]>;
Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Adrian Hunter <[email protected]>; Kamal Dasu <[email protected]>; Al Cooper <[email protected]>; Broadcom internal kernel review list <[email protected]>; Florian Fainelli <[email protected]>; Bough Chen <[email protected]>; Michal Simek <[email protected]>; Eugen Hristev <[email protected]>; Vignesh Raghavendra <[email protected]>; Ben Dooks <[email protected]>; Viresh Kumar <[email protected]>; Orson Zhai <[email protected]>; Baolin Wang <[email protected]>; Chunyan Zhang <[email protected]>; Patrice Chotard <[email protected]>; Thierry Reding <[email protected]>; Jonathan Hunter <[email protected]>; Chen-Yu Tsai <[email protected]>; Jernej Skrabec <[email protected]>; Samuel Holland <[email protected]>; Alexey Charkov <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

Hi Jisheng,

Hi,

Quoted 2 lines

When I remove all the configs under Power management options I got the

following build warning:

Quoted 11 lines
Quoted 10 lines

drivers/mmc/host/sdhci-esdhc-imx.c:2079:12: warning:
??sdhci_esdhc_resume?? defined but not used [-Wunused-function]
2079 | static int sdhci_esdhc_resume(struct device *dev)

      |            ^~~~~~~~~~~~~~~~~~

CC drivers/mmc/host/cqhci-core.o
drivers/mmc/host/sdhci-esdhc-imx.c:2017:12: warning:
??sdhci_esdhc_suspend?? defined but not used [-Wunused-function]
2017 | static int sdhci_esdhc_suspend(struct device *dev)

      |            ^~~~~~~~~~~~~~~~~~~
Quoted 7 lines

Hmm interesting, what's test toolchain? I tested this patch with gcc14 with below three combinations before sending out, no warnings at all:
PM + PM_SLEEP
PM only
!PM + ! PM_SLEEP

The sdhci_esdhc_suspend|resume are referenced by

SYSTEM_SLEEP_PM_OPS.

Quoted 2 lines

The pm_sleep_ptr() macro does the tricky, when both PM and PM_SLEEP are disabled, they are optimized out.

Hi Haibo,

Quoted 8 lines
Quoted 5 lines

Could you plz share your toolchain information? And FYI, today I tested clang with the above three combinations, also no warnings. So I'm really interested how to reproduce your warnings.

And the kernel CI build robot hasn't sent out warning email so far.

I'm not sure whether my test step is correct.
I find for ARM, it force to enable the CONFIG_PM. to test your patch, I force remove all the PM related configs in .config. then meet this warning. And also many other driver build warning.

Now, I tried arm multi_v7_defconfig, then unselect those platforms which enable CONFIG_PM, then enable COMPILE_TEST, then unselect CONFIG_PM and CONFIG_PM_SLEEP, and build with arm-linux-gnueabihf-gcc-14, stil no any warning.
So can you plz share your defconfig? you can save it by 'make savedefconfig' And I asked twice about your toolchain information, can you plz provide it?

Quoted 5 lines

Seems this test method is not correct, can anyone confirm here?

I did another test today, I enable the COMPILE_TEST, and use x86, chose the usdhc in menuconfig, disable CONFIG_PM, and build kernel by the following command, do not meet any warning:
make ARCH=x86 CC=gcc -j64
Seems this means !PM + !PM_SLEEP verify ok.

I tested not only x86, but also arm64 and riscv...

Quoted 2 lines

What's your method to test these PM related combination?

Similar as yours -- enable COMPILE_TEST.
Sure for the drivers I used: sdhci-of-dwcmshc, sdhci-pxav3 and sdhci-xenon, I tested them.

B.R

maintainer Reviewed-by
#28 lore raw

RE: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 166 lines

-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: 2025年8月19日 19:59
To: Bough Chen <[email protected]>
Cc: Ulf Hansson <[email protected]>; Aubin Constans <[email protected]>; Nicolas Ferre <[email protected]>; Alexandre Belloni <[email protected]>; Claudiu Beznea <[email protected]>; Manuel Lauss <[email protected]>; Micha�� Miros��aw <[email protected]>; Jaehoon Chung <[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>; Heiko Stuebner <[email protected]>; Russell King <[email protected]>; Chaotian Jing <[email protected]>; Matthias Brugger <[email protected]>; AngeloGioacchino Del Regno <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Adrian Hunter <[email protected]>; Kamal Dasu <[email protected]>; Al Cooper <[email protected]>; Broadcom internal kernel review list <[email protected]>; Florian Fainelli <[email protected]>; Michal Simek <[email protected]>; Eugen Hristev <[email protected]>; Vignesh Raghavendra <[email protected]>; Ben Dooks <[email protected]>; Viresh Kumar <[email protected]>; Orson Zhai <[email protected]>; Baolin Wang <[email protected]>; Chunyan Zhang <[email protected]>; Patrice Chotard <[email protected]>; Thierry Reding <[email protected]>; Jonathan Hunter <[email protected]>; Chen-Yu Tsai <[email protected]>; Jernej Skrabec <[email protected]>; Samuel Holland <[email protected]>; Alexey Charkov <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 13 lines · Bough Chen
Quoted 13 lines

-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: 2025年8月18日 20:15
To: Bough Chen <[email protected]>
Cc: Ulf Hansson <[email protected]>; Aubin Constans <[email protected]>; Nicolas Ferre <[email protected]>; Alexandre Belloni <[email protected]>; Claudiu Beznea <[email protected]>; Manuel Lauss <[email protected]>;
Micha Miros aw <[email protected]>; Jaehoon Chung
<[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>; Heiko Stuebner <[email protected]>; Russell King <[email protected]>; Chaotian

Quoted 8 lines
Quoted 8 lines

Jing <[email protected]>; Matthias Brugger <[email protected]>; AngeloGioacchino Del Regno <[email protected]>;
Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Adrian Hunter <[email protected]>; Kamal Dasu <[email protected]>; Al Cooper <[email protected]>;

Broadcom

Quoted 85 lines
Quoted 85 lines

internal kernel review list <[email protected]>; Florian Fainelli <[email protected]>; Michal Simek <[email protected]>; Eugen Hristev <[email protected]>; Vignesh Raghavendra <[email protected]>; Ben Dooks <[email protected]>; Viresh Kumar <[email protected]>; Orson Zhai <[email protected]>; Baolin Wang <[email protected]>; Chunyan Zhang <[email protected]>; Patrice Chotard <[email protected]>; Thierry Reding <[email protected]>; Jonathan Hunter <[email protected]>; Chen-Yu Tsai <[email protected]>; Jernej Skrabec <[email protected]>; Samuel Holland <[email protected]>; Alexey Charkov <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Quoted 45 lines · Jisheng Zhang
Quoted 44 lines · Bough Chen
Quoted 44 lines

-----Original Message-----
From: Jisheng Zhang <[email protected]>
Sent: 2025Ҵ8??15?? 9:34
To: Ulf Hansson <[email protected]>; Aubin Constans <[email protected]>; Nicolas Ferre <[email protected]>; Alexandre Belloni <[email protected]>; Claudiu Beznea <[email protected]>; Manuel Lauss <[email protected]>; Micha?? Miros??aw <[email protected]>; Jaehoon Chung <[email protected]>; Krzysztof Kozlowski <[email protected]>; Alim Akhtar <[email protected]>; Heiko Stuebner <[email protected]>; Russell King <[email protected]>; Chaotian Jing <[email protected]>; Matthias Brugger <[email protected]>; AngeloGioacchino Del Regno <[email protected]>;
Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Adrian Hunter <[email protected]>; Kamal Dasu <[email protected]>; Al Cooper <[email protected]>; Broadcom internal kernel review list <[email protected]>; Florian Fainelli <[email protected]>; Bough Chen <[email protected]>; Michal Simek <[email protected]>; Eugen Hristev <[email protected]>; Vignesh Raghavendra <[email protected]>; Ben Dooks <[email protected]>; Viresh Kumar <[email protected]>; Orson Zhai <[email protected]>; Baolin Wang <[email protected]>; Chunyan Zhang <[email protected]>; Patrice Chotard <[email protected]>; Thierry Reding <[email protected]>; Jonathan Hunter <[email protected]>; Chen-Yu Tsai <[email protected]>; Jernej Skrabec <[email protected]>; Samuel Holland <[email protected]>; Alexey Charkov <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH 18/38] mmc: sdhci-esdhc-imx: use modern PM macros

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

Quoted 11 lines
Quoted 5 lines
Quoted 3 lines

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

Hi Jisheng,

Hi,

Quoted 3 lines

When I remove all the configs under Power management options I got the

following build warning:

Quoted 11 lines
Quoted 10 lines

drivers/mmc/host/sdhci-esdhc-imx.c:2079:12: warning:
??sdhci_esdhc_resume?? defined but not used [-Wunused-function]
2079 | static int sdhci_esdhc_resume(struct device *dev)

      |            ^~~~~~~~~~~~~~~~~~

CC drivers/mmc/host/cqhci-core.o
drivers/mmc/host/sdhci-esdhc-imx.c:2017:12: warning:
??sdhci_esdhc_suspend?? defined but not used [-Wunused-function]
2017 | static int sdhci_esdhc_suspend(struct device *dev)

      |            ^~~~~~~~~~~~~~~~~~~
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Hmm interesting, what's test toolchain? I tested this patch with gcc14 with below three combinations before sending out, no warnings at

all:

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

PM + PM_SLEEP
PM only
!PM + ! PM_SLEEP

The sdhci_esdhc_suspend|resume are referenced by

SYSTEM_SLEEP_PM_OPS.

Quoted 2 lines

The pm_sleep_ptr() macro does the tricky, when both PM and PM_SLEEP are disabled, they are optimized out.

Hi Haibo,

Quoted 8 lines
Quoted 5 lines

Could you plz share your toolchain information? And FYI, today I tested clang with the above three combinations, also no warnings. So I'm really interested how to reproduce your warnings.

And the kernel CI build robot hasn't sent out warning email so far.

I'm not sure whether my test step is correct.
I find for ARM, it force to enable the CONFIG_PM. to test your patch, I force

remove all the PM related configs in .config. then meet this warning. And also many other driver build warning.

Quoted 7 lines

Now, I tried arm multi_v7_defconfig, then unselect those platforms which enable CONFIG_PM, then enable COMPILE_TEST, then unselect CONFIG_PM and CONFIG_PM_SLEEP, and build with arm-linux-gnueabihf-gcc-14, stil no any warning.
So can you plz share your defconfig? you can save it by 'make savedefconfig' And I asked twice about your toolchain information, can you plz provide it?

Please ignore my first reply, the test method is wrong. The toolchain is : aarch64-poky-linux-gcc-13.2.0 I just use the default defconfig in arch/arm64/config.

For this patch:

Regards
Haibo Chen

Quoted 18 lines
Quoted 3 lines

Seems this test method is not correct, can anyone confirm here?

I did another test today, I enable the COMPILE_TEST, and use x86, chose the

usdhc in menuconfig, disable CONFIG_PM, and build kernel by the following command, do not meet any warning:

Quoted 2 lines

make ARCH=x86 CC=gcc -j64
Seems this means !PM + !PM_SLEEP verify ok.

I tested not only x86, but also arm64 and riscv...

Quoted 2 lines

What's your method to test these PM related combination?

Similar as yours -- enable COMPILE_TEST.
Sure for the drivers I used: sdhci-of-dwcmshc, sdhci-pxav3 and sdhci-xenon, I tested them.

B.R

#29 lore raw

PATCH 19/38 mmc: sdhci-of-arasan: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-of-arasan.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/mmc/host/sdhci-of-arasan.c +3 -5
index 42878474e56e..d0939b5bc1a6 100644
@@ -581,7 +581,6 @@ static const struct sdhci_pltfm_data sdhci_arasan_cqe_pdata = {
 			SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN,
 };
 
-#ifdef CONFIG_PM_SLEEP
 /**
  * sdhci_arasan_suspend - Suspend method for the driver
  * @dev:	Address of the device structure
@@ -675,10 +674,9 @@ static int sdhci_arasan_resume(struct device *dev)
 
 	return 0;
 }
-#endif /* ! CONFIG_PM_SLEEP */
 
-static SIMPLE_DEV_PM_OPS(sdhci_arasan_dev_pm_ops, sdhci_arasan_suspend,
-			 sdhci_arasan_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_arasan_dev_pm_ops, sdhci_arasan_suspend,
+				sdhci_arasan_resume);
 
 /**
  * sdhci_arasan_sdcardclk_recalc_rate - Return the card clock rate
@@ -2051,7 +2049,7 @@ static struct platform_driver sdhci_arasan_driver = {
 		.name = "sdhci-arasan",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = sdhci_arasan_of_match,
-		.pm = &sdhci_arasan_dev_pm_ops,
+		.pm = pm_sleep_ptr(&sdhci_arasan_dev_pm_ops),
 	},
 	.probe = sdhci_arasan_probe,
 	.remove = sdhci_arasan_remove,
Signature · 1 line
2.50.0
#30 lore raw

PATCH 20/38 mmc: sdhci-of-at91: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-of-at91.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/mmc/host/sdhci-of-at91.c +3 -9
index 1ba2effaf376..7c4ac65f247d 100644
@@ -229,7 +229,6 @@ static int sdhci_at91_set_clks_presets(struct device *dev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_at91_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -243,9 +242,7 @@ static int sdhci_at91_suspend(struct device *dev)
 
 	return ret;
 }
-#endif /* CONFIG_PM_SLEEP */
 
-#ifdef CONFIG_PM
 static int sdhci_at91_runtime_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -302,13 +299,10 @@ static int sdhci_at91_runtime_resume(struct device *dev)
 	sdhci_runtime_resume_host(host, 0);
 	return 0;
 }
-#endif /* CONFIG_PM */
 
 static const struct dev_pm_ops sdhci_at91_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_at91_suspend, pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(sdhci_at91_runtime_suspend,
-			   sdhci_at91_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_at91_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(sdhci_at91_runtime_suspend, sdhci_at91_runtime_resume, NULL)
 };
 
 static int sdhci_at91_probe(struct platform_device *pdev)
@@ -460,7 +454,7 @@ static struct platform_driver sdhci_at91_driver = {
 		.name	= "sdhci-at91",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = sdhci_at91_dt_match,
-		.pm	= &sdhci_at91_dev_pm_ops,
+		.pm	= pm_ptr(&sdhci_at91_dev_pm_ops),
 	},
 	.probe		= sdhci_at91_probe,
 	.remove		= sdhci_at91_remove,
Signature · 1 line
2.50.0
#31 lore raw

PATCH 21/38 mmc: sdhci-of-esdhc: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-of-esdhc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-of-esdhc.c +2 -6
index c6ee0099ead0..8345e2c5a034 100644
@@ -1234,7 +1234,6 @@ static u32 esdhc_irq(struct sdhci_host *host, u32 intmask)
 	return intmask;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static u32 esdhc_proctl;
 static int esdhc_of_suspend(struct device *dev)
 {
@@ -1260,11 +1259,8 @@ static int esdhc_of_resume(struct device *dev)
 	}
 	return ret;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(esdhc_of_dev_pm_ops,
-			esdhc_of_suspend,
-			esdhc_of_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(esdhc_of_dev_pm_ops, esdhc_of_suspend, esdhc_of_resume);
 
 static const struct sdhci_ops sdhci_esdhc_be_ops = {
 	.read_l = esdhc_be_readl,
@@ -1511,7 +1507,7 @@ static struct platform_driver sdhci_esdhc_driver = {
 		.name = "sdhci-esdhc",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = sdhci_esdhc_of_match,
-		.pm = &esdhc_of_dev_pm_ops,
+		.pm = pm_sleep_ptr(&esdhc_of_dev_pm_ops),
 	},
 	.probe = sdhci_esdhc_probe,
 	.remove = sdhci_pltfm_remove,
Signature · 1 line
2.50.0
#32 lore raw

PATCH 22/38 mmc: sdhci-omap: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-omap.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/mmc/host/sdhci-omap.c +7 -11
index cdb09605e009..b5d7c1a80a92 100644
@@ -1400,8 +1400,7 @@ static void sdhci_omap_remove(struct platform_device *pdev)
 	pm_runtime_force_suspend(dev);
 }
 
-#ifdef CONFIG_PM
-static void __maybe_unused sdhci_omap_context_save(struct sdhci_omap_host *omap_host)
+static void sdhci_omap_context_save(struct sdhci_omap_host *omap_host)
 {
 	omap_host->con = sdhci_omap_readl(omap_host, SDHCI_OMAP_CON);
 	omap_host->hctl = sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL);
@@ -1412,7 +1411,7 @@ static void __maybe_unused sdhci_omap_context_save(struct sdhci_omap_host *omap_
 }
 
 /* Order matters here, HCTL must be restored in two phases */
-static void __maybe_unused sdhci_omap_context_restore(struct sdhci_omap_host *omap_host)
+static void sdhci_omap_context_restore(struct sdhci_omap_host *omap_host)
 {
 	sdhci_omap_writel(omap_host, SDHCI_OMAP_HCTL, omap_host->hctl);
 	sdhci_omap_writel(omap_host, SDHCI_OMAP_CAPA, omap_host->capa);
@@ -1424,7 +1423,7 @@ static void __maybe_unused sdhci_omap_context_restore(struct sdhci_omap_host *om
 	sdhci_omap_writel(omap_host, SDHCI_OMAP_ISE, omap_host->ise);
 }
 
-static int __maybe_unused sdhci_omap_runtime_suspend(struct device *dev)
+static int sdhci_omap_runtime_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -1443,7 +1442,7 @@ static int __maybe_unused sdhci_omap_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused sdhci_omap_runtime_resume(struct device *dev)
+static int sdhci_omap_runtime_resume(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -1458,13 +1457,10 @@ static int __maybe_unused sdhci_omap_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops sdhci_omap_dev_pm_ops = {
-	SET_RUNTIME_PM_OPS(sdhci_omap_runtime_suspend,
-			   sdhci_omap_runtime_resume, NULL)
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
+	RUNTIME_PM_OPS(sdhci_omap_runtime_suspend, sdhci_omap_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
 };
 
 static struct platform_driver sdhci_omap_driver = {
@@ -1473,7 +1469,7 @@ static struct platform_driver sdhci_omap_driver = {
 	.driver = {
 		   .name = "sdhci-omap",
 		   .probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		   .pm = &sdhci_omap_dev_pm_ops,
+		   .pm = pm_ptr(&sdhci_omap_dev_pm_ops),
 		   .of_match_table = omap_sdhci_match,
 		  },
 };
Signature · 1 line
2.50.0
#33 lore raw

PATCH 23/38 mmc: sdhci-cadence: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-cadence.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-cadence.c +2 -6
index 2d823e158c59..60a297628b06 100644
@@ -551,7 +551,6 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
 	return sdhci_add_host(host);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_cdns_resume(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -578,11 +577,8 @@ static int sdhci_cdns_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops sdhci_cdns_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_pltfm_suspend, sdhci_cdns_resume)
-};
+static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_cdns_pm_ops, sdhci_pltfm_suspend, sdhci_cdns_resume);
 
 static const struct of_device_id sdhci_cdns_match[] = {
 	{
@@ -606,7 +602,7 @@ static struct platform_driver sdhci_cdns_driver = {
 	.driver = {
 		.name = "sdhci-cdns",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm = &sdhci_cdns_pm_ops,
+		.pm = pm_sleep_ptr(&sdhci_cdns_pm_ops),
 		.of_match_table = sdhci_cdns_match,
 	},
 	.probe = sdhci_cdns_probe,
Signature · 1 line
2.50.0
#34 lore raw

PATCH 24/38 mmc: sdhci-s3c: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-s3c.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/mmc/host/sdhci-s3c.c +3 -8
index 40857fc2e21b..6bf66aaa86a6 100644
@@ -681,7 +681,6 @@ static void sdhci_s3c_remove(struct platform_device *pdev)
 	clk_disable_unprepare(sc->clk_io);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_s3c_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -698,9 +697,7 @@ static int sdhci_s3c_resume(struct device *dev)
 
 	return sdhci_resume_host(host);
 }
-#endif
 
-#ifdef CONFIG_PM
 static int sdhci_s3c_runtime_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -730,12 +727,10 @@ static int sdhci_s3c_runtime_resume(struct device *dev)
 	sdhci_runtime_resume_host(host, 0);
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops sdhci_s3c_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
-	SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
+	RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume, NULL)
 };
 
 static const struct platform_device_id sdhci_s3c_driver_ids[] = {
@@ -770,7 +765,7 @@ static struct platform_driver sdhci_s3c_driver = {
 		.name	= "s3c-sdhci",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = of_match_ptr(sdhci_s3c_dt_match),
-		.pm	= &sdhci_s3c_pmops,
+		.pm	= pm_ptr(&sdhci_s3c_pmops),
 	},
 };
 
Signature · 1 line
2.50.0
#35 lore raw

PATCH 25/38 mmc: sdhci-spear: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-spear.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-spear.c +2 -4
index fa0f8aeb7ee0..72d21dc0cb69 100644
@@ -130,7 +130,6 @@ static void sdhci_remove(struct platform_device *pdev)
 	clk_disable_unprepare(sdhci->clk);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -161,9 +160,8 @@ static int sdhci_resume(struct device *dev)
 
 	return sdhci_resume_host(host);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(sdhci_pm_ops, sdhci_suspend, sdhci_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_pm_ops, sdhci_suspend, sdhci_resume);
 
 static const struct of_device_id sdhci_spear_id_table[] = {
 	{ .compatible = "st,spear300-sdhci" },
@@ -175,7 +173,7 @@ static struct platform_driver sdhci_driver = {
 	.driver = {
 		.name	= "sdhci",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm	= &sdhci_pm_ops,
+		.pm	= pm_sleep_ptr(&sdhci_pm_ops),
 		.of_match_table = sdhci_spear_id_table,
 	},
 	.probe		= sdhci_probe,
Signature · 1 line
2.50.0
Acked-by on v1 25/38
#36 lore raw

Re: [PATCH 25/38] mmc: sdhci-spear: use modern PM macros

Quoted 4 lines · Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

Quoted 8 lines

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-spear.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
viresh
#37 lore raw

PATCH 26/38 mmc: sdhci-sprd: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-sprd.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci-sprd.c +3 -7
index fe2fe52b23b2..3584a2b314a9 100644
@@ -903,7 +903,6 @@ static const struct of_device_id sdhci_sprd_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, sdhci_sprd_of_match);
 
-#ifdef CONFIG_PM
 static int sdhci_sprd_runtime_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -950,13 +949,10 @@ static int sdhci_sprd_runtime_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
 static const struct dev_pm_ops sdhci_sprd_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(sdhci_sprd_runtime_suspend,
-			   sdhci_sprd_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(sdhci_sprd_runtime_suspend, sdhci_sprd_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_sprd_driver = {
@@ -966,7 +962,7 @@ static struct platform_driver sdhci_sprd_driver = {
 		.name = "sdhci_sprd_r11",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = sdhci_sprd_of_match,
-		.pm = &sdhci_sprd_pm_ops,
+		.pm = pm_ptr(&sdhci_sprd_pm_ops),
 	},
 };
 module_platform_driver(sdhci_sprd_driver);
Signature · 1 line
2.50.0
#38 lore raw

PATCH 27/38 mmc: sdhci-st: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-st.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mmc/host/sdhci-st.c +2 -4
index 9157342ff7a4..bf6685805137 100644
@@ -445,7 +445,6 @@ static void sdhci_st_remove(struct platform_device *pdev)
 	reset_control_assert(rstc);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_st_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -492,9 +491,8 @@ static int sdhci_st_resume(struct device *dev)
 
 	return sdhci_resume_host(host);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(sdhci_st_pmops, sdhci_st_suspend, sdhci_st_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_st_pmops, sdhci_st_suspend, sdhci_st_resume);
 
 static const struct of_device_id st_sdhci_match[] = {
 	{ .compatible = "st,sdhci" },
@@ -509,7 +507,7 @@ static struct platform_driver sdhci_st_driver = {
 	.driver = {
 		   .name = "sdhci-st",
 		   .probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		   .pm = &sdhci_st_pmops,
+		   .pm = pm_sleep_ptr(&sdhci_st_pmops),
 		   .of_match_table = st_sdhci_match,
 		  },
 };
Signature · 1 line
2.50.0
maintainer Reviewed-by on v1 27/38
#39 lore raw

Re: [PATCH 27/38] mmc: sdhci-st: use modern PM macros

Quoted 4 lines · Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

Quoted 8 lines

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-st.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Thanks
Patrice

Quoted 33 lines
drivers/mmc/host/sdhci-st.c +2 -4
index 9157342ff7a4..bf6685805137 100644
@@ -445,7 +445,6 @@ static void sdhci_st_remove(struct platform_device *pdev)
 	reset_control_assert(rstc);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_st_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -492,9 +491,8 @@ static int sdhci_st_resume(struct device *dev)
 
 	return sdhci_resume_host(host);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(sdhci_st_pmops, sdhci_st_suspend, sdhci_st_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(sdhci_st_pmops, sdhci_st_suspend, sdhci_st_resume);
 
 static const struct of_device_id st_sdhci_match[] = {
 	{ .compatible = "st,sdhci" },
@@ -509,7 +507,7 @@ static struct platform_driver sdhci_st_driver = {
 	.driver = {
 		   .name = "sdhci-st",
 		   .probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		   .pm = &sdhci_st_pmops,
+		   .pm = pm_sleep_ptr(&sdhci_st_pmops),
 		   .of_match_table = st_sdhci_match,
 		  },
 };
#40 lore raw

PATCH 28/38 mmc: sdhci-tegra: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sdhci-tegra.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/mmc/host/sdhci-tegra.c +5 -8
index c811297185d8..820ce4dae58b 100644
@@ -1831,7 +1831,7 @@ static void sdhci_tegra_remove(struct platform_device *pdev)
 	clk_disable_unprepare(tegra_host->tmclk);
 }
 
-static int __maybe_unused sdhci_tegra_runtime_suspend(struct device *dev)
+static int sdhci_tegra_runtime_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -1841,7 +1841,7 @@ static int __maybe_unused sdhci_tegra_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused sdhci_tegra_runtime_resume(struct device *dev)
+static int sdhci_tegra_runtime_resume(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -1849,7 +1849,6 @@ static int __maybe_unused sdhci_tegra_runtime_resume(struct device *dev)
 	return clk_prepare_enable(pltfm_host->clk);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_tegra_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -1910,12 +1909,10 @@ static int sdhci_tegra_resume(struct device *dev)
 	pm_runtime_force_suspend(dev);
 	return ret;
 }
-#endif
 
 static const struct dev_pm_ops sdhci_tegra_dev_pm_ops = {
-	SET_RUNTIME_PM_OPS(sdhci_tegra_runtime_suspend, sdhci_tegra_runtime_resume,
-			   NULL)
-	SET_SYSTEM_SLEEP_PM_OPS(sdhci_tegra_suspend, sdhci_tegra_resume)
+	RUNTIME_PM_OPS(sdhci_tegra_runtime_suspend, sdhci_tegra_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(sdhci_tegra_suspend, sdhci_tegra_resume)
 };
 
 static struct platform_driver sdhci_tegra_driver = {
@@ -1923,7 +1920,7 @@ static struct platform_driver sdhci_tegra_driver = {
 		.name	= "sdhci-tegra",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = sdhci_tegra_dt_match,
-		.pm	= &sdhci_tegra_dev_pm_ops,
+		.pm	= pm_ptr(&sdhci_tegra_dev_pm_ops),
 	},
 	.probe		= sdhci_tegra_probe,
 	.remove		= sdhci_tegra_remove,
Signature · 1 line
2.50.0
#41 lore raw

PATCH 29/38 mmc: sh_mmicf: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/sh_mmcif.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/mmc/host/sh_mmcif.c +2 -6
index 19f84584ecfa..413c34585c90 100644
@@ -1568,7 +1568,6 @@ static void sh_mmcif_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sh_mmcif_suspend(struct device *dev)
 {
 	struct sh_mmcif_host *host = dev_get_drvdata(dev);
@@ -1584,11 +1583,8 @@ static int sh_mmcif_resume(struct device *dev)
 {
 	return 0;
 }
-#endif
 
-static const struct dev_pm_ops sh_mmcif_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sh_mmcif_suspend, sh_mmcif_resume)
-};
+static DEFINE_SIMPLE_DEV_PM_OPS(sh_mmcif_dev_pm_ops, sh_mmcif_suspend, sh_mmcif_resume);
 
 static struct platform_driver sh_mmcif_driver = {
 	.probe		= sh_mmcif_probe,
@@ -1596,7 +1592,7 @@ static struct platform_driver sh_mmcif_driver = {
 	.driver		= {
 		.name	= DRIVER_NAME,
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm	= &sh_mmcif_dev_pm_ops,
+		.pm	= pm_sleep_ptr(&sh_mmcif_dev_pm_ops),
 		.of_match_table = sh_mmcif_of_match,
 	},
 };
Signature · 1 line
2.50.0
#42 lore raw

PATCH 30/38 mmc: toshsd: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/toshsd.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/mmc/host/toshsd.c +2 -6
index e5f7f8abafc0..aa5d2511a62b 100644
@@ -567,7 +567,6 @@ static void toshsd_powerdown(struct toshsd_host *host)
 	pci_write_config_byte(host->pdev, SD_PCICFG_CLKSTOP, 0);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int toshsd_pm_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
@@ -599,7 +598,6 @@ static int toshsd_pm_resume(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM_SLEEP */
 
 static int toshsd_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
@@ -688,16 +686,14 @@ static void toshsd_remove(struct pci_dev *pdev)
 	pci_disable_device(pdev);
 }
 
-static const struct dev_pm_ops toshsd_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(toshsd_pm_suspend, toshsd_pm_resume)
-};
+static DEFINE_SIMPLE_DEV_PM_OPS(toshsd_pm_ops, toshsd_pm_suspend, toshsd_pm_resume);
 
 static struct pci_driver toshsd_driver = {
 	.name = DRIVER_NAME,
 	.id_table = pci_ids,
 	.probe = toshsd_probe,
 	.remove = toshsd_remove,
-	.driver.pm = &toshsd_pm_ops,
+	.driver.pm = pm_sleep_ptr(&toshsd_pm_ops),
 };
 
 module_pci_driver(toshsd_driver);
Signature · 1 line
2.50.0
#43 lore raw

PATCH 31/38 mmc: wmt-sdmmc: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/wmt-sdmmc.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/mmc/host/wmt-sdmmc.c +2 -14
index 0d2929cfe397..1b1d691e19fc 100644
@@ -911,7 +911,6 @@ static void wmt_mci_remove(struct platform_device *pdev)
 	dev_info(&pdev->dev, "WMT MCI device removed\n");
 }
 
-#ifdef CONFIG_PM
 static int wmt_mci_suspend(struct device *dev)
 {
 	u32 reg_tmp;
@@ -963,18 +962,7 @@ static int wmt_mci_resume(struct device *dev)
 	return 0;
 }
 
-static const struct dev_pm_ops wmt_mci_pm = {
-	.suspend        = wmt_mci_suspend,
-	.resume         = wmt_mci_resume,
-};
-
-#define wmt_mci_pm_ops (&wmt_mci_pm)
-
-#else	/* !CONFIG_PM */
-
-#define wmt_mci_pm_ops NULL
-
-#endif
+static DEFINE_SIMPLE_DEV_PM_OPS(wmt_mci_pm_ops, wmt_mci_suspend, wmt_mci_resume);
 
 static struct platform_driver wmt_mci_driver = {
 	.probe = wmt_mci_probe,
@@ -982,7 +970,7 @@ static struct platform_driver wmt_mci_driver = {
 	.driver = {
 		.name = DRIVER_NAME,
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
-		.pm = wmt_mci_pm_ops,
+		.pm = pm_sleep_ptr(&wmt_mci_pm_ops),
 		.of_match_table = wmt_mci_dt_ids,
 	},
 };
Signature · 1 line
2.50.0
#44 lore raw

PATCH 32/38 mmc: mtk-sd: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use __maybe_unused.

---
 drivers/mmc/host/mtk-sd.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/mmc/host/mtk-sd.c +7 -7
index d7020e06dd55..79074291e9d2 100644
@@ -3278,7 +3278,7 @@ static void msdc_restore_reg(struct msdc_host *host)
 		__msdc_enable_sdio_irq(host, 1);
 }
 
-static int __maybe_unused msdc_runtime_suspend(struct device *dev)
+static int msdc_runtime_suspend(struct device *dev)
 {
 	struct mmc_host *mmc = dev_get_drvdata(dev);
 	struct msdc_host *host = mmc_priv(mmc);
@@ -3300,7 +3300,7 @@ static int __maybe_unused msdc_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused msdc_runtime_resume(struct device *dev)
+static int msdc_runtime_resume(struct device *dev)
 {
 	struct mmc_host *mmc = dev_get_drvdata(dev);
 	struct msdc_host *host = mmc_priv(mmc);
@@ -3323,7 +3323,7 @@ static int __maybe_unused msdc_runtime_resume(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused msdc_suspend(struct device *dev)
+static int msdc_suspend(struct device *dev)
 {
 	struct mmc_host *mmc = dev_get_drvdata(dev);
 	struct msdc_host *host = mmc_priv(mmc);
@@ -3348,7 +3348,7 @@ static int __maybe_unused msdc_suspend(struct device *dev)
 	return pm_runtime_force_suspend(dev);
 }
 
-static int __maybe_unused msdc_resume(struct device *dev)
+static int msdc_resume(struct device *dev)
 {
 	struct mmc_host *mmc = dev_get_drvdata(dev);
 	struct msdc_host *host = mmc_priv(mmc);
@@ -3360,8 +3360,8 @@ static int __maybe_unused msdc_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops msdc_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(msdc_suspend, msdc_resume)
-	SET_RUNTIME_PM_OPS(msdc_runtime_suspend, msdc_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(msdc_suspend, msdc_resume)
+	RUNTIME_PM_OPS(msdc_runtime_suspend, msdc_runtime_resume, NULL)
 };
 
 static struct platform_driver mt_msdc_driver = {
@@ -3371,7 +3371,7 @@ static struct platform_driver mt_msdc_driver = {
 		.name = "mtk-msdc",
 		.probe_type = PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table = msdc_of_ids,
-		.pm = &msdc_dev_pm_ops,
+		.pm = pm_ptr(&msdc_dev_pm_ops),
 	},
 };
 
Signature · 1 line
2.50.0
#45 lore raw

PATCH 33/38 mmc: sdhci-msm: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use __maybe_unused.

---
 drivers/mmc/host/sdhci-msm.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/mmc/host/sdhci-msm.c +9 -12
index 9d8e20dc8ca1..d2906bf6e598 100644
@@ -1943,7 +1943,7 @@ static void sdhci_msm_ice_enable(struct sdhci_msm_host *msm_host)
 		qcom_ice_enable(msm_host->ice);
 }
 
-static __maybe_unused int sdhci_msm_ice_resume(struct sdhci_msm_host *msm_host)
+static int sdhci_msm_ice_resume(struct sdhci_msm_host *msm_host)
 {
 	if (msm_host->mmc->caps2 & MMC_CAP2_CRYPTO)
 		return qcom_ice_resume(msm_host->ice);
@@ -1951,7 +1951,7 @@ static __maybe_unused int sdhci_msm_ice_resume(struct sdhci_msm_host *msm_host)
 	return 0;
 }
 
-static __maybe_unused int sdhci_msm_ice_suspend(struct sdhci_msm_host *msm_host)
+static int sdhci_msm_ice_suspend(struct sdhci_msm_host *msm_host)
 {
 	if (msm_host->mmc->caps2 & MMC_CAP2_CRYPTO)
 		return qcom_ice_suspend(msm_host->ice);
@@ -2011,13 +2011,13 @@ static inline void sdhci_msm_ice_enable(struct sdhci_msm_host *msm_host)
 {
 }
 
-static inline __maybe_unused int
+static inline int
 sdhci_msm_ice_resume(struct sdhci_msm_host *msm_host)
 {
 	return 0;
 }
 
-static inline __maybe_unused int
+static inline int
 sdhci_msm_ice_suspend(struct sdhci_msm_host *msm_host)
 {
 	return 0;
@@ -2801,7 +2801,7 @@ static void sdhci_msm_remove(struct platform_device *pdev)
 		clk_disable_unprepare(msm_host->bus_clk);
 }
 
-static __maybe_unused int sdhci_msm_runtime_suspend(struct device *dev)
+static int sdhci_msm_runtime_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -2820,7 +2820,7 @@ static __maybe_unused int sdhci_msm_runtime_suspend(struct device *dev)
 	return sdhci_msm_ice_suspend(msm_host);
 }
 
-static __maybe_unused int sdhci_msm_runtime_resume(struct device *dev)
+static int sdhci_msm_runtime_resume(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -2856,11 +2856,8 @@ static __maybe_unused int sdhci_msm_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops sdhci_msm_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(sdhci_msm_runtime_suspend,
-			   sdhci_msm_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(sdhci_msm_runtime_suspend, sdhci_msm_runtime_resume, NULL)
 };
 
 static struct platform_driver sdhci_msm_driver = {
@@ -2869,7 +2866,7 @@ static struct platform_driver sdhci_msm_driver = {
 	.driver = {
 		   .name = "sdhci_msm",
 		   .of_match_table = sdhci_msm_dt_match,
-		   .pm = &sdhci_msm_pm_ops,
+		   .pm = pm_ptr(&sdhci_msm_pm_ops),
 		   .probe_type = PROBE_PREFER_ASYNCHRONOUS,
 	},
 };
Signature · 1 line
2.50.0
#46 lore raw

PATCH 34/38 mmc: via-sdmmc: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use __maybe_unused.

---
 drivers/mmc/host/via-sdmmc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mmc/host/via-sdmmc.c +5 -5
index 3bd49f64899d..c628b3bbfd7a 100644
@@ -1218,7 +1218,7 @@ static void via_sd_remove(struct pci_dev *pcidev)
 		pci_name(pcidev), (int)pcidev->vendor, (int)pcidev->device);
 }
 
-static void __maybe_unused via_init_sdc_pm(struct via_crdr_mmc_host *host)
+static void via_init_sdc_pm(struct via_crdr_mmc_host *host)
 {
 	struct sdhcreg *pm_sdhcreg;
 	void __iomem *addrbase;
@@ -1252,7 +1252,7 @@ static void __maybe_unused via_init_sdc_pm(struct via_crdr_mmc_host *host)
 	via_print_sdchc(host);
 }
 
-static int __maybe_unused via_sd_suspend(struct device *dev)
+static int via_sd_suspend(struct device *dev)
 {
 	struct via_crdr_mmc_host *host;
 	unsigned long flags;
@@ -1269,7 +1269,7 @@ static int __maybe_unused via_sd_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused via_sd_resume(struct device *dev)
+static int via_sd_resume(struct device *dev)
 {
 	struct via_crdr_mmc_host *sdhost;
 	u8 gatt;
@@ -1295,14 +1295,14 @@ static int __maybe_unused via_sd_resume(struct device *dev)
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(via_sd_pm_ops, via_sd_suspend, via_sd_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(via_sd_pm_ops, via_sd_suspend, via_sd_resume);
 
 static struct pci_driver via_sd_driver = {
 	.name = DRV_NAME,
 	.id_table = via_ids,
 	.probe = via_sd_probe,
 	.remove = via_sd_remove,
-	.driver.pm = &via_sd_pm_ops,
+	.driver.pm = pm_sleep_ptr(&via_sd_pm_ops),
 };
 
 module_pci_driver(via_sd_driver);
Signature · 1 line
2.50.0
#47 lore raw

PATCH 35/38 mmc: dw_mmc: exynos: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/dw_mmc-exynos.c | 13 +++----------
 drivers/mmc/host/dw_mmc.h        |  3 +++
 2 files changed, 6 insertions(+), 10 deletions(-)
drivers/mmc/host/dw_mmc-exynos.c +3 -10
index e3548408ca39..384609671a9a 100644
@@ -189,7 +189,6 @@ static void dw_mci_exynos_set_clksel_timing(struct dw_mci *host, u32 timing)
 		set_bit(DW_MMC_CARD_NO_USE_HOLD, &host->slot->flags);
 }
 
-#ifdef CONFIG_PM
 static int dw_mci_exynos_runtime_resume(struct device *dev)
 {
 	struct dw_mci *host = dev_get_drvdata(dev);
@@ -203,9 +202,7 @@ static int dw_mci_exynos_runtime_resume(struct device *dev)
 
 	return ret;
 }
-#endif /* CONFIG_PM */
 
-#ifdef CONFIG_PM_SLEEP
 /**
  * dw_mci_exynos_suspend_noirq - Exynos-specific suspend code
  * @dev: Device to suspend (this device)
@@ -265,7 +262,6 @@ static int dw_mci_exynos_resume_noirq(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM_SLEEP */
 
 static void dw_mci_exynos_config_hs400(struct dw_mci *host, u32 timing)
 {
@@ -712,11 +708,8 @@ static void dw_mci_exynos_remove(struct platform_device *pdev)
 }
 
 static const struct dev_pm_ops dw_mci_exynos_pmops = {
-	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(dw_mci_exynos_suspend_noirq,
-				      dw_mci_exynos_resume_noirq)
-	SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend,
-			   dw_mci_exynos_runtime_resume,
-			   NULL)
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(dw_mci_exynos_suspend_noirq, dw_mci_exynos_resume_noirq)
+	RUNTIME_PM_OPS(dw_mci_runtime_suspend, dw_mci_exynos_runtime_resume, NULL)
 };
 
 static struct platform_driver dw_mci_exynos_pltfm_driver = {
@@ -726,7 +719,7 @@ static struct platform_driver dw_mci_exynos_pltfm_driver = {
 		.name		= "dwmmc_exynos",
 		.probe_type	= PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table	= dw_mci_exynos_match,
-		.pm		= &dw_mci_exynos_pmops,
+		.pm		= pm_ptr(&dw_mci_exynos_pmops),
 	},
 };
 
drivers/mmc/host/dw_mmc.h +3 -0
index 5463392dc811..588027932412 100644
@@ -541,6 +541,9 @@ extern void dw_mci_remove(struct dw_mci *host);
 #ifdef CONFIG_PM
 extern int dw_mci_runtime_suspend(struct device *device);
 extern int dw_mci_runtime_resume(struct device *device);
+#else
+static inline int dw_mci_runtime_suspend(struct device *device) { return -EOPNOTSUPP; }
+static inline int dw_mci_runtime_resume(struct device *device) { return -EOPNOTSUPP; }
 #endif
 
 /**
Signature · 1 line
2.50.0
#48 lore raw

PATCH 36/38 mmc: dw_mmc-k3: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/dw_mmc-k3.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mmc/host/dw_mmc-k3.c +3 -6
index 0311a37dd4ab..ad6aa1aea549 100644
@@ -461,11 +461,8 @@ static int dw_mci_k3_probe(struct platform_device *pdev)
 }
 
 static const struct dev_pm_ops dw_mci_k3_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend,
-			   dw_mci_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(dw_mci_runtime_suspend, dw_mci_runtime_resume, NULL)
 };
 
 static struct platform_driver dw_mci_k3_pltfm_driver = {
@@ -475,7 +472,7 @@ static struct platform_driver dw_mci_k3_pltfm_driver = {
 		.name		= "dwmmc_k3",
 		.probe_type	= PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table	= dw_mci_k3_match,
-		.pm		= &dw_mci_k3_dev_pm_ops,
+		.pm		= pm_ptr(&dw_mci_k3_dev_pm_ops),
 	},
 };
 
Signature · 1 line
2.50.0
#49 lore raw

PATCH 37/38 mmc: dw_mmc-pci: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/dw_mmc-pci.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mmc/host/dw_mmc-pci.c +3 -6
index e7ab699f488e..092cc99175af 100644
@@ -75,11 +75,8 @@ static void dw_mci_pci_remove(struct pci_dev *pdev)
 }
 
 static const struct dev_pm_ops dw_mci_pci_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend,
-			   dw_mci_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(dw_mci_runtime_suspend, dw_mci_runtime_resume, NULL)
 };
 
 static const struct pci_device_id dw_mci_pci_id[] = {
@@ -94,7 +91,7 @@ static struct pci_driver dw_mci_pci_driver = {
 	.probe		= dw_mci_pci_probe,
 	.remove		= dw_mci_pci_remove,
 	.driver		=	{
-		.pm =   &dw_mci_pci_dev_pm_ops,
+		.pm =   pm_ptr(&dw_mci_pci_dev_pm_ops),
 	},
 };
 
Signature · 1 line
2.50.0
#50 lore raw

PATCH 38/38 mmc: dw_mmc-rockchip: use modern PM macros

In reply to Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

---
 drivers/mmc/host/dw_mmc-rockchip.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mmc/host/dw_mmc-rockchip.c +3 -6
index baa23b517731..d2aec6cf9773 100644
@@ -568,11 +568,8 @@ static void dw_mci_rockchip_remove(struct platform_device *pdev)
 }
 
 static const struct dev_pm_ops dw_mci_rockchip_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend,
-			   dw_mci_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(dw_mci_runtime_suspend, dw_mci_runtime_resume, NULL)
 };
 
 static struct platform_driver dw_mci_rockchip_pltfm_driver = {
@@ -582,7 +579,7 @@ static struct platform_driver dw_mci_rockchip_pltfm_driver = {
 		.name		= "dwmmc_rockchip",
 		.probe_type	= PROBE_PREFER_ASYNCHRONOUS,
 		.of_match_table	= dw_mci_rockchip_match,
-		.pm		= &dw_mci_rockchip_dev_pm_ops,
+		.pm		= pm_ptr(&dw_mci_rockchip_dev_pm_ops),
 	},
 };
 
Signature · 1 line
2.50.0
#51 lore raw
In reply to Jisheng Zhang
Quoted 96 lines · Jisheng Zhang

Use the modern PM macros for the suspend and resume functions to be automatically dropped by the compiler when CONFIG_PM or CONFIG_PM_SLEEP are disabled, without having to use #ifdef guards or __maybe_unused.

This has the advantage of always compiling these functions in, independently of any Kconfig option. Thanks to that, bugs and other regressions are subsequently easier to catch.

Previously, I only cleaned up the host drivers which I used, e.g sdhci-of-dwcmshc, sdhci-pxav3 and sdhci-xenon, these are both compile tested and functionality tested. But then I also cleaned up other host drivers, but they are compile-tested only.

Jisheng Zhang (38):
sdhci: add some simple inline functions for !CONFIG_PM
mmc: sdhci-of-dwcmshc: use modern PM macros
mmc: sdhci-xenon: use modern PM macros
mmc: sdhci-pxav3: use modern PM macros
mmc: sunxi: use modern PM macros
mmc: alcor: use modern PM macros
mmc: atmel: use modern PM macros
mmc: au1xmmc: use modern PM macros
mmc: cb710-mmc: use modern PM macros
mmc: davinci_mmc: use modern PM macros
mmc: mmci: use modern PM macros
mmc: mxs-mmc: use modern PM macros
mmc: omap_hsmmc: use modern PM macros
mmc: rtsx_usb_sdmmc: use modern PM macros
mmc: sdhci-acpi: use modern PM macros
mmc: sdhci_am654: use modern PM macros
mmc: sdhci-brcmstb: use modern PM macros
mmc: sdhci-esdhc-imx: use modern PM macros
mmc: sdhci-of-arasan: use modern PM macros
mmc: sdhci-of-at91: use modern PM macros
mmc: sdhci-of-esdhc: use modern PM macros
mmc: sdhci-omap: use modern PM macros
mmc: sdhci-cadence: use modern PM macros
mmc: sdhci-s3c: use modern PM macros
mmc: sdhci-spear: use modern PM macros
mmc: sdhci-sprd: use modern PM macros
mmc: sdhci-st: use modern PM macros
mmc: sdhci-tegra: use modern PM macros
mmc: sh_mmicf: use modern PM macros
mmc: toshsd: use modern PM macros
mmc: wmt-sdmmc: use modern PM macros
mmc: mtk-sd: use modern PM macros
mmc: sdhci-msm: use modern PM macros
mmc: via-sdmmc: use modern PM macros
mmc: dw_mmc: exynos: use modern PM macros
mmc: dw_mmc-k3: use modern PM macros
mmc: dw_mmc-pci: use modern PM macros
mmc: dw_mmc-rockchip: use modern PM macros

 drivers/mmc/host/alcor.c            |  8 +++-----
 drivers/mmc/host/atmel-mci.c        |  9 +++------
 drivers/mmc/host/au1xmmc.c          | 18 +++++++-----------
 drivers/mmc/host/cb710-mmc.c        | 19 +++++++++----------
 drivers/mmc/host/davinci_mmc.c      | 14 +++-----------
 drivers/mmc/host/dw_mmc-exynos.c    | 13 +++----------
 drivers/mmc/host/dw_mmc-k3.c        |  9 +++------
 drivers/mmc/host/dw_mmc-pci.c       |  9 +++------
 drivers/mmc/host/dw_mmc-rockchip.c  |  9 +++------
 drivers/mmc/host/dw_mmc.h           |  3 +++
 drivers/mmc/host/mmci.c             |  9 +++------
 drivers/mmc/host/mtk-sd.c           | 14 +++++++-------
 drivers/mmc/host/mxs-mmc.c          |  6 ++----
 drivers/mmc/host/omap_hsmmc.c       | 13 ++++---------
 drivers/mmc/host/rtsx_usb_sdmmc.c   |  7 ++-----
 drivers/mmc/host/sdhci-acpi.c       | 18 ++++--------------
 drivers/mmc/host/sdhci-brcmstb.c    |  8 ++------
 drivers/mmc/host/sdhci-cadence.c    |  8 ++------
 drivers/mmc/host/sdhci-esdhc-imx.c  | 13 +++----------
 drivers/mmc/host/sdhci-msm.c        | 21 +++++++++------------
 drivers/mmc/host/sdhci-of-arasan.c  |  8 +++-----
 drivers/mmc/host/sdhci-of-at91.c    | 12 +++---------
 drivers/mmc/host/sdhci-of-dwcmshc.c | 13 +++----------
 drivers/mmc/host/sdhci-of-esdhc.c   |  8 ++------
 drivers/mmc/host/sdhci-omap.c       | 18 +++++++-----------
 drivers/mmc/host/sdhci-pxav3.c      | 11 +++--------
 drivers/mmc/host/sdhci-s3c.c        | 11 +++--------
 drivers/mmc/host/sdhci-spear.c      |  6 ++----
 drivers/mmc/host/sdhci-sprd.c       | 10 +++-------
 drivers/mmc/host/sdhci-st.c         |  6 ++----
 drivers/mmc/host/sdhci-tegra.c      | 13 +++++--------
 drivers/mmc/host/sdhci-xenon.c      | 13 +++----------
 drivers/mmc/host/sdhci.h            |  7 +++++++
 drivers/mmc/host/sdhci_am654.c      | 10 +++-------
 drivers/mmc/host/sh_mmcif.c         |  8 ++------
 drivers/mmc/host/sunxi-mmc.c        | 11 +++--------
 drivers/mmc/host/toshsd.c           |  8 ++------
 drivers/mmc/host/via-sdmmc.c        | 10 +++++-----
 drivers/mmc/host/wmt-sdmmc.c        | 16 ++--------------
 39 files changed, 141 insertions(+), 286 deletions(-)
Quoted 3 lines

--
2.50.0

The series applied for next, thanks!

Kind regards
Uffe