Skip to contentSkip to conversation

AHCI power management cleanup

RFC PATCH In review Raphael Gallais-Pou 6 participants 23 messages Jan 27, 2025 – Jan 30, 2025

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

cover AHCI power management cleanup

Several AHCI drivers expose suspend/resume functions in a way that can be simplified. Using pre-processor operation can lead to errors, while relying on automatic kernel configuration is safer. It also shrinks the kernel size when CONFIG_PM_SLEEP is not used[1].

This has been compile-tested on x86, arm and arm64.

[1] https://lore.kernel.org/lkml/[email protected]/

---
Raphael Gallais-Pou (14):
ahci: brcm: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: ceva: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: da850: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: dm816: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: imx: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: mtk: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: platform: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: qoriq: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: seattle: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: sunxi: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: pata_arasan_cf: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: pata_imx: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: sata_highbank: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
ahci: sata_rcar: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

 drivers/ata/ahci_brcm.c      | 6 +++---
 drivers/ata/ahci_ceva.c      | 8 ++++----
 drivers/ata/ahci_da850.c     | 7 ++++---
 drivers/ata/ahci_dm816.c     | 8 ++++----
 drivers/ata/ahci_imx.c       | 6 ++----
 drivers/ata/ahci_mtk.c       | 7 ++++---
 drivers/ata/ahci_platform.c  | 7 ++++---
 drivers/ata/ahci_qoriq.c     | 9 ++++-----
 drivers/ata/ahci_seattle.c   | 7 ++++---
 drivers/ata/ahci_sunxi.c     | 9 ++++-----
 drivers/ata/pata_arasan_cf.c | 6 ++----
 drivers/ata/pata_imx.c       | 6 ++----
 drivers/ata/sata_highbank.c  | 9 ++++-----
 drivers/ata/sata_rcar.c      | 6 +-----
 14 files changed, 46 insertions(+), 55 deletions(-)

---
base-commit: 5ffa57f6eecefababb8cbe327222ef171943b183
change-id: 20250113-pm_ata-dbc07b3b0df3

Best regards,

Signature · 1 line
Raphael Gallais-Pou <[email protected]>
#1 lore raw

RFC PATCH 1/14 ahci: brcm: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/ahci_brcm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/ata/ahci_brcm.c +3 -3
index 29be74fedcf01934e436481c66cb8d329284d599..3d43ed5db6078b3f07440f21aae6edf73d1da7f2 100644
@@ -362,7 +362,7 @@ static int brcm_ahci_suspend(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused brcm_ahci_resume(struct device *dev)
+static int brcm_ahci_resume(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
 	struct ahci_host_priv *hpriv = host->private_data;
@@ -570,7 +570,7 @@ static void brcm_ahci_shutdown(struct platform_device *pdev)
 		dev_err(&pdev->dev, "failed to shutdown\n");
 }
 
-static SIMPLE_DEV_PM_OPS(ahci_brcm_pm_ops, brcm_ahci_suspend, brcm_ahci_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_brcm_pm_ops, brcm_ahci_suspend, brcm_ahci_resume);
 
 static struct platform_driver brcm_ahci_driver = {
 	.probe = brcm_ahci_probe,
@@ -579,7 +579,7 @@ static struct platform_driver brcm_ahci_driver = {
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = ahci_of_match,
-		.pm = &ahci_brcm_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_brcm_pm_ops),
 	},
 };
 module_platform_driver(brcm_ahci_driver);
Signature · 1 line
2.48.0
#2 lore raw

RFC PATCH 2/14 ahci: ceva: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/ahci_ceva.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ata/ahci_ceva.c +4 -4
index 2d6a08c23d6ad5d1d11a7de7fbe2968201d6095a..76e55f1f7db1f8349d696e92d8964af609532186 100644
@@ -363,12 +363,12 @@ static int ceva_ahci_probe(struct platform_device *pdev)
 	return rc;
 }
 
-static int __maybe_unused ceva_ahci_suspend(struct device *dev)
+static int ceva_ahci_suspend(struct device *dev)
 {
 	return ahci_platform_suspend(dev);
 }
 
-static int __maybe_unused ceva_ahci_resume(struct device *dev)
+static int ceva_ahci_resume(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
 	struct ahci_host_priv *hpriv = host->private_data;
@@ -398,7 +398,7 @@ static int __maybe_unused ceva_ahci_resume(struct device *dev)
 	return rc;
 }
 
-static SIMPLE_DEV_PM_OPS(ahci_ceva_pm_ops, ceva_ahci_suspend, ceva_ahci_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_ceva_pm_ops, ceva_ahci_suspend, ceva_ahci_resume);
 
 static const struct of_device_id ceva_ahci_of_match[] = {
 	{ .compatible = "ceva,ahci-1v84" },
@@ -412,7 +412,7 @@ static struct platform_driver ceva_ahci_driver = {
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = ceva_ahci_of_match,
-		.pm = &ahci_ceva_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_ceva_pm_ops),
 	},
 };
 module_platform_driver(ceva_ahci_driver);
Signature · 1 line
2.48.0
#3 lore raw

RFC PATCH 3/14 ahci: da850: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/ahci_da850.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/ata/ahci_da850.c +4 -3
index ca0924dc5bd26ba424b26bd040bf83720c96b56f..698b0c30de0d65423f932ab3c3d95787b692cb37 100644
@@ -227,8 +227,9 @@ static int ahci_da850_probe(struct platform_device *pdev)
 	return rc;
 }
 
