diff mbox series

[v2,62/88] ASoC: intel: catpt: Convert to RUNTIME_PM_OPS() & co

Message ID 20250317095603.20073-63-tiwai@suse.de (mailing list archive)
State Accepted
Commit 2c498d9a3a5ad28d2cfbdffde8496626f1b89c82
Headers show
Series ASoC: Convert to modern PM macros | expand

Commit Message

Takashi Iwai March 17, 2025, 9:55 a.m. UTC
Use the newer RUNTIME_PM_OPS() and SYSTEM_SLEEP_PM_OPS() macros
instead of SET_RUNTIME_PM_OPS() and SET_SYSTEM_SLEEP_PM_OPS() together
with pm_ptr(), which allows us dropping ugly __maybe_unused
attributes.

This optimizes slightly when CONFIG_PM is disabled, too.

Cc: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/intel/catpt/device.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Cezary Rojewski March 17, 2025, 10:08 a.m. UTC | #1
On 2025-03-17 10:55 AM, Takashi Iwai wrote:
> Use the newer RUNTIME_PM_OPS() and SYSTEM_SLEEP_PM_OPS() macros
> instead of SET_RUNTIME_PM_OPS() and SET_SYSTEM_SLEEP_PM_OPS() together
> with pm_ptr(), which allows us dropping ugly __maybe_unused
> attributes.

Off-topic comment:
While __maybe_unused may not be the prettiest, it is still better 
alternative than #if/ifdef spam all over the code if you ask me.

> This optimizes slightly when CONFIG_PM is disabled, too.
> 
> Cc: Cezary Rojewski <cezary.rojewski@intel.com>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

Thank you for keeping me in loop. The patch looks good.

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>

