Skip to contentSkip to conversation

mmc: esdhc-imx: convert to modern PM_OPS

PATCH Superseded Arnd Bergmann 4 participants 4 messages Apr 10, 2025 – Apr 11, 2025

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: esdhc-imx: convert to modern PM_OPS

From: Arnd Bergmann <[email protected]>

Two newly added functions are unused in configurations without power management support:

drivers/mmc/host/sdhci-esdhc-imx.c:1586:13: error: unused function 'sdhc_esdhc_tuning_save' [-Werror,-Wunused-function]
1586 | static void sdhc_esdhc_tuning_save(struct sdhci_host *host)

      |             ^~~~~~~~~~~~~~~~~~~~~~
drivers/mmc/host/sdhci-esdhc-imx.c:1608:13: error: unused function 'sdhc_esdhc_tuning_restore' [-Werror,-Wunused-function]
 1608 | static void sdhc_esdhc_tuning_restore(struct sdhci_host *host)
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~

Remove the #ifdef checks and instead use the better macros that silently drop the unused functions when PM is disabled.

Fixes 3d1eea493894 ("mmc: sdhci-esdhc-imx: Save tuning value when card stays powered in suspend")
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +2 -6
index 7e8addaed697..8742622da55a 100644
@@ -1942,7 +1942,6 @@ static void sdhci_esdhc_imx_remove(struct platform_device *pdev)
 	sdhci_pltfm_free(pdev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_esdhc_suspend(struct device *dev)
 {
 	struct sdhci_host *host = dev_get_drvdata(dev);
@@ -2021,9 +2020,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);
@@ -2103,11 +2100,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,
+	SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
+	RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
 				sdhci_esdhc_runtime_resume, NULL)
 };
 
Signature · 1 line
2.39.5
maintainer
#1 lore raw
Quoted 23 lines

-----Original Message-----
From: Arnd Bergmann <[email protected]>
Sent: 2025年4月10日 22:09
To: Adrian Hunter <[email protected]>; Bough Chen <[email protected]>; Ulf Hansson <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Luke Wang <[email protected]>
Cc: Arnd Bergmann <[email protected]>; Pengutronix Kernel Team <[email protected]>; Fabio Estevam <[email protected]>; Ciprian Marian Costea (OSS) <[email protected]>; Josua Mayer <[email protected]>; [email protected]; [email protected]; dl-S32 <[email protected]>; [email protected]; [email protected]
Subject: [PATCH] mmc: esdhc-imx: convert to modern PM_OPS

From: Arnd Bergmann <[email protected]>

Two newly added functions are unused in configurations without power management support:

drivers/mmc/host/sdhci-esdhc-imx.c:1586:13: error: unused function 'sdhc_esdhc_tuning_save' [-Werror,-Wunused-function]
1586 | static void sdhc_esdhc_tuning_save(struct sdhci_host *host)

Quoted 8 lines
      |             ^~~~~~~~~~~~~~~~~~~~~~
drivers/mmc/host/sdhci-esdhc-imx.c:1608:13: error: unused function
'sdhc_esdhc_tuning_restore' [-Werror,-Wunused-function]
 1608 | static void sdhc_esdhc_tuning_restore(struct sdhci_host *host)
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~

Remove the #ifdef checks and instead use the better macros that silently drop the unused functions when PM is disabled.

Hi Arnd,

Thanks for this catching.

How about add __maybe_unused to define this tuning_save/retore function?

Regards
Haibo Chen

Quoted 46 lines
Fixes 3d1eea493894 ("mmc: sdhci-esdhc-imx: Save tuning value when card

stays powered in suspend")

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -1
index 7e8addaed697..8742622da55a 100644
@@ -1942,7 +1942,6 @@ static void sdhci_esdhc_imx_remove(struct
 platform_device *pdev)
 	sdhci_pltfm_free(pdev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sdhci_esdhc_suspend(struct device *dev)  {
 	struct sdhci_host *host = dev_get_drvdata(dev); @@ -2021,9 +2020,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); @@ -2103,11 +2100,10

@@ static int sdhci_esdhc_runtime_resume(struct device *dev)

drivers/mmc/host/sdhci-esdhc-imx.c +2 -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,
+	SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume)
+	RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend,
 				sdhci_esdhc_runtime_resume, NULL)
 };
 
--

2.39.5

#2 lore raw
Quoted 10 lines · Bough Chen
Quoted 10 lines

From: Arnd Bergmann <[email protected]> drivers/mmc/host/sdhci-esdhc-imx.c:1586:13: error: unused function 'sdhc_esdhc_tuning_save' [-Werror,-Wunused-function]
1586 | static void sdhc_esdhc_tuning_save(struct sdhci_host *host)

      |             ^~~~~~~~~~~~~~~~~~~~~~
drivers/mmc/host/sdhci-esdhc-imx.c:1608:13: error: unused function
'sdhc_esdhc_tuning_restore' [-Werror,-Wunused-function]
 1608 | static void sdhc_esdhc_tuning_restore(struct sdhci_host *host)
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
Quoted 2 lines

Remove the #ifdef checks and instead use the better macros that silently drop the unused functions when PM is disabled.

Thanks for this catching.

How about add __maybe_unused to define this tuning_save/retore function?

That sounds counterproductive.

The new macros were introduced to allow removing all the pointless __maybe_unused annotations, I see no reason to stick with the legacy helpers here.

I did make a small mistake and ran into another warning later, but this fixup should address that:

drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
@@ -2112,7 +2112,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,

Arnd

maintainer
#3 lore raw
Quoted 31 lines · Arnd Bergmann
Quoted 10 lines · Bough Chen
Quoted 10 lines

From: Arnd Bergmann <[email protected]> drivers/mmc/host/sdhci-esdhc-imx.c:1586:13: error: unused function 'sdhc_esdhc_tuning_save' [-Werror,-Wunused-function]
1586 | static void sdhc_esdhc_tuning_save(struct sdhci_host *host)

      |             ^~~~~~~~~~~~~~~~~~~~~~
drivers/mmc/host/sdhci-esdhc-imx.c:1608:13: error: unused function
'sdhc_esdhc_tuning_restore' [-Werror,-Wunused-function]
 1608 | static void sdhc_esdhc_tuning_restore(struct sdhci_host *host)
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
Quoted 2 lines

Remove the #ifdef checks and instead use the better macros that silently drop the unused functions when PM is disabled.

Thanks for this catching.

How about add __maybe_unused to define this tuning_save/retore function?

That sounds counterproductive.

The new macros were introduced to allow removing all the pointless __maybe_unused annotations, I see no reason to stick with the legacy helpers here.

I did make a small mistake and ran into another warning later, but this fixup should address that:

drivers/mmc/host/sdhci-esdhc-imx.c static struct platform_driver sdhci_esdhc_imx_driver = { · line 2118

Quoted 8 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
@@ -2112,7 +2112,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,

Can someone provide a Tested-by?