-static SIMPLE_DEV_PM_OPS(ahci_da850_pm_ops, ahci_platform_suspend,
-			 ahci_platform_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_da850_pm_ops,
+				ahci_platform_suspend,
+				ahci_platform_resume);
 
 static const struct of_device_id ahci_da850_of_match[] = {
 	{ .compatible = "ti,da850-ahci", },
@@ -242,7 +243,7 @@ static struct platform_driver ahci_da850_driver = {
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = ahci_da850_of_match,
-		.pm = &ahci_da850_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_da850_pm_ops),
 	},
 };
 module_platform_driver(ahci_da850_driver);
Signature · 1 line
2.48.0
#4 lore raw

RFC PATCH 4/14 ahci: dm816: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/ahci_dm816.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ata/ahci_dm816.c +4 -4
index b08547b877a1f77ba220e925de321ed034147d7b..cb30a55945b8bdb1efefab192575864220215d08 100644
@@ -170,9 +170,9 @@ static int ahci_dm816_probe(struct platform_device *pdev)
 	return rc;
 }
 
-static SIMPLE_DEV_PM_OPS(ahci_dm816_pm_ops,
-			 ahci_platform_suspend,
-			 ahci_platform_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_dm816_pm_ops,
+				ahci_platform_suspend,
+				ahci_platform_resume);
 
 static const struct of_device_id ahci_dm816_of_match[] = {
 	{ .compatible = "ti,dm816-ahci", },
@@ -186,7 +186,7 @@ static struct platform_driver ahci_dm816_driver = {
 	.driver = {
 		.name = AHCI_DM816_DRV_NAME,
 		.of_match_table = ahci_dm816_of_match,
-		.pm = &ahci_dm816_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_dm816_pm_ops),
 	},
 };
 module_platform_driver(ahci_dm816_driver);
Signature · 1 line
2.48.0
#5 lore raw

RFC PATCH 5/14 ahci: imx: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/ahci_imx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/ahci_imx.c +2 -4
index f01f08048f97aa230877e413ba6e416d79779c1b..ec75a16c630a79ce10ea98b16c44c9a3908f869f 100644
@@ -993,7 +993,6 @@ static void ahci_imx_host_stop(struct ata_host *host)
 	clk_disable_unprepare(imxpriv->sata_clk);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int imx_ahci_suspend(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
@@ -1021,9 +1020,8 @@ static int imx_ahci_resume(struct device *dev)
 
 	return ahci_platform_resume_host(dev);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(ahci_imx_pm_ops, imx_ahci_suspend, imx_ahci_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_imx_pm_ops, imx_ahci_suspend, imx_ahci_resume);
 
 static struct platform_driver imx_ahci_driver = {
 	.probe = imx_ahci_probe,
@@ -1031,7 +1029,7 @@ static struct platform_driver imx_ahci_driver = {
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = imx_ahci_of_match,
-		.pm = &ahci_imx_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_imx_pm_ops),
 	},
 };
 module_platform_driver(imx_ahci_driver);
Signature · 1 line
2.48.0
maintainer Reviewed-by on v1 5/14
#6 lore raw

Re: [PATCH RFC 05/14] ahci: imx: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

Quoted 5 lines · Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

Quoted 40 lines
---
 drivers/ata/ahci_imx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/ahci_imx.c +2 -5
index f01f08048f97aa230877e413ba6e416d79779c1b..ec75a16c630a79ce10ea98b16c44c9a3908f869f 100644
@@ -993,7 +993,6 @@ static void ahci_imx_host_stop(struct ata_host *host)
 	clk_disable_unprepare(imxpriv->sata_clk);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int imx_ahci_suspend(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
@@ -1021,9 +1020,8 @@ static int imx_ahci_resume(struct device *dev)
 
 	return ahci_platform_resume_host(dev);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(ahci_imx_pm_ops, imx_ahci_suspend, imx_ahci_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_imx_pm_ops, imx_ahci_suspend, imx_ahci_resume);
 
 static struct platform_driver imx_ahci_driver = {
 	.probe = imx_ahci_probe,
@@ -1031,7 +1029,7 @@ static struct platform_driver imx_ahci_driver = {
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = imx_ahci_of_match,
-		.pm = &ahci_imx_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_imx_pm_ops),
 	},
 };
 module_platform_driver(imx_ahci_driver);
 
--

2.48.0

#7 lore raw

RFC PATCH 6/14 ahci: mtk: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/ahci_mtk.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/ata/ahci_mtk.c +4 -3
index 7295b9066ae213a72a8c180a66ecfac8c2f46ff9..4afcf5e90e3b660f17b2eb0b1e3df446bef470da 100644
@@ -163,8 +163,9 @@ static int mtk_ahci_probe(struct platform_device *pdev)
 	return err;
 }
 
-static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_platform_suspend,
-			 ahci_platform_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_pm_ops,
+				ahci_platform_suspend,
+				ahci_platform_resume);
 
 static const struct of_device_id ahci_of_match[] = {
 	{ .compatible = "mediatek,mtk-ahci", },
@@ -178,7 +179,7 @@ static struct platform_driver mtk_ahci_driver = {
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = ahci_of_match,
-		.pm = &ahci_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_pm_ops),
 	},
 };
 module_platform_driver(mtk_ahci_driver);
Signature · 1 line
2.48.0
#8 lore raw

