All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org
Cc: Paul Cercueil <paul@crapouillou.net>,
	Arnd Bergmann <arnd@arndb.de>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Fabrice Gasnier <fabrice.gasnier@foss.st.com>,
	Olivier Moysan <olivier.moysan@foss.st.com>
Subject: [PATCH v3 44/50] iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr()
Date: Sun, 30 Jan 2022 19:31:41 +0000	[thread overview]
Message-ID: <20220130193147.279148-45-jic23@kernel.org> (raw)
In-Reply-To: <20220130193147.279148-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM support is simpler and less error prone than the
use of #ifdef based config guards.

Removing instances of this approach from IIO also stops them being
copied into new drivers.

The new DEFINE_RUNTIME_DEV_PM_OPS() macro reduces boilerplate.

Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Olivier Moysan <olivier.moysan@foss.st.com>
---
 drivers/iio/adc/stm32-adc-core.c | 17 ++++++-----------
 drivers/iio/adc/stm32-adc.c      | 12 ++++--------
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
index b6e18eb101f7..142656232157 100644
--- a/drivers/iio/adc/stm32-adc-core.c
+++ b/drivers/iio/adc/stm32-adc-core.c
@@ -763,7 +763,6 @@ static int stm32_adc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#if defined(CONFIG_PM)
 static int stm32_adc_core_runtime_suspend(struct device *dev)
 {
 	stm32_adc_core_hw_stop(dev);
@@ -782,15 +781,11 @@ static int stm32_adc_core_runtime_idle(struct device *dev)
 
 	return 0;
 }
-#endif
-
-static const struct dev_pm_ops stm32_adc_core_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(stm32_adc_core_runtime_suspend,
-			   stm32_adc_core_runtime_resume,
-			   stm32_adc_core_runtime_idle)
-};
+
+static DEFINE_RUNTIME_DEV_PM_OPS(stm32_adc_core_pm_ops,
+				stm32_adc_core_runtime_suspend,
+				stm32_adc_core_runtime_resume,
+				stm32_adc_core_runtime_idle);
 
 static const struct stm32_adc_priv_cfg stm32f4_adc_priv_cfg = {
 	.regs = &stm32f4_adc_common_regs,
@@ -836,7 +831,7 @@ static struct platform_driver stm32_adc_driver = {
 	.driver = {
 		.name = "stm32-adc-core",
 		.of_match_table = stm32_adc_of_match,
-		.pm = &stm32_adc_core_pm_ops,
+		.pm = pm_ptr(&stm32_adc_core_pm_ops),
 	},
 };
 module_platform_driver(stm32_adc_driver);
diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index 897166d9e45c..a68ecbda6480 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -2352,7 +2352,6 @@ static int stm32_adc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#if defined(CONFIG_PM_SLEEP)
 static int stm32_adc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -2382,9 +2381,7 @@ static int stm32_adc_resume(struct device *dev)
 
 	return stm32_adc_buffer_postenable(indio_dev);
 }
-#endif
 
-#if defined(CONFIG_PM)
 static int stm32_adc_runtime_suspend(struct device *dev)
 {
 	return stm32_adc_hw_stop(dev);
@@ -2394,12 +2391,11 @@ static int stm32_adc_runtime_resume(struct device *dev)
 {
 	return stm32_adc_hw_start(dev);
 }
-#endif
 
 static const struct dev_pm_ops stm32_adc_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(stm32_adc_suspend, stm32_adc_resume)
-	SET_RUNTIME_PM_OPS(stm32_adc_runtime_suspend, stm32_adc_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(stm32_adc_suspend, stm32_adc_resume)
+	RUNTIME_PM_OPS(stm32_adc_runtime_suspend, stm32_adc_runtime_resume,
+		       NULL)
 };
 
 static const struct stm32_adc_cfg stm32f4_adc_cfg = {
@@ -2453,7 +2449,7 @@ static struct platform_driver stm32_adc_driver = {
 	.driver = {
 		.name = "stm32-adc",
 		.of_match_table = stm32_adc_of_match,
-		.pm = &stm32_adc_pm_ops,
+		.pm = pm_ptr(&stm32_adc_pm_ops),
 	},
 };
 module_platform_driver(stm32_adc_driver);
-- 
2.35.1


  parent reply	other threads:[~2022-01-30 19:27 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-30 19:30 [PATCH v3 00/50] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
2022-01-30 19:30 ` [PATCH v3 01/50] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-30 19:30 ` [PATCH v3 02/50] iio:accel:da280: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 03/50] iio:accel:dmard06: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 04/50] iio:accel:dmard10: Switch from CONFIG_PM " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 05/50] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 06/50] iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 07/50] iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 08/50] iio:accel:mma9553: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 09/50] iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 10/50] iio:adc:at91-adc: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 11/50] iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 12/50] iio:adc:palmas_gpadc: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 13/50] iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 14/50] iio:adc:twl6030: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 15/50] iio:adc:vf610: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 16/50] iio:common:ssp: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 17/50] iio:dac:vf610: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 18/50] iio:light:apds9300: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 19/50] iio:light:cm3232: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 20/50] iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 21/50] iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 22/50] iio:light:jsa1212: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 23/50] iio:light:ltr501: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 24/50] iio:light:stk3310: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 25/50] iio:light:tcs3414: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 26/50] iio:light:tcs3472: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 27/50] iio:light:tsl2563: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 28/50] iio:light:tsl4531: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 29/50] iio:magn:ak8975: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 30/50] iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 31/50] iio:magn:mmc35240: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 32/50] iio:pressure:mpl3115: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 33/50] iio:proximity:as3935: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 34/50] iio:proximity:rfd77492: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 35/50] iio:proximity:sx9500: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 36/50] iio:temperature:tmp006: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 37/50] iio:temperature:tmp007: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 38/50] iio:accel:stk8312: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 39/50] iio:accel:bma180: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 40/50] iio:dac:m62332: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 41/50] iio:imu:kmx61: Switch from CONFIG_PM* guards to pm_ptr() etc Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 42/50] iio:temperature:mlx90614: " Jonathan Cameron
2022-01-31 13:16   ` Crt Mori
2022-01-30 19:31 ` [PATCH v3 43/50] iio:adc:ab8500: Switch from CONFIG_PM " Jonathan Cameron
2022-02-21 19:36   ` Jonathan Cameron
2022-01-30 19:31 ` Jonathan Cameron [this message]
2022-01-30 19:31 ` [PATCH v3 45/50] iio:adc:rcar: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 46/50] iio:light:bh1780: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 47/50] iio:proximity:pulsedlight: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 48/50] iio:chemical:atlas: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 49/50] iio:light:rpr0521: " Jonathan Cameron
2022-01-30 19:31 ` [PATCH v3 50/50] iio:adc:stm32*: Use pm[_sleep]_ptr() etc to avoid need to make pm __maybe_unused Jonathan Cameron
2022-02-09 14:04   ` Fabrice Gasnier
2022-01-31 13:33 ` [PATCH v3 00/50] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Arnd Bergmann
2022-02-09 11:41 ` Paul Cercueil
2022-02-18 11:47   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220130193147.279148-45-jic23@kernel.org \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=arnd@arndb.de \
    --cc=fabrice.gasnier@foss.st.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=olivier.moysan@foss.st.com \
    --cc=paul@crapouillou.net \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.