Skip to contentSkip to conversation

iio: adc: rzg2l: Use RUNTIME_PM_OPS() instead of SET_*

PATCH In review Jonathan Cameron 2 participants 6 messages Aug 7, 2022 – Jan 28, 2023

Subsystems (2)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

PATCH 1/1 iio: adc: rzg2l: Use RUNTIME_PM_OPS() instead of SET_*

From: Jonathan Cameron <[email protected]>

Here we could use DEFINE_RUNTIME_DEV_PM_OPS() but that would have the side effect of providing suspend and resume support. That would be harmless but also of little purpose as this driver does very simplistic power management with synchronous power up and down around individual channel reads.

In general these new PM macros avoid the need to mark functions __maybe_unused, whilst still allowing the compiler to remove them if they are unused.

Cc Biju Das <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
---
 drivers/iio/adc/rzg2l_adc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/iio/adc/rzg2l_adc.c +6 -6
index 0921ff2d9b3a..b859a2db6b13 100644
@@ -547,7 +547,7 @@ static const struct of_device_id rzg2l_adc_match[] = {
 };
 MODULE_DEVICE_TABLE(of, rzg2l_adc_match);
 
-static int __maybe_unused rzg2l_adc_pm_runtime_suspend(struct device *dev)
+static int rzg2l_adc_pm_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct rzg2l_adc *adc = iio_priv(indio_dev);
@@ -559,7 +559,7 @@ static int __maybe_unused rzg2l_adc_pm_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused rzg2l_adc_pm_runtime_resume(struct device *dev)
+static int rzg2l_adc_pm_runtime_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct rzg2l_adc *adc = iio_priv(indio_dev);
@@ -581,9 +581,9 @@ static int __maybe_unused rzg2l_adc_pm_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops rzg2l_adc_pm_ops = {
-	SET_RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
-			   rzg2l_adc_pm_runtime_resume,
-			   NULL)
+	RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
+		       rzg2l_adc_pm_runtime_resume,
+		       NULL)
 };
 
 static struct platform_driver rzg2l_adc_driver = {
@@ -591,7 +591,7 @@ static struct platform_driver rzg2l_adc_driver = {
 	.driver		= {
 		.name		= DRIVER_NAME,
 		.of_match_table = rzg2l_adc_match,
-		.pm		= &rzg2l_adc_pm_ops,
+		.pm		= pm_ptr(&rzg2l_adc_pm_ops),
 	},
 };
 
Signature · 1 line
2.37.1
#1 lore raw
Quoted 12 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Here we could use DEFINE_RUNTIME_DEV_PM_OPS() but that would have the side effect of providing suspend and resume support. That would be harmless but also of little purpose as this driver does very simplistic power management with synchronous power up and down around individual channel reads.

In general these new PM macros avoid the need to mark functions __maybe_unused, whilst still allowing the compiler to remove them if they are unused.

...

drivers/iio/adc/rzg2l_adc.c static int __maybe_unused rzg2l_adc_pm_runtime_resume(struct device *dev) · line 587

Quoted 8 lines

static const struct dev_pm_ops rzg2l_adc_pm_ops = {

drivers/iio/adc/rzg2l_adc.c +3 -3
-       SET_RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
-                          rzg2l_adc_pm_runtime_resume,
-                          NULL)
+       RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
+                      rzg2l_adc_pm_runtime_resume,
+                      NULL)
 };

DEFINE_RUNTIME_DEV_PM_OPS() ?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#2 lore raw
Quoted 25 lines · On Mon, 8 Aug 2022 11:34:23 +0200 Andy Shevchenko <[email protected]>…
Quoted 12 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Here we could use DEFINE_RUNTIME_DEV_PM_OPS() but that would have the side effect of providing suspend and resume support. That would be harmless but also of little purpose as this driver does very simplistic power management with synchronous power up and down around individual channel reads.

In general these new PM macros avoid the need to mark functions __maybe_unused, whilst still allowing the compiler to remove them if they are unused.

...

drivers/iio/adc/rzg2l_adc.c static int __maybe_unused rzg2l_adc_pm_runtime_resume(struct device *dev) · line 587

Quoted 8 lines

static const struct dev_pm_ops rzg2l_adc_pm_ops = {

drivers/iio/adc/rzg2l_adc.c +3 -3
-       SET_RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
-                          rzg2l_adc_pm_runtime_resume,
-                          NULL)
+       RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
+                      rzg2l_adc_pm_runtime_resume,
+                      NULL)
 };  
Quoted 2 lines

DEFINE_RUNTIME_DEV_PM_OPS() ?

Disagreeing with the patch description argument on why I didn't do that? The extra ops set will never have anything to do... Mostly harmless, but kind of gives the wrong impression of what is going on in this driver.

Jonathan

#3 lore raw
Quoted 25 lines · Jonathan Cameron
Quoted 23 lines · On Mon, 8 Aug 2022 11:34:23 +0200 Andy Shevchenko <[email protected]>…
Quoted 9 lines · Jonathan Cameron

Here we could use DEFINE_RUNTIME_DEV_PM_OPS() but that would have the side effect of providing suspend and resume support. That would be harmless but also of little purpose as this driver does very simplistic power management with synchronous power up and down around individual channel reads.

In general these new PM macros avoid the need to mark functions __maybe_unused, whilst still allowing the compiler to remove them if they are unused.

...