RFC PATCH 7/14 ahci: platform: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/ahci_platform.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/ata/ahci_platform.c +4 -3
index c18054333f7c968cc4e131545fc3127f03ac27e4..cd5d89c1902fab6c936aa04eefb461c968726185 100644
@@ -74,8 +74,9 @@ static int ahci_probe(struct platform_device *pdev)
 	return rc;
 }
 
-static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_platform_suspend,
-			 ahci_platform_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_pm_ops,
+				ahci_platform_suspend,
+				ahci_platform_resume);
 
 static const struct of_device_id ahci_of_match[] = {
 	{ .compatible = "generic-ahci", },
@@ -102,7 +103,7 @@ static struct platform_driver ahci_driver = {
 		.name = DRV_NAME,
 		.of_match_table = ahci_of_match,
 		.acpi_match_table = ahci_acpi_match,
-		.pm = &ahci_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_pm_ops),
 	},
 };
 module_platform_driver(ahci_driver);
Signature · 1 line
2.48.0
#9 lore raw

RFC PATCH 8/14 ahci: qoriq: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/ahci_qoriq.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/ata/ahci_qoriq.c +4 -5
index 30e39885b64edf9cbb1eeca853659582f5296361..5f64bb8cd2e9c8d34403f76e5789fa435dce94ca 100644
@@ -319,7 +319,6 @@ static int ahci_qoriq_probe(struct platform_device *pdev)
 	return rc;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int ahci_qoriq_resume(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
@@ -350,10 +349,10 @@ static int ahci_qoriq_resume(struct device *dev)
 
 	return rc;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(ahci_qoriq_pm_ops, ahci_platform_suspend,
-			 ahci_qoriq_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_qoriq_pm_ops,
+				ahci_platform_suspend,
+				ahci_qoriq_resume);
 
 static struct platform_driver ahci_qoriq_driver = {
 	.probe = ahci_qoriq_probe,
@@ -362,7 +361,7 @@ static struct platform_driver ahci_qoriq_driver = {
 		.name = DRV_NAME,
 		.of_match_table = ahci_qoriq_of_match,
 		.acpi_match_table = ahci_qoriq_acpi_match,
-		.pm = &ahci_qoriq_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_qoriq_pm_ops),
 	},
 };
 module_platform_driver(ahci_qoriq_driver);
Signature · 1 line
2.48.0
#10 lore raw

RFC PATCH 9/14 ahci: seattle: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/ahci_seattle.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/ata/ahci_seattle.c +4 -3
index 3f16c167840222e0de935f7fe44b3d83b95bc16c..4b67f3aa5787de433c8bcc1bb4965a887709aa9c 100644
@@ -174,8 +174,9 @@ static int ahci_seattle_probe(struct platform_device *pdev)
 	return rc;
 }
 
-static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_platform_suspend,
-			 ahci_platform_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_pm_ops,
+				ahci_platform_suspend,
+				ahci_platform_resume);
 
 static const struct acpi_device_id ahci_acpi_match[] = {
 	{ "AMDI0600", 0 },
@@ -189,7 +190,7 @@ static struct platform_driver ahci_seattle_driver = {
 	.driver = {
 		.name = DRV_NAME,
 		.acpi_match_table = ahci_acpi_match,
-		.pm = &ahci_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_pm_ops),
 	},
 };
 module_platform_driver(ahci_seattle_driver);
Signature · 1 line
2.48.0
#11 lore raw

RFC PATCH 10/14 ahci: sunxi: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/ahci_sunxi.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/ata/ahci_sunxi.c +4 -5
index 5d4584570ae013a4e44ca69557cc2c5aa61d32b1..2e86d4c97b822b6a52513dbe55e21851a58385d9 100644
@@ -253,7 +253,6 @@ static int ahci_sunxi_probe(struct platform_device *pdev)
 	return rc;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int ahci_sunxi_resume(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
@@ -278,10 +277,10 @@ static int ahci_sunxi_resume(struct device *dev)
 	ahci_platform_disable_resources(hpriv);
 	return rc;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(ahci_sunxi_pm_ops, ahci_platform_suspend,
-			 ahci_sunxi_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_sunxi_pm_ops,
+				ahci_platform_suspend,
+				ahci_sunxi_resume);
 
 static const struct of_device_id ahci_sunxi_of_match[] = {
 	{ .compatible = "allwinner,sun4i-a10-ahci", },
@@ -296,7 +295,7 @@ static struct platform_driver ahci_sunxi_driver = {
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = ahci_sunxi_of_match,
-		.pm = &ahci_sunxi_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_sunxi_pm_ops),
 	},
 };
 module_platform_driver(ahci_sunxi_driver);
Signature · 1 line
2.48.0
maintainer Acked-by on v1 10/14
#12 lore raw

Re: [PATCH RFC 10/14] ahci: sunxi: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

Dne ponedeljek, 27. januar 2025 ob 13:46:05 Srednjeevropski standardni čas je Raphael Gallais-Pou napisal(a):

Quoted 5 lines

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

Best regards,
Jernej

#13 lore raw