> ---
>   sound/soc/intel/catpt/device.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/sound/soc/intel/catpt/device.c b/sound/soc/intel/catpt/device.c
> index 2aa637124bec..faa916f40069 100644
> --- a/sound/soc/intel/catpt/device.c
> +++ b/sound/soc/intel/catpt/device.c
> @@ -28,7 +28,7 @@
>   #define CREATE_TRACE_POINTS
>   #include "trace.h"
>   
> -static int __maybe_unused catpt_suspend(struct device *dev)
> +static int catpt_suspend(struct device *dev)
>   {
>   	struct catpt_dev *cdev = dev_get_drvdata(dev);
>   	struct dma_chan *chan;
> @@ -72,7 +72,7 @@ static int __maybe_unused catpt_suspend(struct device *dev)
>   	return catpt_dsp_power_down(cdev);
>   }
>   
> -static int __maybe_unused catpt_resume(struct device *dev)
> +static int catpt_resume(struct device *dev)
>   {
>   	struct catpt_dev *cdev = dev_get_drvdata(dev);
>   	int ret, i;
> @@ -106,7 +106,7 @@ static int __maybe_unused catpt_resume(struct device *dev)
>   	return 0;
>   }
>   
> -static int __maybe_unused catpt_runtime_suspend(struct device *dev)
> +static int catpt_runtime_suspend(struct device *dev)
>   {
>   	if (!try_module_get(dev->driver->owner)) {
>   		dev_info(dev, "module unloading, skipping suspend\n");
> @@ -117,14 +117,14 @@ static int __maybe_unused catpt_runtime_suspend(struct device *dev)
>   	return catpt_suspend(dev);
>   }
>   
> -static int __maybe_unused catpt_runtime_resume(struct device *dev)
> +static int catpt_runtime_resume(struct device *dev)
>   {
>   	return catpt_resume(dev);
>   }
>   
>   static const struct dev_pm_ops catpt_dev_pm = {
> -	SET_SYSTEM_SLEEP_PM_OPS(catpt_suspend, catpt_resume)
> -	SET_RUNTIME_PM_OPS(catpt_runtime_suspend, catpt_runtime_resume, NULL)
> +	SYSTEM_SLEEP_PM_OPS(catpt_suspend, catpt_resume)
> +	RUNTIME_PM_OPS(catpt_runtime_suspend, catpt_runtime_resume, NULL)
>   };
>   
>   /* machine board owned by CATPT is removed with this hook */
> @@ -378,7 +378,7 @@ static struct platform_driver catpt_acpi_driver = {
>   	.driver = {
>   		.name = "intel_catpt",
>   		.acpi_match_table = catpt_ids,
> -		.pm = &catpt_dev_pm,
> +		.pm = pm_ptr(&catpt_dev_pm),
>   		.dev_groups = catpt_attr_groups,
>   	},
>   };
Takashi Iwai March 17, 2025, 10:13 a.m. UTC | #2
On Mon, 17 Mar 2025 11:08:54 +0100,
Cezary Rojewski wrote:
> 
> On 2025-03-17 10:55 AM, Takashi Iwai wrote:
> > Use the newer RUNTIME_PM_OPS() and SYSTEM_SLEEP_PM_OPS() macros
> > instead of SET_RUNTIME_PM_OPS() and SET_SYSTEM_SLEEP_PM_OPS() together
> > with pm_ptr(), which allows us dropping ugly __maybe_unused
> > attributes.
> 
> Off-topic comment:
> While __maybe_unused may not be the prettiest, it is still better
> alternative than #if/ifdef spam all over the code if you ask me.

Yeah, that's why we introduced it in the past.

The downside is it's often more cumbersome to rip it off than the
explicit ifdef.


thanks,

Takashi
diff mbox series

Patch

diff --git a/sound/soc/intel/catpt/device.c b/sound/soc/intel/catpt/device.c
index 2aa637124bec..faa916f40069 100644
--- a/sound/soc/intel/catpt/device.c
+++ b/sound/soc/intel/catpt/device.c
@@ -28,7 +28,7 @@ 
 #define CREATE_TRACE_POINTS
 #include "trace.h"
 
-static int __maybe_unused catpt_suspend(struct device *dev)
+static int catpt_suspend(struct device *dev)
 {
 	struct catpt_dev *cdev = dev_get_drvdata(dev);
 	struct dma_chan *chan;
@@ -72,7 +72,7 @@  static int __maybe_unused catpt_suspend(struct device *dev)
 	return catpt_dsp_power_down(cdev);
 }
 
-static int __maybe_unused catpt_resume(struct device *dev)
+static int catpt_resume(struct device *dev)
 {
 	struct catpt_dev *cdev = dev_get_drvdata(dev);
 	int ret, i;
@@ -106,7 +106,7 @@  static int __maybe_unused catpt_resume(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused catpt_runtime_suspend(struct device *dev)
+static int catpt_runtime_suspend(struct device *dev)
 {
 	if (!try_module_get(dev->driver->owner)) {
 		dev_info(dev, "module unloading, skipping suspend\n");
@@ -117,14 +117,14 @@  static int __maybe_unused catpt_runtime_suspend(struct device *dev)
 	return catpt_suspend(dev);
 }
 
-static int __maybe_unused catpt_runtime_resume(struct device *dev)
+static int catpt_runtime_resume(struct device *dev)
 {
 	return catpt_resume(dev);
 }
 
 static const struct dev_pm_ops catpt_dev_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(catpt_suspend, catpt_resume)
-	SET_RUNTIME_PM_OPS(catpt_runtime_suspend, catpt_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(catpt_suspend, catpt_resume)
+	RUNTIME_PM_OPS(catpt_runtime_suspend, catpt_runtime_resume, NULL)
 };
 
 /* machine board owned by CATPT is removed with this hook */
@@ -378,7 +378,7 @@  static struct platform_driver catpt_acpi_driver = {
 	.driver = {
 		.name = "intel_catpt",
 		.acpi_match_table = catpt_ids,
-		.pm = &catpt_dev_pm,
+		.pm = pm_ptr(&catpt_dev_pm),
 		.dev_groups = catpt_attr_groups,
 	},
 };