Skip to contentSkip to conversation

media: rockchip: Modernize PM_OPS

PATCH In review Diederik de Haas 3 participants 8 messages Oct 1 – Oct 2

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

cover media: rockchip: Modernize PM_OPS

A bunch of new PM_OPS macros got introduced in commit 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones")

Straight up copied from that commit message:

These new macros are very similar to their SET_*_PM_OPS() equivalent. They however differ in the fact that the callbacks they set will always be seen as referenced by the compiler. This means that the callback functions don't need to be wrapped with a #ifdef CONFIG_PM guard, or tagged with __maybe_unused, to prevent the compiler from complaining about unused static symbols. The compiler will then simply evaluate at compile time whether or not these symbols are dead code.

So convert the rockchip media components which used the old macros to the new ones.

Diederik de Haas (3):
media: rkvdec: Switch to modern PM_OPS
media: rockchip: rga: Switch to modern PM_OPS
media: rkisp1: Switch to modern PM_OPS

 drivers/media/platform/rockchip/rga/rga.c           |  9 ++++-----
 drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 11 +++++------
 drivers/media/platform/rockchip/rkvdec/rkvdec.c     |  9 +++------
 3 files changed, 12 insertions(+), 17 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/3 media: rkvdec: Switch to modern PM_OPS

A new set of modern PM_OPS macros got defined in commit 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones")

Switch to those new macros so that the PM callbacks are always seen by the compiler, but discarded if not used. This lets us drop the check for CONFIG_PM.

---
 drivers/media/platform/rockchip/rkvdec/rkvdec.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/media/platform/rockchip/rkvdec/rkvdec.c +3 -6
index 061281f903f3..936abd92f703 100644
@@ -1877,7 +1877,6 @@ static void rkvdec_remove(struct platform_device *pdev)
 		iommu_domain_free(rkvdec->empty_domain);
 }
 
-#ifdef CONFIG_PM
 static int rkvdec_runtime_resume(struct device *dev)
 {
 	struct rkvdec_dev *rkvdec = dev_get_drvdata(dev);
@@ -1892,12 +1891,10 @@ static int rkvdec_runtime_suspend(struct device *dev)
 	clk_bulk_disable_unprepare(rkvdec->num_clocks, rkvdec->clocks);
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops rkvdec_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(rkvdec_runtime_suspend, rkvdec_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(rkvdec_runtime_suspend, rkvdec_runtime_resume, NULL)
 };
 
 static struct platform_driver rkvdec_driver = {
@@ -1906,7 +1903,7 @@ static struct platform_driver rkvdec_driver = {
 	.driver = {
 		   .name = "rkvdec",
 		   .of_match_table = of_rkvdec_match,
-		   .pm = &rkvdec_pm_ops,
+		   .pm = pm_ptr(&rkvdec_pm_ops),
 	},
 };
 module_platform_driver(rkvdec_driver);
Signature · 1 line
2.55.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] media: rkvdec: Switch to modern PM_OPS

Le jeudi 01 octobre 2026 à 19:34 +0200, Diederik de Haas a écrit :

Quoted 8 lines

A new set of modern PM_OPS macros got defined in commit 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones")

Switch to those new macros so that the PM callbacks are always seen by the compiler, but discarded if not used. This lets us drop the check for CONFIG_PM.

Quoted 40 lines
---
 drivers/media/platform/rockchip/rkvdec/rkvdec.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/media/platform/rockchip/rkvdec/rkvdec.c +3 -6
index 061281f903f3..936abd92f703 100644
@@ -1877,7 +1877,6 @@ static void rkvdec_remove(struct platform_device *pdev)
 		iommu_domain_free(rkvdec->empty_domain);
 }
 
-#ifdef CONFIG_PM
 static int rkvdec_runtime_resume(struct device *dev)
 {
 	struct rkvdec_dev *rkvdec = dev_get_drvdata(dev);
@@ -1892,12 +1891,10 @@ static int rkvdec_runtime_suspend(struct device *dev)
 	clk_bulk_disable_unprepare(rkvdec->num_clocks, rkvdec->clocks);
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops rkvdec_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(rkvdec_runtime_suspend, rkvdec_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(rkvdec_runtime_suspend, rkvdec_runtime_resume, NULL)
 };
 
 static struct platform_driver rkvdec_driver = {
@@ -1906,7 +1903,7 @@ static struct platform_driver rkvdec_driver = {
 	.driver = {
 		   .name = "rkvdec",
 		   .of_match_table = of_rkvdec_match,
-		   .pm = &rkvdec_pm_ops,
+		   .pm = pm_ptr(&rkvdec_pm_ops),
 	},
 };
 module_platform_driver(rkvdec_driver);
#3 lore raw

PATCH 2/3 media: rockchip: rga: Switch to modern PM_OPS

In reply to Diederik de Haas

A new set of modern PM_OPS macros got defined in commit 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones")

Switch to those new macros so that the PM callbacks are always seen by the compiler, but discarded if not used. This lets us drop the __maybe_unused annotation from the callback functions.

---
 drivers/media/platform/rockchip/rga/rga.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/media/platform/rockchip/rga/rga.c +4 -5
index b3cb6bf8eb86..f28c93d63760 100644
@@ -883,7 +883,7 @@ static void rga_remove(struct platform_device *pdev)
 	pm_runtime_disable(rga->dev);
 }
 
-static int __maybe_unused rga_runtime_suspend(struct device *dev)
+static int rga_runtime_suspend(struct device *dev)
 {
 	struct rockchip_rga *rga = dev_get_drvdata(dev);
 
@@ -892,7 +892,7 @@ static int __maybe_unused rga_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused rga_runtime_resume(struct device *dev)
+static int rga_runtime_resume(struct device *dev)
 {
 	struct rockchip_rga *rga = dev_get_drvdata(dev);
 
@@ -900,8 +900,7 @@ static int __maybe_unused rga_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops rga_pm = {
-	SET_RUNTIME_PM_OPS(rga_runtime_suspend,
-			   rga_runtime_resume, NULL)
+	RUNTIME_PM_OPS(rga_runtime_suspend, rga_runtime_resume, NULL)
 };
 
 static const struct of_device_id rockchip_rga_match[] = {
@@ -927,7 +926,7 @@ static struct platform_driver rga_pdrv = {
 	.remove = rga_remove,
 	.driver = {
 		.name = RGA_NAME,
-		.pm = &rga_pm,
+		.pm = pm_ptr(&rga_pm),
 		.of_match_table = rockchip_rga_match,
 	},
 };
Signature · 1 line
2.55.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] media: rockchip: rga: Switch to modern PM_OPS

Le jeudi 01 octobre 2026 à 19:34 +0200, Diederik de Haas a écrit :

Quoted 8 lines

A new set of modern PM_OPS macros got defined in commit 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones")

Switch to those new macros so that the PM callbacks are always seen by the compiler, but discarded if not used. This lets us drop the __maybe_unused annotation from the callback functions.

Quoted 45 lines
---
 drivers/media/platform/rockchip/rga/rga.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/media/platform/rockchip/rga/rga.c +4 -5
index b3cb6bf8eb86..f28c93d63760 100644
@@ -883,7 +883,7 @@ static void rga_remove(struct platform_device *pdev)
 	pm_runtime_disable(rga->dev);
 }
 
-static int __maybe_unused rga_runtime_suspend(struct device *dev)
+static int rga_runtime_suspend(struct device *dev)
 {
 	struct rockchip_rga *rga = dev_get_drvdata(dev);
 
@@ -892,7 +892,7 @@ static int __maybe_unused rga_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused rga_runtime_resume(struct device *dev)
+static int rga_runtime_resume(struct device *dev)
 {
 	struct rockchip_rga *rga = dev_get_drvdata(dev);
 
@@ -900,8 +900,7 @@ static int __maybe_unused rga_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops rga_pm = {
-	SET_RUNTIME_PM_OPS(rga_runtime_suspend,
-			   rga_runtime_resume, NULL)
+	RUNTIME_PM_OPS(rga_runtime_suspend, rga_runtime_resume, NULL)
 };
 
 static const struct of_device_id rockchip_rga_match[] = {
@@ -927,7 +926,7 @@ static struct platform_driver rga_pdrv = {
 	.remove = rga_remove,
 	.driver = {
 		.name = RGA_NAME,
-		.pm = &rga_pm,
+		.pm = pm_ptr(&rga_pm),
 		.of_match_table = rockchip_rga_match,
 	},
 };
#5 lore raw

PATCH 3/3 media: rkisp1: Switch to modern PM_OPS

In reply to Diederik de Haas

A new set of modern PM_OPS macros got defined in commit 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones")

Switch to those new macros so that the PM callbacks are always seen by the compiler, but discarded if not used. This lets us drop the __maybe_unused annotation from the callback functions.

---
 drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +5 -6
index f90e01301943..e619a949dbc9 100644
@@ -305,7 +305,7 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1)
  * Power
  */
 
-static int __maybe_unused rkisp1_runtime_suspend(struct device *dev)
+static int rkisp1_runtime_suspend(struct device *dev)
 {
 	struct rkisp1_device *rkisp1 = dev_get_drvdata(dev);
 
@@ -331,7 +331,7 @@ static int __maybe_unused rkisp1_runtime_suspend(struct device *dev)
 	return pinctrl_pm_select_sleep_state(dev);
 }
 
-static int __maybe_unused rkisp1_runtime_resume(struct device *dev)
+static int rkisp1_runtime_resume(struct device *dev)
 {
 	struct rkisp1_device *rkisp1 = dev_get_drvdata(dev);
 	int ret;
@@ -351,9 +351,8 @@ static int __maybe_unused rkisp1_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops rkisp1_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(rkisp1_runtime_suspend, rkisp1_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(rkisp1_runtime_suspend, rkisp1_runtime_resume, NULL)
 };
 
 /* ----------------------------------------------------------------------------
@@ -815,7 +814,7 @@ static struct platform_driver rkisp1_drv = {
 	.driver = {
 		.name = RKISP1_DRIVER_NAME,
 		.of_match_table = of_match_ptr(rkisp1_of_match),
-		.pm = &rkisp1_pm_ops,
+		.pm = pm_ptr(&rkisp1_pm_ops),
 	},
 	.probe = rkisp1_probe,
 	.remove = rkisp1_remove,
Signature · 1 line
2.55.0
maintainer Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH 3/3] media: rkisp1: Switch to modern PM_OPS

Quoted 8 lines · Diederik de Haas

A new set of modern PM_OPS macros got defined in commit 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones")

Switch to those new macros so that the PM callbacks are always seen by the compiler, but discarded if not used. This lets us drop the __maybe_unused annotation from the callback functions.

As the three patches in this series are independent from each other, I've taken this in my tree.

Quoted 47 lines
---
 drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +5 -6
index f90e01301943..e619a949dbc9 100644
@@ -305,7 +305,7 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1)
  * Power
  */
 
-static int __maybe_unused rkisp1_runtime_suspend(struct device *dev)
+static int rkisp1_runtime_suspend(struct device *dev)
 {
 	struct rkisp1_device *rkisp1 = dev_get_drvdata(dev);
 
@@ -331,7 +331,7 @@ static int __maybe_unused rkisp1_runtime_suspend(struct device *dev)
 	return pinctrl_pm_select_sleep_state(dev);
 }
 
-static int __maybe_unused rkisp1_runtime_resume(struct device *dev)
+static int rkisp1_runtime_resume(struct device *dev)
 {
 	struct rkisp1_device *rkisp1 = dev_get_drvdata(dev);
 	int ret;
@@ -351,9 +351,8 @@ static int __maybe_unused rkisp1_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops rkisp1_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(rkisp1_runtime_suspend, rkisp1_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(rkisp1_runtime_suspend, rkisp1_runtime_resume, NULL)
 };
 
 /* ----------------------------------------------------------------------------
@@ -815,7 +814,7 @@ static struct platform_driver rkisp1_drv = {
 	.driver = {
 		.name = RKISP1_DRIVER_NAME,
 		.of_match_table = of_match_ptr(rkisp1_of_match),
-		.pm = &rkisp1_pm_ops,
+		.pm = pm_ptr(&rkisp1_pm_ops),
 	},
 	.probe = rkisp1_probe,
 	.remove = rkisp1_remove,
Signature · 3 lines
Regards,

Laurent Pinchart
#7 lore raw
In reply to Diederik de Haas

Hi,

Le jeudi 01 octobre 2026 à 19:34 +0200, Diederik de Haas a écrit :

Quoted 13 lines

A bunch of new PM_OPS macros got introduced in commit 1a3c7bb08826 ("PM: core: Add new *_PM_OPS macros, deprecate old ones")

Straight up copied from that commit message:

These new macros are very similar to their SET_*_PM_OPS() equivalent. They however differ in the fact that the callbacks they set will always be seen as referenced by the compiler. This means that the callback functions don't need to be wrapped with a #ifdef CONFIG_PM guard, or tagged with __maybe_unused, to prevent the compiler from complaining about unused static symbols. The compiler will then simply evaluate at compile time whether or not these symbols are dead code.

Quoted 6 lines

So convert the rockchip media components which used the old macros to the new ones.

Diederik de Haas (3):
media: rkvdec: Switch to modern PM_OPS
media: rockchip: rga: Switch to modern PM_OPS

I'm taking the two first, thanks!

Quoted 6 lines

media: rkisp1: Switch to modern PM_OPS

 drivers/media/platform/rockchip/rga/rga.c           |  9 ++++-----
 drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 11 +++++------
 drivers/media/platform/rockchip/rkvdec/rkvdec.c     |  9 +++------
 3 files changed, 12 insertions(+), 17 deletions(-)