RFC PATCH 11/14 ahci: pata_arasan_cf: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/pata_arasan_cf.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_arasan_cf.c +2 -4
index 514d549286b56eabe07dfc2b3a961ef0f7c983f2..3ec03147a8fbe30e9f82c184d7a9c32cabcfdb92 100644
@@ -926,7 +926,6 @@ static void arasan_cf_remove(struct platform_device *pdev)
 	cf_exit(acdev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int arasan_cf_suspend(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
@@ -950,9 +949,8 @@ static int arasan_cf_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(arasan_cf_pm_ops, arasan_cf_suspend, arasan_cf_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(arasan_cf_pm_ops, arasan_cf_suspend, arasan_cf_resume);
 
 #ifdef CONFIG_OF
 static const struct of_device_id arasan_cf_id_table[] = {
@@ -967,7 +965,7 @@ static struct platform_driver arasan_cf_driver = {
 	.remove		= arasan_cf_remove,
 	.driver		= {
 		.name	= DRIVER_NAME,
-		.pm	= &arasan_cf_pm_ops,
+		.pm	= pm_sleep_ptr(&arasan_cf_pm_ops),
 		.of_match_table = of_match_ptr(arasan_cf_id_table),
 	},
 };
Signature · 1 line
2.48.0
#14 lore raw

Re: [PATCH RFC 11/14] ahci: pata_arasan_cf: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

kernel test robot noticed the following build errors:

Hi Raphael,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:

[auto build test ERROR on 5ffa57f6eecefababb8cbe327222ef171943b183]

url:    https://github.com/intel-lab-lkp/linux/commits/Raphael-Gallais-Pou/ahci-brcm-Switch-from-CONFIG_PM_SLEEP-guards-to-pm_sleep_ptr/20250127-205128
base:   5ffa57f6eecefababb8cbe327222ef171943b183
patch link:    https://lore.kernel.org/r/20250127-pm_ata-v1-11-f8f50c821a2a%40gmail.com
patch subject: [PATCH RFC 11/14] ahci: pata_arasan_cf: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20250128/[email protected]/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250128/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from drivers/ata/pata_arasan_cf.c:28:
In file included from include/linux/dmaengine.h:8:
In file included from include/linux/device.h:32:
In file included from include/linux/device/driver.h:21:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2224:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]

     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> drivers/ata/pata_arasan_cf.c:938:2: error: call to undeclared function 'ata_host_suspend'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     938 |         ata_host_suspend(host, PMSG_SUSPEND);
         |         ^
>> drivers/ata/pata_arasan_cf.c:948:2: error: call to undeclared function 'ata_host_resume'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     948 |         ata_host_resume(host);
         |         ^

3 warnings and 2 errors generated.

vim +/ata_host_suspend +938 drivers/ata/pata_arasan_cf.c

a480167b23ef9b3 Viresh Kumar    2011-02-22  928  
a480167b23ef9b3 Viresh Kumar    2011-02-22  929  static int arasan_cf_suspend(struct device *dev)
a480167b23ef9b3 Viresh Kumar    2011-02-22  930  {
90f0adf0936d464 Sergei Shtylyov 2011-10-12  931  	struct ata_host *host = dev_get_drvdata(dev);
a480167b23ef9b3 Viresh Kumar    2011-02-22  932  	struct arasan_cf_dev *acdev = host->ports[0]->private_data;
a480167b23ef9b3 Viresh Kumar    2011-02-22  933  
40679b3ce9d993e Viresh Kumar    2012-02-23  934  	if (acdev->dma_chan)
72b2caff4aac451 Vinod Koul      2014-10-11  935  		dmaengine_terminate_all(acdev->dma_chan);
40679b3ce9d993e Viresh Kumar    2012-02-23  936  
a480167b23ef9b3 Viresh Kumar    2011-02-22  937  	cf_exit(acdev);
ec87cf3782f7b05 Sergey Shtylyov 2022-02-02 @938  	ata_host_suspend(host, PMSG_SUSPEND);
ec87cf3782f7b05 Sergey Shtylyov 2022-02-02  939  	return 0;
a480167b23ef9b3 Viresh Kumar    2011-02-22  940  }
a480167b23ef9b3 Viresh Kumar    2011-02-22  941  
a480167b23ef9b3 Viresh Kumar    2011-02-22  942  static int arasan_cf_resume(struct device *dev)
a480167b23ef9b3 Viresh Kumar    2011-02-22  943  {
90f0adf0936d464 Sergei Shtylyov 2011-10-12  944  	struct ata_host *host = dev_get_drvdata(dev);
a480167b23ef9b3 Viresh Kumar    2011-02-22  945  	struct arasan_cf_dev *acdev = host->ports[0]->private_data;
a480167b23ef9b3 Viresh Kumar    2011-02-22  946  
a480167b23ef9b3 Viresh Kumar    2011-02-22  947  	cf_init(acdev);
a480167b23ef9b3 Viresh Kumar    2011-02-22 @948  	ata_host_resume(host);
a480167b23ef9b3 Viresh Kumar    2011-02-22  949  
a480167b23ef9b3 Viresh Kumar    2011-02-22  950  	return 0;
a480167b23ef9b3 Viresh Kumar    2011-02-22  951  }
a480167b23ef9b3 Viresh Kumar    2011-02-22  952  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#15 lore raw

Re: [PATCH RFC 11/14] ahci: pata_arasan_cf: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou
kernel test robot noticed the following build errors:

Hi Raphael,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:

[auto build test ERROR on 5ffa57f6eecefababb8cbe327222ef171943b183]

url:    https://github.com/intel-lab-lkp/linux/commits/Raphael-Gallais-Pou/ahci-brcm-Switch-from-CONFIG_PM_SLEEP-guards-to-pm_sleep_ptr/20250127-205128
base:   5ffa57f6eecefababb8cbe327222ef171943b183
patch link:    https://lore.kernel.org/r/20250127-pm_ata-v1-11-f8f50c821a2a%40gmail.com
patch subject: [PATCH RFC 11/14] ahci: pata_arasan_cf: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20250128/[email protected]/config)
compiler: s390-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250128/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/ata/pata_arasan_cf.c: In function 'arasan_cf_suspend':

>> drivers/ata/pata_arasan_cf.c:938:9: error: implicit declaration of function 'ata_host_suspend'; did you mean 'ata_sas_port_suspend'? [-Wimplicit-function-declaration]
     938 |         ata_host_suspend(host, PMSG_SUSPEND);
         |         ^~~~~~~~~~~~~~~~
         |         ata_sas_port_suspend
   drivers/ata/pata_arasan_cf.c: In function 'arasan_cf_resume':
>> drivers/ata/pata_arasan_cf.c:948:9: error: implicit declaration of function 'ata_host_resume'; did you mean 'sata_link_resume'? [-Wimplicit-function-declaration]
     948 |         ata_host_resume(host);
         |         ^~~~~~~~~~~~~~~
         |         sata_link_resume

vim +938 drivers/ata/pata_arasan_cf.c

a480167b23ef9b Viresh Kumar    2011-02-22  928  
a480167b23ef9b Viresh Kumar    2011-02-22  929  static int arasan_cf_suspend(struct device *dev)
a480167b23ef9b Viresh Kumar    2011-02-22  930  {
90f0adf0936d46 Sergei Shtylyov 2011-10-12  931  	struct ata_host *host = dev_get_drvdata(dev);
a480167b23ef9b Viresh Kumar    2011-02-22  932  	struct arasan_cf_dev *acdev = host->ports[0]->private_data;
a480167b23ef9b Viresh Kumar    2011-02-22  933  
40679b3ce9d993 Viresh Kumar    2012-02-23  934  	if (acdev->dma_chan)
72b2caff4aac45 Vinod Koul      2014-10-11  935  		dmaengine_terminate_all(acdev->dma_chan);
40679b3ce9d993 Viresh Kumar    2012-02-23  936  
a480167b23ef9b Viresh Kumar    2011-02-22  937  	cf_exit(acdev);
ec87cf3782f7b0 Sergey Shtylyov 2022-02-02 @938  	ata_host_suspend(host, PMSG_SUSPEND);
ec87cf3782f7b0 Sergey Shtylyov 2022-02-02  939  	return 0;
a480167b23ef9b Viresh Kumar    2011-02-22  940  }
a480167b23ef9b Viresh Kumar    2011-02-22  941  
a480167b23ef9b Viresh Kumar    2011-02-22  942  static int arasan_cf_resume(struct device *dev)
a480167b23ef9b Viresh Kumar    2011-02-22  943  {
90f0adf0936d46 Sergei Shtylyov 2011-10-12  944  	struct ata_host *host = dev_get_drvdata(dev);
a480167b23ef9b Viresh Kumar    2011-02-22  945  	struct arasan_cf_dev *acdev = host->ports[0]->private_data;
a480167b23ef9b Viresh Kumar    2011-02-22  946  
a480167b23ef9b Viresh Kumar    2011-02-22  947  	cf_init(acdev);
a480167b23ef9b Viresh Kumar    2011-02-22 @948  	ata_host_resume(host);
a480167b23ef9b Viresh Kumar    2011-02-22  949  
a480167b23ef9b Viresh Kumar    2011-02-22  950  	return 0;
a480167b23ef9b Viresh Kumar    2011-02-22  951  }
a480167b23ef9b Viresh Kumar    2011-02-22  952  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#16 lore raw

RFC PATCH 12/14 ahci: pata_imx: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/pata_imx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_imx.c +2 -4
index b37682b0578f48ea9d51a103d19e40fe91c4729f..533de2782c37fb21bba4e4b8361c48c0f2878175 100644
@@ -201,7 +201,6 @@ static void pata_imx_remove(struct platform_device *pdev)
 	__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int pata_imx_suspend(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
@@ -234,9 +233,8 @@ static int pata_imx_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(pata_imx_pm_ops, pata_imx_suspend, pata_imx_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(pata_imx_pm_ops, pata_imx_suspend, pata_imx_resume);
 
 static const struct of_device_id imx_pata_dt_ids[] = {
 	{
@@ -253,7 +251,7 @@ static struct platform_driver pata_imx_driver = {
 	.driver = {
 		.name		= DRV_NAME,
 		.of_match_table	= imx_pata_dt_ids,
-		.pm		= &pata_imx_pm_ops,
+		.pm		= pm_sleep_ptr(&pata_imx_pm_ops),
 	},
 };
 
Signature · 1 line
2.48.0
#17 lore raw

RFC PATCH 13/14 ahci: sata_highbank: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/sata_highbank.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/ata/sata_highbank.c +4 -5
index c8c817c51230a74df721016eb80238c188d96d01..c387e50485b974fa2f2defc0bd1ea8cd43dc14bb 100644
@@ -565,7 +565,6 @@ static int ahci_highbank_probe(struct platform_device *pdev)
 	return rc;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int ahci_highbank_suspend(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
@@ -609,17 +608,17 @@ static int ahci_highbank_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops,
-		  ahci_highbank_suspend, ahci_highbank_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops,
+				ahci_highbank_suspend,
+				ahci_highbank_resume);
 
 static struct platform_driver ahci_highbank_driver = {
 	.remove = ata_platform_remove_one,
 	.driver = {
 		.name = "highbank-ahci",
 		.of_match_table = ahci_of_match,
-		.pm = &ahci_highbank_pm_ops,
+		.pm = pm_sleep_ptr(&ahci_highbank_pm_ops),
 	},
 	.probe = ahci_highbank_probe,
 };
Signature · 1 line
2.48.0
#18 lore raw

Re: [PATCH RFC 13/14] ahci: sata_highbank: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

kernel test robot noticed the following build errors:

Hi Raphael,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:

[auto build test ERROR on 5ffa57f6eecefababb8cbe327222ef171943b183]

url:    https://github.com/intel-lab-lkp/linux/commits/Raphael-Gallais-Pou/ahci-brcm-Switch-from-CONFIG_PM_SLEEP-guards-to-pm_sleep_ptr/20250127-205128
base:   5ffa57f6eecefababb8cbe327222ef171943b183
patch link:    https://lore.kernel.org/r/20250127-pm_ata-v1-13-f8f50c821a2a%40gmail.com
patch subject: [PATCH RFC 13/14] ahci: sata_highbank: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
config: csky-randconfig-002-20250127 (https://download.01.org/0day-ci/archive/20250127/[email protected]/config)
compiler: csky-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250127/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/ata/sata_highbank.c: In function 'ahci_highbank_suspend':

>> drivers/ata/sata_highbank.c:590:9: error: implicit declaration of function 'ata_host_suspend'; did you mean 'ata_sas_port_suspend'? [-Wimplicit-function-declaration]
     590 |         ata_host_suspend(host, PMSG_SUSPEND);
         |         ^~~~~~~~~~~~~~~~
         |         ata_sas_port_suspend
   drivers/ata/sata_highbank.c: In function 'ahci_highbank_resume':
>> drivers/ata/sata_highbank.c:607:9: error: implicit declaration of function 'ata_host_resume'; did you mean 'ahci_port_resume'? [-Wimplicit-function-declaration]
     607 |         ata_host_resume(host);
         |         ^~~~~~~~~~~~~~~
         |         ahci_port_resume

vim +590 drivers/ata/sata_highbank.c

8996b89d6bc98ae Mark Langsdorf  2012-09-06  567  
8996b89d6bc98ae Mark Langsdorf  2012-09-06  568  static int ahci_highbank_suspend(struct device *dev)
8996b89d6bc98ae Mark Langsdorf  2012-09-06  569  {
8996b89d6bc98ae Mark Langsdorf  2012-09-06  570  	struct ata_host *host = dev_get_drvdata(dev);
8996b89d6bc98ae Mark Langsdorf  2012-09-06  571  	struct ahci_host_priv *hpriv = host->private_data;
8996b89d6bc98ae Mark Langsdorf  2012-09-06  572  	void __iomem *mmio = hpriv->mmio;
8996b89d6bc98ae Mark Langsdorf  2012-09-06  573  	u32 ctl;
8996b89d6bc98ae Mark Langsdorf  2012-09-06  574  
8996b89d6bc98ae Mark Langsdorf  2012-09-06  575  	if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
8996b89d6bc98ae Mark Langsdorf  2012-09-06  576  		dev_err(dev, "firmware update required for suspend/resume\n");
8996b89d6bc98ae Mark Langsdorf  2012-09-06  577  		return -EIO;
8996b89d6bc98ae Mark Langsdorf  2012-09-06  578  	}
8996b89d6bc98ae Mark Langsdorf  2012-09-06  579  
8996b89d6bc98ae Mark Langsdorf  2012-09-06  580  	/*
8996b89d6bc98ae Mark Langsdorf  2012-09-06  581  	 * AHCI spec rev1.1 section 8.3.3:
8996b89d6bc98ae Mark Langsdorf  2012-09-06  582  	 * Software must disable interrupts prior to requesting a
8996b89d6bc98ae Mark Langsdorf  2012-09-06  583  	 * transition of the HBA to D3 state.
8996b89d6bc98ae Mark Langsdorf  2012-09-06  584  	 */
8996b89d6bc98ae Mark Langsdorf  2012-09-06  585  	ctl = readl(mmio + HOST_CTL);
8996b89d6bc98ae Mark Langsdorf  2012-09-06  586  	ctl &= ~HOST_IRQ_EN;
8996b89d6bc98ae Mark Langsdorf  2012-09-06  587  	writel(ctl, mmio + HOST_CTL);
8996b89d6bc98ae Mark Langsdorf  2012-09-06  588  	readl(mmio + HOST_CTL); /* flush */
8996b89d6bc98ae Mark Langsdorf  2012-09-06  589  
ec87cf3782f7b05 Sergey Shtylyov 2022-02-02 @590  	ata_host_suspend(host, PMSG_SUSPEND);
ec87cf3782f7b05 Sergey Shtylyov 2022-02-02  591  	return 0;
8996b89d6bc98ae Mark Langsdorf  2012-09-06  592  }
8996b89d6bc98ae Mark Langsdorf  2012-09-06  593  
8996b89d6bc98ae Mark Langsdorf  2012-09-06  594  static int ahci_highbank_resume(struct device *dev)
8996b89d6bc98ae Mark Langsdorf  2012-09-06  595  {
8996b89d6bc98ae Mark Langsdorf  2012-09-06  596  	struct ata_host *host = dev_get_drvdata(dev);
8996b89d6bc98ae Mark Langsdorf  2012-09-06  597  	int rc;
8996b89d6bc98ae Mark Langsdorf  2012-09-06  598  
8996b89d6bc98ae Mark Langsdorf  2012-09-06  599  	if (dev->power.power_state.event == PM_EVENT_SUSPEND) {
8996b89d6bc98ae Mark Langsdorf  2012-09-06  600  		rc = ahci_reset_controller(host);
8996b89d6bc98ae Mark Langsdorf  2012-09-06  601  		if (rc)
8996b89d6bc98ae Mark Langsdorf  2012-09-06  602  			return rc;
8996b89d6bc98ae Mark Langsdorf  2012-09-06  603  
8996b89d6bc98ae Mark Langsdorf  2012-09-06  604  		ahci_init_controller(host);
8996b89d6bc98ae Mark Langsdorf  2012-09-06  605  	}
8996b89d6bc98ae Mark Langsdorf  2012-09-06  606  
8996b89d6bc98ae Mark Langsdorf  2012-09-06 @607  	ata_host_resume(host);
8996b89d6bc98ae Mark Langsdorf  2012-09-06  608  
8996b89d6bc98ae Mark Langsdorf  2012-09-06  609  	return 0;
8996b89d6bc98ae Mark Langsdorf  2012-09-06  610  }
8996b89d6bc98ae Mark Langsdorf  2012-09-06  611  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#19 lore raw

RFC PATCH 14/14 ahci: sata_rcar: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

In reply to Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

---
 drivers/ata/sata_rcar.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/ata/sata_rcar.c +1 -5
index 22820a02d7408033d698a98373e1e8e7ef47f908..4c5f5938c12efc7c8594df4092915011e83f910d 100644
@@ -927,7 +927,6 @@ static void sata_rcar_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sata_rcar_suspend(struct device *dev)
 {
 	struct ata_host *host = dev_get_drvdata(dev);
@@ -1005,7 +1004,6 @@ static const struct dev_pm_ops sata_rcar_pm_ops = {
 	.poweroff	= sata_rcar_suspend,
 	.restore	= sata_rcar_restore,
 };
-#endif
 
 static struct platform_driver sata_rcar_driver = {
 	.probe		= sata_rcar_probe,
@@ -1013,9 +1011,7 @@ static struct platform_driver sata_rcar_driver = {
 	.driver = {
 		.name		= DRV_NAME,
 		.of_match_table	= sata_rcar_match,
-#ifdef CONFIG_PM_SLEEP
-		.pm		= &sata_rcar_pm_ops,
-#endif
+		.pm		= pm_sleep_ptr(&sata_rcar_pm_ops),
 	},
 };
 
Signature · 1 line
2.48.0
#20 lore raw

Re: [PATCH RFC 14/14] ahci: sata_rcar: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

Hi Raphael,

Quoted 5 lines · Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

Thanks for your patch!

The subsystem prefix is "ata", not "ahci" (not all ATA-drivers are AHCI-drivers).

Quoted 11 lines
drivers/ata/sata_rcar.c +0 -1
@@ -927,7 +927,6 @@ static void sata_rcar_remove(struct platform_device *pdev)
        pm_runtime_disable(&pdev->dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sata_rcar_suspend(struct device *dev)
 {
        struct ata_host *host = dev_get_drvdata(dev);

drivers/ata/sata_rcar.c static const struct dev_pm_ops sata_rcar_pm_ops = { · line 1008

Quoted 4 lines
drivers/ata/sata_rcar.c +0 -1
@@ -1005,7 +1004,6 @@ static const struct dev_pm_ops sata_rcar_pm_ops = {
        .poweroff       = sata_rcar_suspend,
        .restore        = sata_rcar_restore,
 };
-#endif

If CONFIG_PM_SLEEP is disabled (e.g. m68k allyesconfig):

drivers/ata/sata_rcar.c: In function ‘sata_rcar_suspend’:
drivers/ata/sata_rcar.c:936:9: error: implicit declaration of
function ‘ata_host_suspend’; did you mean ‘sata_rcar_suspend’? [-Werror=implicit-function-declaration]

      936 |         ata_host_suspend(host, PMSG_SUSPEND);
          |         ^~~~~~~~~~~~~~~~
          |         sata_rcar_suspend

drivers/ata/sata_rcar.c: In function ‘sata_rcar_resume’:
drivers/ata/sata_rcar.c:973:9: error: implicit declaration of
function ‘ata_host_resume’; did you mean ‘sata_rcar_resume’? [-Werror=implicit-function-declaration]

      973 |         ata_host_resume(host);
          |         ^~~~~~~~~~~~~~~
          |         sata_rcar_resume

drivers/ata/sata_rcar.c static struct platform_driver sata_rcar_driver = { · line 1016

Quoted 13 lines
drivers/ata/sata_rcar.c +1 -3
 static struct platform_driver sata_rcar_driver = {
        .probe          = sata_rcar_probe,
@@ -1013,9 +1011,7 @@ static struct platform_driver sata_rcar_driver = {
        .driver = {
                .name           = DRV_NAME,
                .of_match_table = sata_rcar_match,
-#ifdef CONFIG_PM_SLEEP
-               .pm             = &sata_rcar_pm_ops,
-#endif
+               .pm             = pm_sleep_ptr(&sata_rcar_pm_ops),
        },
 };

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer
#21 lore raw

Re: [PATCH RFC 14/14] ahci: sata_rcar: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

Quoted 7 lines · Geert Uytterhoeven

Hi Raphael,

Quoted 4 lines · Raphael Gallais-Pou

Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based kernel configuration guards.

Quoted 6 lines
Quoted 1 line

Thanks for your patch!

The subsystem prefix is "ata", not "ahci" (not all ATA-drivers are AHCI-drivers).

Yep. The convention is:

ata: driver_name: xxx

So it would be:

ata: sata_rcar: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()

for this patch. And the same comment applies to all your other patches in the series.

Quoted 52 lines
Quoted 12 lines
drivers/ata/sata_rcar.c +0 -1
@@ -927,7 +927,6 @@ static void sata_rcar_remove(struct platform_device *pdev)
        pm_runtime_disable(&pdev->dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sata_rcar_suspend(struct device *dev)
 {
        struct ata_host *host = dev_get_drvdata(dev);

drivers/ata/sata_rcar.c static const struct dev_pm_ops sata_rcar_pm_ops = { · line 1008

Quoted 4 lines
drivers/ata/sata_rcar.c +0 -1
@@ -1005,7 +1004,6 @@ static const struct dev_pm_ops sata_rcar_pm_ops = {
        .poweroff       = sata_rcar_suspend,
        .restore        = sata_rcar_restore,
 };
-#endif

If CONFIG_PM_SLEEP is disabled (e.g. m68k allyesconfig):

drivers/ata/sata_rcar.c: In function ‘sata_rcar_suspend’:
drivers/ata/sata_rcar.c:936:9: error: implicit declaration of
function ‘ata_host_suspend’; did you mean ‘sata_rcar_suspend’? [-Werror=implicit-function-declaration]

      936 |         ata_host_suspend(host, PMSG_SUSPEND);
          |         ^~~~~~~~~~~~~~~~
          |         sata_rcar_suspend

drivers/ata/sata_rcar.c: In function ‘sata_rcar_resume’:
drivers/ata/sata_rcar.c:973:9: error: implicit declaration of
function ‘ata_host_resume’; did you mean ‘sata_rcar_resume’? [-Werror=implicit-function-declaration]

      973 |         ata_host_resume(host);
          |         ^~~~~~~~~~~~~~~
          |         sata_rcar_resume

drivers/ata/sata_rcar.c static struct platform_driver sata_rcar_driver = { · line 1016

Quoted 13 lines
drivers/ata/sata_rcar.c +1 -3
 static struct platform_driver sata_rcar_driver = {
        .probe          = sata_rcar_probe,
@@ -1013,9 +1011,7 @@ static struct platform_driver sata_rcar_driver = {
        .driver = {
                .name           = DRV_NAME,
                .of_match_table = sata_rcar_match,
-#ifdef CONFIG_PM_SLEEP
-               .pm             = &sata_rcar_pm_ops,
-#endif
+               .pm             = pm_sleep_ptr(&sata_rcar_pm_ops),
        },
 };

Gr{oetje,eeting}s,

Geert

Signature · 2 lines
Damien Le Moal
Western Digital Research
#22 lore raw
In reply to Raphael Gallais-Pou

Hi Raphael,

Quoted 4 lines · Raphael Gallais-Pou

Several AHCI drivers expose suspend/resume functions in a way that can be simplified. Using pre-processor operation can lead to errors, while relying on automatic kernel configuration is safer. It also shrinks the kernel size when CONFIG_PM_SLEEP is not used[1].

m68k/allyesconfig:

drivers/ata/sata_highbank.c: In function ‘ahci_highbank_suspend’:
drivers/ata/sata_highbank.c:590:9: error: implicit declaration of function ‘ata_host_suspend’; did you mean ‘ata_sas_port_suspend’? [-Werror=implicit-function-declaration] drivers/ata/sata_highbank.c: In function ‘ahci_highbank_resume’:
drivers/ata/sata_highbank.c:607:9: error: implicit declaration of function ‘ata_host_resume’; did you mean ‘ahci_port_resume’? [-Werror=implicit-function-declaration] drivers/ata/pata_arasan_cf.c: In function ‘arasan_cf_suspend’:
drivers/ata/pata_arasan_cf.c:938:9: error: implicit declaration of function ‘ata_host_suspend’; did you mean ‘ata_sas_port_suspend’? [-Werror=implicit-function-declaration] drivers/ata/pata_arasan_cf.c: In function ‘arasan_cf_resume’:
drivers/ata/pata_arasan_cf.c:948:9: error: implicit declaration of function ‘ata_host_resume’; did you mean ‘sata_link_resume’? [-Werror=implicit-function-declaration] drivers/ata/sata_rcar.c: In function ‘sata_rcar_suspend’:
drivers/ata/sata_rcar.c:936:9: error: implicit declaration of function ‘ata_host_suspend’; did you mean ‘sata_rcar_suspend’? [-Werror=implicit-function-declaration] drivers/ata/sata_rcar.c: In function ‘sata_rcar_resume’:
drivers/ata/sata_rcar.c:973:9: error: implicit declaration of function ‘ata_host_resume’; did you mean ‘sata_rcar_resume’? [-Werror=implicit-function-declaration] drivers/ata/pata_imx.c: In function ‘pata_imx_suspend’:
drivers/ata/pata_imx.c:209:9: error: implicit declaration of function ‘ata_host_suspend’; did you mean ‘pata_imx_suspend’? [-Werror=implicit-function-declaration] drivers/ata/pata_imx.c: In function ‘pata_imx_resume’:
drivers/ata/pata_imx.c:232:9: error: implicit declaration of function ‘ata_host_resume’; did you mean ‘pata_imx_resume’? [-Werror=implicit-function-declaration]

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds