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

Raphael Gallais-Pou posted 14 patches 3 days, 6 hours ago
[PATCH RFC 10/14] ahci: sunxi: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
Posted by Raphael Gallais-Pou 3 days, 6 hours ago
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.

Signed-off-by: Raphael Gallais-Pou <rgallaispou@gmail.com>
---
 drivers/ata/ahci_sunxi.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/ata/ahci_sunxi.c b/drivers/ata/ahci_sunxi.c
index 5d4584570ae013a4e44ca69557cc2c5aa61d32b1..2e86d4c97b822b6a52513dbe55e21851a58385d9 100644
--- a/drivers/ata/ahci_sunxi.c
+++ b/drivers/ata/ahci_sunxi.c
@@ -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);

-- 
2.48.0
Re: [PATCH RFC 10/14] ahci: sunxi: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
Posted by Jernej Škrabec 1 day ago
Dne ponedeljek, 27. januar 2025 ob 13:46:05 Srednjeevropski standardni čas je Raphael Gallais-Pou napisal(a):
> 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.
> 
> Signed-off-by: Raphael Gallais-Pou <rgallaispou@gmail.com>

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>

Best regards,
Jernej