Quoted 8 lines

static const struct dev_pm_ops rzg2l_adc_pm_ops = {

drivers/iio/adc/rzg2l_adc.c +3 -3
-       SET_RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
-                          rzg2l_adc_pm_runtime_resume,
-                          NULL)
+       RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
+                      rzg2l_adc_pm_runtime_resume,
+                      NULL)
 };
Quoted 6 lines
Quoted 2 lines

DEFINE_RUNTIME_DEV_PM_OPS() ?

Disagreeing with the patch description argument on why I didn't do that? The extra ops set will never have anything to do... Mostly harmless, but kind of gives the wrong impression of what is going on in this driver.

As per thread with Paul, this patch has no function change intentions, but also, if tested on hardware, enabling system sleep states shouldn't be harmful.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#4 lore raw
Quoted 28 lines · On Sun, 14 Aug 2022 22:12:59 +0300 Andy Shevchenko <[email protected]>…
Quoted 27 lines · Jonathan Cameron
Quoted 25 lines · On Mon, 8 Aug 2022 11:34:23 +0200 Andy Shevchenko <[email protected]>…
Quoted 9 lines · Jonathan Cameron

Here we could use DEFINE_RUNTIME_DEV_PM_OPS() but that would have the side effect of providing suspend and resume support. That would be harmless but also of little purpose as this driver does very simplistic power management with synchronous power up and down around individual channel reads.

In general these new PM macros avoid the need to mark functions __maybe_unused, whilst still allowing the compiler to remove them if they are unused.

...

drivers/iio/adc/rzg2l_adc.c static int __maybe_unused rzg2l_adc_pm_runtime_resume(struct device *dev) · line 587

Quoted 8 lines

static const struct dev_pm_ops rzg2l_adc_pm_ops = {

drivers/iio/adc/rzg2l_adc.c +3 -3
-       SET_RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
-                          rzg2l_adc_pm_runtime_resume,
-                          NULL)
+       RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
+                      rzg2l_adc_pm_runtime_resume,
+                      NULL)
 };  

DEFINE_RUNTIME_DEV_PM_OPS() ?

Quoted 9 lines
Quoted 4 lines

Disagreeing with the patch description argument on why I didn't do that? The extra ops set will never have anything to do... Mostly harmless, but kind of gives the wrong impression of what is going on in this driver.

As per thread with Paul, this patch has no function change intentions, but also, if tested on hardware, enabling system sleep states shouldn't be harmful.

This one is different from that case where there might be side effects. Here the suspend and resume are (I think) guaranteed to have nothing to do in all cases - because the driver does synchronous power up and power down in all paths. So in all cases we are already in runtime suspended state on a call to suspend.

Joanthan

author maintainer
#5 lore raw
In reply to Jonathan Cameron
Quoted 8 lines · On Sun, 7 Aug 2022 20:07:12 +0100 Jonathan Cameron <[email protected]> wrote:

From: Jonathan Cameron <[email protected]>

Here we could use DEFINE_RUNTIME_DEV_PM_OPS() but that would have the side effect of providing suspend and resume support. That would be harmless but also of little purpose as this driver does very simplistic power management with synchronous power up and down around individual channel reads.

Quoted 7 lines

In general these new PM macros avoid the need to mark functions __maybe_unused, whilst still allowing the compiler to remove them if they are unused.

Cc Biju Das <[email protected]>
Cc Geert Uytterhoeven <[email protected]>

+CC Prabhakar on basis of recent DT binding patch might have hardware
to test changing this to DEFINE_RUNTIME_DEV_PM_OPS.

If not I'm tempted to just pick this one up on basis it does no harm and we can revisit later.

Thanks,

Jonathan

Quoted 48 lines
---
 drivers/iio/adc/rzg2l_adc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/iio/adc/rzg2l_adc.c +6 -6
index 0921ff2d9b3a..b859a2db6b13 100644
@@ -547,7 +547,7 @@ static const struct of_device_id rzg2l_adc_match[] = {
 };
 MODULE_DEVICE_TABLE(of, rzg2l_adc_match);
 
-static int __maybe_unused rzg2l_adc_pm_runtime_suspend(struct device *dev)
+static int rzg2l_adc_pm_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct rzg2l_adc *adc = iio_priv(indio_dev);
@@ -559,7 +559,7 @@ static int __maybe_unused rzg2l_adc_pm_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused rzg2l_adc_pm_runtime_resume(struct device *dev)
+static int rzg2l_adc_pm_runtime_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct rzg2l_adc *adc = iio_priv(indio_dev);
@@ -581,9 +581,9 @@ static int __maybe_unused rzg2l_adc_pm_runtime_resume(struct device *dev)
 }
 
 static const struct dev_pm_ops rzg2l_adc_pm_ops = {
-	SET_RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
-			   rzg2l_adc_pm_runtime_resume,
-			   NULL)
+	RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend,
+		       rzg2l_adc_pm_runtime_resume,
+		       NULL)
 };
 
 static struct platform_driver rzg2l_adc_driver = {
@@ -591,7 +591,7 @@ static struct platform_driver rzg2l_adc_driver = {
 	.driver		= {
 		.name		= DRIVER_NAME,
 		.of_match_table = rzg2l_adc_match,
-		.pm		= &rzg2l_adc_pm_ops,
+		.pm		= pm_ptr(&rzg2l_adc_pm_ops),
 	},
 };