[PATCH 2/2] coresight: Switch to DEFINE_RUNTIME_DEV_PM_OPS()

Eric Chan ericchancf at google.com
Thu Sep 10 07:51:07 PDT 2026


According to Documentation/power/runtime_pm.rst and
include/linux/pm_runtime.h, modern drivers are encouraged to use
DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() to simplify runtime PM ops
definitions and eliminate unnecessary #ifdef CONFIG_PM guards.

Convert the CoreSight TMC, CATU, and ETM4x drivers to use
DEFINE_RUNTIME_DEV_PM_OPS() and replace direct references to their
dev_pm_ops structures with pm_ptr(). This removes the #ifdef CONFIG_PM
blocks around the runtime suspend and resume callbacks, allowing the
compiler to always validate them regardless of CONFIG_PM.

Signed-off-by: Eric Chan <ericchancf at google.com>
---
 drivers/hwtracing/coresight/coresight-catu.c       | 12 +++++-------
 drivers/hwtracing/coresight/coresight-etm4x-core.c | 11 ++++-------
 drivers/hwtracing/coresight/coresight-tmc-core.c   | 12 ++++--------
 3 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c
index d9a12d5e48fa..e3bbfb707f73 100644
--- a/drivers/hwtracing/coresight/coresight-catu.c
+++ b/drivers/hwtracing/coresight/coresight-catu.c
@@ -14,6 +14,7 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 
 #include "coresight-catu.h"
@@ -640,7 +641,6 @@ static void catu_platform_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 }
 
-#ifdef CONFIG_PM
 static int catu_runtime_suspend(struct device *dev)
 {
 	struct catu_drvdata *drvdata = dev_get_drvdata(dev);
@@ -666,11 +666,9 @@ static int catu_runtime_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops catu_dev_pm_ops = {
-	SET_RUNTIME_PM_OPS(catu_runtime_suspend, catu_runtime_resume, NULL)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(catu_dev_pm_ops,
+				 catu_runtime_suspend, catu_runtime_resume, NULL);
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id catu_acpi_ids[] = {
@@ -688,14 +686,14 @@ static struct platform_driver catu_platform_driver = {
 		.name			= "coresight-catu-platform",
 		.acpi_match_table	= ACPI_PTR(catu_acpi_ids),
 		.suppress_bind_attrs	= true,
-		.pm			= &catu_dev_pm_ops,
+		.pm			= pm_ptr(&catu_dev_pm_ops),
 	},
 };
 
 static struct amba_driver catu_driver = {
 	.drv = {
 		.name			= "coresight-catu",
-		.pm			= &catu_dev_pm_ops,
+		.pm			= pm_ptr(&catu_dev_pm_ops),
 		.suppress_bind_attrs	= true,
 	},
 	.probe				= catu_probe,
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
index ace5e077a10c..ef664a84120f 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
@@ -2460,7 +2460,6 @@ static const struct amba_id etm4_ids[] = {
 
 MODULE_DEVICE_TABLE(amba, etm4_ids);
 
-#ifdef CONFIG_PM
 static int etm4_runtime_suspend(struct device *dev)
 {
 	struct etmv4_drvdata *drvdata = dev_get_drvdata(dev);
@@ -2486,11 +2485,9 @@ static int etm4_runtime_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops etm4_dev_pm_ops = {
-	SET_RUNTIME_PM_OPS(etm4_runtime_suspend, etm4_runtime_resume, NULL)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(etm4_dev_pm_ops,
+				 etm4_runtime_suspend, etm4_runtime_resume, NULL);
 
 static const struct of_device_id etm4_sysreg_match[] = {
 	{ .compatible	= "arm,coresight-etm4x-sysreg" },
@@ -2514,14 +2511,14 @@ static struct platform_driver etm4_platform_driver = {
 		.of_match_table		= etm4_sysreg_match,
 		.acpi_match_table	= ACPI_PTR(etm4x_acpi_ids),
 		.suppress_bind_attrs	= true,
-		.pm			= &etm4_dev_pm_ops,
+		.pm			= pm_ptr(&etm4_dev_pm_ops),
 	},
 };
 
 static struct amba_driver etm4x_amba_driver = {
 	.drv = {
 		.name   = "coresight-etm4x",
-		.pm	= &etm4_dev_pm_ops,
+		.pm	= pm_ptr(&etm4_dev_pm_ops),
 		.suppress_bind_attrs = true,
 	},
 	.probe		= etm4_probe_amba,
diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
index ece2e8c9be26..77588d53e1b0 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-core.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
@@ -980,8 +980,6 @@ static void tmc_platform_remove(struct platform_device *pdev)
 	__tmc_remove(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 }
-
-#ifdef CONFIG_PM
 static int tmc_runtime_suspend(struct device *dev)
 {
 	struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
@@ -1007,11 +1005,9 @@ static int tmc_runtime_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops tmc_dev_pm_ops = {
-	SET_RUNTIME_PM_OPS(tmc_runtime_suspend, tmc_runtime_resume, NULL)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(tmc_dev_pm_ops,
+				 tmc_runtime_suspend, tmc_runtime_resume, NULL);
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id tmc_acpi_ids[] = {
@@ -1029,14 +1025,14 @@ static struct platform_driver tmc_platform_driver = {
 		.name			= "coresight-tmc-platform",
 		.acpi_match_table	= ACPI_PTR(tmc_acpi_ids),
 		.suppress_bind_attrs	= true,
-		.pm			= &tmc_dev_pm_ops,
+		.pm			= pm_ptr(&tmc_dev_pm_ops),
 	},
 };
 
 static struct amba_driver tmc_driver = {
 	.drv = {
 		.name   = "coresight-tmc",
-		.pm	= &tmc_dev_pm_ops,
+		.pm	= pm_ptr(&tmc_dev_pm_ops),
 		.suppress_bind_attrs = true,
 	},
 	.probe		= tmc_probe,
-- 
2.55.0.1003.g10538fe699-goog




More information about the linux-arm-kernel mailing list