All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc.
@ 2022-01-02 12:55 Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
                   ` (50 more replies)
  0 siblings, 51 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Alexandre Belloni,
	Anson Huang, Brian Masney, Crt Mori, Fabrice Gasnier,
	Hans de Goede, Heiko Stuebner, Icenowy Zheng, Jonathan Albrieux,
	Krzysztof Kozlowski, Linus Walleij, Luca Weiss,
	Ludovic Desroches, Manivannan Sadhasivam, Martijn Braam,
	Maslov Dmitry, Mikko Koivunen, Olivier Moysan,
	Stefan-Gabriel Mirea, Vaishnav M A

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

Previously "iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc."

Note I've kept tags given for v1 having concluded the changes were fairly
minor, but if anyone wants me to drop a tag let me know (it was a bit
borderline in my view).

I have a follow up series to convert the existing cases that looked like the
results of the v1 version of this series but will sit on that until this
has had some review given this set is already rather too large.  For those
I'll probably do some groupings rather than one patch per file.

In the discussion of v1 Paul proposed a change to how pm_ptr() and
related macros are defined to remove the need to mark the various
functions as __maybe_unused.  That culminated in the patch:

https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/commit/?id=1a3c7bb088266fa2db017be299f91f1c1894c857

which is currently queued up by Rafael in the linux-pm tree for the
merge window.  This series depends on that patch.

So the main changes since v1:

* Drop all the __maybe_unused markings
* Switch from SIMPLE_DEV_PM_OPS() to DEFINE_SIMPLE_DEV_PM_OPS()
* Switch from SET_RUNTIME_PM_OPS() to RUNTIME_PM_OPS()
* Switch from SET_SYSTEM_SLEEP_PM_OPS() to SYSTEM_SLEEP_PM_OPS()
* Use pm_sleep_ptr() with DEFINE_SIMPLE_DEV_PM_OPS() cases
* Use pm_ptr() with al other cases
* Drop patches change cases where the dev_pm_ops structure is exported
  to other modules as the compiler can't remove those cases automatically
  and more thought is needed.
* Add some additional drivers that I'd missed on the first round.

Note this does not cover all cases of CONFIG_PM* in IIO as some are
considerably more complicated and this approach may not be suitable.

Overall motivation for the series remains the same as for V1:
* Code reduction and improvement in readability.
* Reduce the chance I'll have to ask people to change how they do
  this in future drivers (cut and paste fun)

Note that in some cases letting the compiler remove the code results
in small reductions in module size, particularly when CONFIG_PM_SLEEP
is not defined.

I've kept this at one patch per driver as personally I prefer to
do this for all but most trivial of patches as it makes backports that
cross with this series simpler (though they will now require the
dependency called out above). It also avoids the complexity of tagging
when people wish to call out the subset they have reviewed.

Note there are drivers in here where the author has probably moved
onto other things, so if people have time to review patches in addition
to those I've explicitly cc'd them on that would be great!

Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Anson Huang <anson.huang@nxp.com>
Cc: Brian Masney <masneyb@onstation.org>
Cc: Crt Mori <cmo@melexis.com>
Cc: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
Cc: Icenowy Zheng <icenowy@aosc.io>
Cc: Jonathan Albrieux <jonathan.albrieux@gmail.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Luca Weiss <luca@z3ntu.xyz>
Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>
Cc: Martijn Braam <martijn@brixit.nl>
Cc: Maslov Dmitry <maslovdmitry@seeed.cc>
Cc: Matt Ranostay <matt.ranostay@konsulko.com
Cc: Mikko Koivunen <mikko.koivunen@fi.rohmeurope.com>
Cc: Olivier Moysan <olivier.moysan@foss.st.com>
Cc: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
Cc: Vaishnav M A <vaishnav@beagleboard.org>

Jonathan Cameron (51):
  iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:accel:da280: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:accel:dmard06: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:accel:dmard10: Switch from CONFIG_PM guards to pm_sleep_ptr() etc
  iio:accel:mc3230: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr()
  iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() etc
  iio:accel:mma9553: Switch from CONFIG_PM guards to pm_ptr() etc
  iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc
  iio:adc:ab8500: Switch from CONFIG_PM guards to pm_ptr() etc
  iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr()
  iio:adc:palmas_gpadc: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr()
  iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr()
  iio:adc:rcar: Switch from CONFIG_PM guards to pm_ptr() etc
  iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:adc:twl6030: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:adc:vf610: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:common:ssp: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:dac:vf610: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:light:apds9300: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() etc
  iio:light:cm3232: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr()
  iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:light:jsa1212: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:light:ltr501: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:light:stk3310: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:light:tcs3414: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:light:tcs3472: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:light:tsl2563: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:light:tsl4531: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() etc
  iio:magn:ak8975: Switch from CONFIG_PM guards to pm_ptr() etc
  iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:magn:mmc35240: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:pressure:mpl3115: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr()
    etc
  iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:proximity:sx9500: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:temperature:tmp006: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:temperature:tmp007: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() etc
  iio:accel:stk8312: Switch from CONFIG_PM_SLEEP guards to
    pm_sleep_ptr() etc
  iio:accel:bma180: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:dac:m62332: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
    etc
  iio:imu:kmx61: Switch from CONFIG_PM* guards to pm_ptr() etc
  iio:light:rpr0521: Switch from CONFIG_PM guards to pm_ptr() etc
  iio:temperature:mlx90614: Switch from CONFIG_PM* guards to pm_ptr()
    etc

 drivers/iio/accel/bma180.c                        |  9 ++-------
 drivers/iio/accel/da280.c                         |  6 ++----
 drivers/iio/accel/da311.c                         |  6 ++----
 drivers/iio/accel/dmard06.c                       | 10 +++-------
 drivers/iio/accel/dmard10.c                       |  7 +++----
 drivers/iio/accel/kxsd9-i2c.c                     |  2 +-
 drivers/iio/accel/kxsd9-spi.c                     |  2 +-
 drivers/iio/accel/kxsd9.c                         |  8 ++------
 drivers/iio/accel/mc3230.c                        |  6 ++----
 drivers/iio/accel/mma7660.c                       | 10 ++--------
 drivers/iio/accel/mma9551.c                       | 11 +++--------
 drivers/iio/accel/mma9553.c                       | 11 +++--------
 drivers/iio/accel/stk8312.c                       | 10 ++--------
 drivers/iio/accel/stk8ba50.c                      | 10 ++--------
 drivers/iio/adc/ab8500-gpadc.c                    | 12 ++++--------
 drivers/iio/adc/at91_adc.c                        |  6 ++----
 drivers/iio/adc/exynos_adc.c                      | 10 ++++------
 drivers/iio/adc/palmas_gpadc.c                    | 10 +++-------
 drivers/iio/adc/rcar-gyroadc.c                    |  6 ++----
 drivers/iio/adc/rockchip_saradc.c                 |  6 ++----
 drivers/iio/adc/stm32-adc-core.c                  | 13 +++++--------
 drivers/iio/adc/stm32-adc.c                       | 12 ++++--------
 drivers/iio/adc/twl6030-gpadc.c                   |  8 +++-----
 drivers/iio/adc/vf610_adc.c                       |  6 ++----
 drivers/iio/chemical/atlas-sensor.c               |  7 ++-----
 drivers/iio/common/ssp_sensors/ssp_dev.c          |  8 ++------
 drivers/iio/dac/m62332.c                          |  9 ++-------
 drivers/iio/dac/vf610_dac.c                       |  6 ++----
 drivers/iio/imu/kmx61.c                           | 10 +++-------
 drivers/iio/light/apds9300.c                      |  9 ++-------
 drivers/iio/light/bh1780.c                        | 10 +++-------
 drivers/iio/light/cm3232.c                        |  9 ++-------
 drivers/iio/light/isl29018.c                      |  9 ++-------
 drivers/iio/light/isl29125.c                      |  6 ++----
 drivers/iio/light/jsa1212.c                       | 10 ++--------
 drivers/iio/light/ltr501.c                        |  6 ++----
 drivers/iio/light/rpr0521.c                       |  7 ++-----
 drivers/iio/light/stk3310.c                       | 10 ++--------
 drivers/iio/light/tcs3414.c                       |  6 ++----
 drivers/iio/light/tcs3472.c                       |  6 ++----
 drivers/iio/light/tsl2563.c                       |  9 ++-------
 drivers/iio/light/tsl4531.c                       |  9 ++-------
 drivers/iio/light/us5182d.c                       |  8 +++-----
 drivers/iio/magnetometer/ak8975.c                 | 10 +++-------
 drivers/iio/magnetometer/mag3110.c                |  9 ++-------
 drivers/iio/magnetometer/mmc35240.c               |  8 ++------
 drivers/iio/pressure/mpl3115.c                    |  9 ++-------
 drivers/iio/proximity/as3935.c                    | 10 ++--------
 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c |  7 ++-----
 drivers/iio/proximity/rfd77402.c                  |  6 ++----
 drivers/iio/proximity/sx9500.c                    |  8 ++------
 drivers/iio/temperature/mlx90614.c                | 12 ++++--------
 drivers/iio/temperature/tmp006.c                  |  6 ++----
 drivers/iio/temperature/tmp007.c                  |  6 ++----
 54 files changed, 127 insertions(+), 315 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 14:15   ` Arnd Bergmann
  2022-01-02 12:55 ` [PATCH v2 02/51] iio:accel:da280: " Jonathan Cameron
                   ` (49 subsequent siblings)
  50 siblings, 1 reply; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/da311.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/da311.c b/drivers/iio/accel/da311.c
index 04e13487e706..a239ec5b5089 100644
--- a/drivers/iio/accel/da311.c
+++ b/drivers/iio/accel/da311.c
@@ -256,7 +256,6 @@ static int da311_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int da311_suspend(struct device *dev)
 {
 	return da311_enable(to_i2c_client(dev), false);
@@ -266,9 +265,8 @@ static int da311_resume(struct device *dev)
 {
 	return da311_enable(to_i2c_client(dev), true);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(da311_pm_ops, da311_suspend, da311_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(da311_pm_ops, da311_suspend, da311_resume);
 
 static const struct i2c_device_id da311_i2c_id[] = {
 	{"da311", 0},
@@ -279,7 +277,7 @@ MODULE_DEVICE_TABLE(i2c, da311_i2c_id);
 static struct i2c_driver da311_driver = {
 	.driver = {
 		.name = "da311",
-		.pm = &da311_pm_ops,
+		.pm = pm_sleep_ptr(&da311_pm_ops),
 	},
 	.probe		= da311_probe,
 	.id_table	= da311_i2c_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 02/51] iio:accel:da280: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 03/51] iio:accel:dmard06: " Jonathan Cameron
                   ` (48 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/da280.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/da280.c b/drivers/iio/accel/da280.c
index 9633bdae5fd4..10fdaaa54c40 100644
--- a/drivers/iio/accel/da280.c
+++ b/drivers/iio/accel/da280.c
@@ -153,7 +153,6 @@ static int da280_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int da280_suspend(struct device *dev)
 {
 	return da280_enable(to_i2c_client(dev), false);
@@ -163,9 +162,8 @@ static int da280_resume(struct device *dev)
 {
 	return da280_enable(to_i2c_client(dev), true);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(da280_pm_ops, da280_suspend, da280_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(da280_pm_ops, da280_suspend, da280_resume);
 
 static const struct acpi_device_id da280_acpi_match[] = {
 	{"MIRAACC", da280},
@@ -184,7 +182,7 @@ static struct i2c_driver da280_driver = {
 	.driver = {
 		.name = "da280",
 		.acpi_match_table = ACPI_PTR(da280_acpi_match),
-		.pm = &da280_pm_ops,
+		.pm = pm_sleep_ptr(&da280_pm_ops),
 	},
 	.probe		= da280_probe,
 	.id_table	= da280_i2c_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 03/51] iio:accel:dmard06: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 02/51] iio:accel:da280: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 04/51] iio:accel:dmard10: Switch from CONFIG_PM " Jonathan Cameron
                   ` (47 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/dmard06.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/accel/dmard06.c b/drivers/iio/accel/dmard06.c
index de2868c28d95..ab9cd6a5369b 100644
--- a/drivers/iio/accel/dmard06.c
+++ b/drivers/iio/accel/dmard06.c
@@ -7,6 +7,7 @@
 
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/compiler.h>
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
 
@@ -170,7 +171,6 @@ static int dmard06_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int dmard06_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -199,11 +199,7 @@ static int dmard06_resume(struct device *dev)
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(dmard06_pm_ops, dmard06_suspend, dmard06_resume);
-#define DMARD06_PM_OPS (&dmard06_pm_ops)
-#else
-#define DMARD06_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(dmard06_pm_ops, dmard06_suspend, dmard06_resume);
 
 static const struct i2c_device_id dmard06_id[] = {
 	{ "dmard05", 0 },
@@ -227,7 +223,7 @@ static struct i2c_driver dmard06_driver = {
 	.driver = {
 		.name = DMARD06_DRV_NAME,
 		.of_match_table = dmard06_of_match,
-		.pm = DMARD06_PM_OPS,
+		.pm = pm_sleep_ptr(&dmard06_pm_ops),
 	},
 };
 module_i2c_driver(dmard06_driver);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 04/51] iio:accel:dmard10: Switch from CONFIG_PM guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (2 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 03/51] iio:accel:dmard06: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 05/51] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
                   ` (46 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/dmard10.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/dmard10.c b/drivers/iio/accel/dmard10.c
index f9f173eec202..bef21aa2aeb5 100644
--- a/drivers/iio/accel/dmard10.c
+++ b/drivers/iio/accel/dmard10.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/compiler.h>
 #include <linux/i2c.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -218,7 +219,6 @@ static int dmard10_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int dmard10_suspend(struct device *dev)
 {
 	return dmard10_shutdown(to_i2c_client(dev));
@@ -228,9 +228,8 @@ static int dmard10_resume(struct device *dev)
 {
 	return dmard10_reset(to_i2c_client(dev));
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(dmard10_pm_ops, dmard10_suspend, dmard10_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(dmard10_pm_ops, dmard10_suspend, dmard10_resume);
 
 static const struct i2c_device_id dmard10_i2c_id[] = {
 	{"dmard10", 0},
@@ -241,7 +240,7 @@ MODULE_DEVICE_TABLE(i2c, dmard10_i2c_id);
 static struct i2c_driver dmard10_driver = {
 	.driver = {
 		.name = "dmard10",
-		.pm = &dmard10_pm_ops,
+		.pm = pm_sleep_ptr(&dmard10_pm_ops),
 	},
 	.probe		= dmard10_probe,
 	.id_table	= dmard10_i2c_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 05/51] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (3 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 04/51] iio:accel:dmard10: Switch from CONFIG_PM " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 06/51] iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
                   ` (45 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Hans de Goede

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/iio/accel/mc3230.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c
index 735002b716f3..09647706756a 100644
--- a/drivers/iio/accel/mc3230.c
+++ b/drivers/iio/accel/mc3230.c
@@ -160,7 +160,6 @@ static int mc3230_remove(struct i2c_client *client)
 	return mc3230_set_opcon(iio_priv(indio_dev), MC3230_MODE_OPCON_STANDBY);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int mc3230_suspend(struct device *dev)
 {
 	struct mc3230_data *data;
@@ -178,9 +177,8 @@ static int mc3230_resume(struct device *dev)
 
 	return mc3230_set_opcon(data, MC3230_MODE_OPCON_WAKE);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(mc3230_pm_ops, mc3230_suspend, mc3230_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(mc3230_pm_ops, mc3230_suspend, mc3230_resume);
 
 static const struct i2c_device_id mc3230_i2c_id[] = {
 	{"mc3230", 0},
@@ -191,7 +189,7 @@ MODULE_DEVICE_TABLE(i2c, mc3230_i2c_id);
 static struct i2c_driver mc3230_driver = {
 	.driver = {
 		.name = "mc3230",
-		.pm = &mc3230_pm_ops,
+		.pm = pm_sleep_ptr(&mc3230_pm_ops),
 	},
 	.probe		= mc3230_probe,
 	.remove		= mc3230_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 06/51] iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (4 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 05/51] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 07/51] iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
                   ` (44 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/mma7660.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/accel/mma7660.c b/drivers/iio/accel/mma7660.c
index 24b83ccdb950..0dec40ca4fd4 100644
--- a/drivers/iio/accel/mma7660.c
+++ b/drivers/iio/accel/mma7660.c
@@ -222,7 +222,6 @@ static int mma7660_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int mma7660_suspend(struct device *dev)
 {
 	struct mma7660_data *data;
@@ -241,12 +240,7 @@ static int mma7660_resume(struct device *dev)
 	return mma7660_set_mode(data, MMA7660_MODE_ACTIVE);
 }
 
-static SIMPLE_DEV_PM_OPS(mma7660_pm_ops, mma7660_suspend, mma7660_resume);
-
-#define MMA7660_PM_OPS (&mma7660_pm_ops)
-#else
-#define MMA7660_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(mma7660_pm_ops, mma7660_suspend, mma7660_resume);
 
 static const struct i2c_device_id mma7660_i2c_id[] = {
 	{"mma7660", 0},
@@ -270,7 +264,7 @@ MODULE_DEVICE_TABLE(acpi, mma7660_acpi_id);
 static struct i2c_driver mma7660_driver = {
 	.driver = {
 		.name = "mma7660",
-		.pm = MMA7660_PM_OPS,
+		.pm = pm_sleep_ptr(&mma7660_pm_ops),
 		.of_match_table = mma7660_of_match,
 		.acpi_match_table = ACPI_PTR(mma7660_acpi_id),
 	},
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 07/51] iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (5 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 06/51] iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 08/51] iio:accel:mma9553: " Jonathan Cameron
                   ` (43 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/mma9551.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c
index 4c359fb05480..fb9c8fac5911 100644
--- a/drivers/iio/accel/mma9551.c
+++ b/drivers/iio/accel/mma9551.c
@@ -523,7 +523,6 @@ static int mma9551_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int mma9551_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -555,9 +554,7 @@ static int mma9551_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-#ifdef CONFIG_PM_SLEEP
 static int mma9551_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -583,12 +580,10 @@ static int mma9551_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
 static const struct dev_pm_ops mma9551_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(mma9551_suspend, mma9551_resume)
-	SET_RUNTIME_PM_OPS(mma9551_runtime_suspend,
-			   mma9551_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(mma9551_suspend, mma9551_resume)
+	RUNTIME_PM_OPS(mma9551_runtime_suspend, mma9551_runtime_resume, NULL)
 };
 
 static const struct acpi_device_id mma9551_acpi_match[] = {
@@ -609,7 +604,7 @@ static struct i2c_driver mma9551_driver = {
 	.driver = {
 		   .name = MMA9551_DRV_NAME,
 		   .acpi_match_table = ACPI_PTR(mma9551_acpi_match),
-		   .pm = &mma9551_pm_ops,
+		   .pm = pm_ptr(&mma9551_pm_ops),
 		   },
 	.probe = mma9551_probe,
 	.remove = mma9551_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 08/51] iio:accel:mma9553: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (6 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 07/51] iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 09/51] iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
                   ` (42 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/mma9553.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c
index 0570ab1cc064..673e5c4beefe 100644
--- a/drivers/iio/accel/mma9553.c
+++ b/drivers/iio/accel/mma9553.c
@@ -1162,7 +1162,6 @@ static int mma9553_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int mma9553_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -1194,9 +1193,7 @@ static int mma9553_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-#ifdef CONFIG_PM_SLEEP
 static int mma9553_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -1222,12 +1219,10 @@ static int mma9553_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
 static const struct dev_pm_ops mma9553_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(mma9553_suspend, mma9553_resume)
-	SET_RUNTIME_PM_OPS(mma9553_runtime_suspend,
-			   mma9553_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(mma9553_suspend, mma9553_resume)
+	RUNTIME_PM_OPS(mma9553_runtime_suspend, mma9553_runtime_resume, NULL)
 };
 
 static const struct acpi_device_id mma9553_acpi_match[] = {
@@ -1248,7 +1243,7 @@ static struct i2c_driver mma9553_driver = {
 	.driver = {
 		   .name = MMA9553_DRV_NAME,
 		   .acpi_match_table = ACPI_PTR(mma9553_acpi_match),
-		   .pm = &mma9553_pm_ops,
+		   .pm = pm_ptr(&mma9553_pm_ops),
 		   },
 	.probe = mma9553_probe,
 	.remove = mma9553_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 09/51] iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (7 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 08/51] iio:accel:mma9553: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 10/51] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
                   ` (41 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/stk8ba50.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
index 517c57ed9e94..0c86cefbe2e2 100644
--- a/drivers/iio/accel/stk8ba50.c
+++ b/drivers/iio/accel/stk8ba50.c
@@ -504,7 +504,6 @@ static int stk8ba50_remove(struct i2c_client *client)
 	return stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int stk8ba50_suspend(struct device *dev)
 {
 	struct stk8ba50_data *data;
@@ -523,12 +522,7 @@ static int stk8ba50_resume(struct device *dev)
 	return stk8ba50_set_power(data, STK8BA50_MODE_NORMAL);
 }
 
-static SIMPLE_DEV_PM_OPS(stk8ba50_pm_ops, stk8ba50_suspend, stk8ba50_resume);
-
-#define STK8BA50_PM_OPS (&stk8ba50_pm_ops)
-#else
-#define STK8BA50_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(stk8ba50_pm_ops, stk8ba50_suspend, stk8ba50_resume);
 
 static const struct i2c_device_id stk8ba50_i2c_id[] = {
 	{"stk8ba50", 0},
@@ -546,7 +540,7 @@ MODULE_DEVICE_TABLE(acpi, stk8ba50_acpi_id);
 static struct i2c_driver stk8ba50_driver = {
 	.driver = {
 		.name = "stk8ba50",
-		.pm = STK8BA50_PM_OPS,
+		.pm = pm_sleep_ptr(&stk8ba50_pm_ops),
 		.acpi_match_table = ACPI_PTR(stk8ba50_acpi_id),
 	},
 	.probe =            stk8ba50_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 10/51] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (8 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 09/51] iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-30 19:08   ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 11/51] iio:adc:ab8500: " Jonathan Cameron
                   ` (40 subsequent siblings)
  50 siblings, 1 reply; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/kxsd9-i2c.c | 2 +-
 drivers/iio/accel/kxsd9-spi.c | 2 +-
 drivers/iio/accel/kxsd9.c     | 8 ++------
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
index 274b41a6e603..ffe8066b4025 100644
--- a/drivers/iio/accel/kxsd9-i2c.c
+++ b/drivers/iio/accel/kxsd9-i2c.c
@@ -55,7 +55,7 @@ static struct i2c_driver kxsd9_i2c_driver = {
 	.driver = {
 		.name	= "kxsd9",
 		.of_match_table = kxsd9_of_match,
-		.pm = &kxsd9_dev_pm_ops,
+		.pm = pm_ptr(&kxsd9_dev_pm_ops),
 	},
 	.probe		= kxsd9_i2c_probe,
 	.remove		= kxsd9_i2c_remove,
diff --git a/drivers/iio/accel/kxsd9-spi.c b/drivers/iio/accel/kxsd9-spi.c
index 441e6b764281..44edf39fc5ff 100644
--- a/drivers/iio/accel/kxsd9-spi.c
+++ b/drivers/iio/accel/kxsd9-spi.c
@@ -54,7 +54,7 @@ MODULE_DEVICE_TABLE(of, kxsd9_of_match);
 static struct spi_driver kxsd9_spi_driver = {
 	.driver = {
 		.name = "kxsd9",
-		.pm = &kxsd9_dev_pm_ops,
+		.pm = pm_ptr(&kxsd9_dev_pm_ops),
 		.of_match_table = kxsd9_of_match,
 	},
 	.probe = kxsd9_spi_probe,
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index 552eba5e8b4f..39059ddca441 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -492,7 +492,6 @@ void kxsd9_common_remove(struct device *dev)
 }
 EXPORT_SYMBOL(kxsd9_common_remove);
 
-#ifdef CONFIG_PM
 static int kxsd9_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -508,13 +507,10 @@ static int kxsd9_runtime_resume(struct device *dev)
 
 	return kxsd9_power_up(st);
 }
-#endif /* CONFIG_PM */
 
 const struct dev_pm_ops kxsd9_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(kxsd9_runtime_suspend,
-			   kxsd9_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(kxsd9_runtime_suspend, kxsd9_runtime_resume, NULL)
 };
 EXPORT_SYMBOL(kxsd9_dev_pm_ops);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 11/51] iio:adc:ab8500: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (9 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 10/51] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 12/51] iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
                   ` (39 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Linus Walleij

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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/adc/ab8500-gpadc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/ab8500-gpadc.c b/drivers/iio/adc/ab8500-gpadc.c
index 4c46a201d4ef..e0b19e8221eb 100644
--- a/drivers/iio/adc/ab8500-gpadc.c
+++ b/drivers/iio/adc/ab8500-gpadc.c
@@ -942,7 +942,6 @@ static const struct iio_info ab8500_gpadc_info = {
 	.read_raw = ab8500_gpadc_read_raw,
 };
 
-#ifdef CONFIG_PM
 static int ab8500_gpadc_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -965,7 +964,6 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
 /**
  * ab8500_gpadc_parse_channel() - process devicetree channel configuration
@@ -1200,11 +1198,9 @@ static int ab8500_gpadc_remove(struct platform_device *pdev)
 }
 
 static const struct dev_pm_ops ab8500_gpadc_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(ab8500_gpadc_runtime_suspend,
-			   ab8500_gpadc_runtime_resume,
-			   NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(ab8500_gpadc_runtime_suspend,
+		       ab8500_gpadc_runtime_resume, NULL)
 };
 
 static struct platform_driver ab8500_gpadc_driver = {
@@ -1212,7 +1208,7 @@ static struct platform_driver ab8500_gpadc_driver = {
 	.remove = ab8500_gpadc_remove,
 	.driver = {
 		.name = "ab8500-gpadc",
-		.pm = &ab8500_gpadc_pm_ops,
+		.pm = pm_ptr(&ab8500_gpadc_pm_ops),
 	},
 };
 builtin_platform_driver(ab8500_gpadc_driver);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 12/51] iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (10 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 11/51] iio:adc:ab8500: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 13/51] iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
                   ` (38 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Alexandre Belloni,
	Ludovic Desroches

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
---
 drivers/iio/adc/at91_adc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 5a7d3a3a5fa8..4ec1586ea0a0 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -1234,7 +1234,6 @@ static int at91_adc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int at91_adc_suspend(struct device *dev)
 {
 	struct iio_dev *idev = dev_get_drvdata(dev);
@@ -1256,9 +1255,8 @@ static int at91_adc_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume);
 
 static const struct at91_adc_trigger at91sam9260_triggers[] = {
 	{ .name = "timer-counter-0", .value = 0x1 },
@@ -1386,7 +1384,7 @@ static struct platform_driver at91_adc_driver = {
 	.driver = {
 		   .name = DRIVER_NAME,
 		   .of_match_table = at91_adc_dt_ids,
-		   .pm = &at91_adc_pm_ops,
+		   .pm = pm_sleep_ptr(&at91_adc_pm_ops),
 	},
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 13/51] iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (11 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 12/51] iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 14/51] iio:adc:palmas_gpadc: " Jonathan Cameron
                   ` (37 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Krzysztof Kozlowski

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/exynos_adc.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 3b3868aa2533..166a6436e36f 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -968,7 +968,6 @@ static int exynos_adc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int exynos_adc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -1001,11 +1000,10 @@ static int exynos_adc_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(exynos_adc_pm_ops,
-			exynos_adc_suspend,
-			exynos_adc_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(exynos_adc_pm_ops,
+			 exynos_adc_suspend,
+			 exynos_adc_resume);
 
 static struct platform_driver exynos_adc_driver = {
 	.probe		= exynos_adc_probe,
@@ -1013,7 +1011,7 @@ static struct platform_driver exynos_adc_driver = {
 	.driver		= {
 		.name	= "exynos-adc",
 		.of_match_table = exynos_adc_match,
-		.pm	= &exynos_adc_pm_ops,
+		.pm	= pm_sleep_ptr(&exynos_adc_pm_ops),
 	},
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 14/51] iio:adc:palmas_gpadc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (12 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 13/51] iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 15/51] iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr() Jonathan Cameron
                   ` (36 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

In this case SIMPLE_DEV_PM_OPS() could have been used previously.
Now we have DEFINE_SIMPLE_DEV_PM_OPS() which also deals with letting
the compiler remove the structure and functions so use that instead.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/palmas_gpadc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
index f9c8385c72d3..a8febe487b2b 100644
--- a/drivers/iio/adc/palmas_gpadc.c
+++ b/drivers/iio/adc/palmas_gpadc.c
@@ -653,7 +653,6 @@ static int palmas_gpadc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int palmas_adc_wakeup_configure(struct palmas_gpadc *adc)
 {
 	int adc_period, conv;
@@ -822,12 +821,9 @@ static int palmas_gpadc_resume(struct device *dev)
 
 	return 0;
 };
-#endif
 
-static const struct dev_pm_ops palmas_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(palmas_gpadc_suspend,
-				palmas_gpadc_resume)
-};
+DEFINE_SIMPLE_DEV_PM_OPS(palmas_pm_ops, palmas_gpadc_suspend,
+			 palmas_gpadc_resume);
 
 static const struct of_device_id of_palmas_gpadc_match_tbl[] = {
 	{ .compatible = "ti,palmas-gpadc", },
@@ -840,7 +836,7 @@ static struct platform_driver palmas_gpadc_driver = {
 	.remove = palmas_gpadc_remove,
 	.driver = {
 		.name = MOD_NAME,
-		.pm = &palmas_pm_ops,
+		.pm = pm_sleep_ptr(&palmas_pm_ops),
 		.of_match_table = of_palmas_gpadc_match_tbl,
 	},
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 15/51] iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr()
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (13 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 14/51] iio:adc:palmas_gpadc: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 16/51] iio:adc:rcar: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
                   ` (35 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Fabrice Gasnier,
	Olivier Moysan

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.

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 | 13 +++++--------
 drivers/iio/adc/stm32-adc.c      | 12 ++++--------
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
index b6e18eb101f7..c506dd558958 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,14 +781,12 @@ 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)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_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 = {
@@ -836,7 +833,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.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 16/51] iio:adc:rcar: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (14 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 15/51] iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr() Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 17/51] iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
                   ` (34 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/rcar-gyroadc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
index 727ea6c68049..27d9e147b4b7 100644
--- a/drivers/iio/adc/rcar-gyroadc.c
+++ b/drivers/iio/adc/rcar-gyroadc.c
@@ -577,7 +577,6 @@ static int rcar_gyroadc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#if defined(CONFIG_PM)
 static int rcar_gyroadc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -597,10 +596,9 @@ static int rcar_gyroadc_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops rcar_gyroadc_pm_ops = {
-	SET_RUNTIME_PM_OPS(rcar_gyroadc_suspend, rcar_gyroadc_resume, NULL)
+	RUNTIME_PM_OPS(rcar_gyroadc_suspend, rcar_gyroadc_resume, NULL)
 };
 
 static struct platform_driver rcar_gyroadc_driver = {
@@ -609,7 +607,7 @@ static struct platform_driver rcar_gyroadc_driver = {
 	.driver         = {
 		.name		= DRIVER_NAME,
 		.of_match_table	= rcar_gyroadc_match,
-		.pm		= &rcar_gyroadc_pm_ops,
+		.pm		= pm_ptr(&rcar_gyroadc_pm_ops),
 	},
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 17/51] iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (15 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 16/51] iio:adc:rcar: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 18/51] iio:adc:twl6030: " Jonathan Cameron
                   ` (33 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Heiko Stuebner

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
---
 drivers/iio/adc/rockchip_saradc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
index 14b8df4ca9c8..62315df14873 100644
--- a/drivers/iio/adc/rockchip_saradc.c
+++ b/drivers/iio/adc/rockchip_saradc.c
@@ -481,7 +481,6 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
 	return devm_iio_device_register(&pdev->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int rockchip_saradc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -514,9 +513,8 @@ static int rockchip_saradc_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(rockchip_saradc_pm_ops,
+DEFINE_SIMPLE_DEV_PM_OPS(rockchip_saradc_pm_ops,
 			 rockchip_saradc_suspend, rockchip_saradc_resume);
 
 static struct platform_driver rockchip_saradc_driver = {
@@ -524,7 +522,7 @@ static struct platform_driver rockchip_saradc_driver = {
 	.driver		= {
 		.name	= "rockchip-saradc",
 		.of_match_table = rockchip_saradc_match,
-		.pm	= &rockchip_saradc_pm_ops,
+		.pm	= pm_sleep_ptr(&rockchip_saradc_pm_ops),
 	},
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 18/51] iio:adc:twl6030: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (16 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 17/51] iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 19/51] iio:adc:vf610: " Jonathan Cameron
                   ` (32 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/twl6030-gpadc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
index afdb59e0b526..a7cf41c82b46 100644
--- a/drivers/iio/adc/twl6030-gpadc.c
+++ b/drivers/iio/adc/twl6030-gpadc.c
@@ -944,7 +944,6 @@ static int twl6030_gpadc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int twl6030_gpadc_suspend(struct device *pdev)
 {
 	int ret;
@@ -968,17 +967,16 @@ static int twl6030_gpadc_resume(struct device *pdev)
 
 	return 0;
 };
-#endif
 
-static SIMPLE_DEV_PM_OPS(twl6030_gpadc_pm_ops, twl6030_gpadc_suspend,
-					twl6030_gpadc_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(twl6030_gpadc_pm_ops, twl6030_gpadc_suspend,
+			 twl6030_gpadc_resume);
 
 static struct platform_driver twl6030_gpadc_driver = {
 	.probe		= twl6030_gpadc_probe,
 	.remove		= twl6030_gpadc_remove,
 	.driver		= {
 		.name	= DRIVER_NAME,
-		.pm	= &twl6030_gpadc_pm_ops,
+		.pm	= pm_sleep_ptr(&twl6030_gpadc_pm_ops),
 		.of_match_table = of_twl6030_match_tbl,
 	},
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 19/51] iio:adc:vf610: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (17 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 18/51] iio:adc:twl6030: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 20/51] iio:common:ssp: " Jonathan Cameron
                   ` (31 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Stefan-Gabriel Mirea

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
---
 drivers/iio/adc/vf610_adc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index fd57fc43e8e5..6f10b265a481 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -912,7 +912,6 @@ static int vf610_adc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int vf610_adc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -952,9 +951,8 @@ static int vf610_adc_resume(struct device *dev)
 	regulator_disable(info->vref);
 	return ret;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(vf610_adc_pm_ops, vf610_adc_suspend, vf610_adc_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(vf610_adc_pm_ops, vf610_adc_suspend, vf610_adc_resume);
 
 static struct platform_driver vf610_adc_driver = {
 	.probe          = vf610_adc_probe,
@@ -962,7 +960,7 @@ static struct platform_driver vf610_adc_driver = {
 	.driver         = {
 		.name   = DRIVER_NAME,
 		.of_match_table = vf610_adc_match,
-		.pm     = &vf610_adc_pm_ops,
+		.pm     = pm_sleep_ptr(&vf610_adc_pm_ops),
 	},
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 20/51] iio:common:ssp: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (18 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 19/51] iio:adc:vf610: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 21/51] iio:dac:vf610: " Jonathan Cameron
                   ` (30 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP support is simpler and less error prone than the
use of ifdef based config guards.  Also switch to SIMPLE_DEV_PM_OPS
rather than open coding the structure.

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

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/common/ssp_sensors/ssp_dev.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/common/ssp_sensors/ssp_dev.c b/drivers/iio/common/ssp_sensors/ssp_dev.c
index 1aee87100038..d1aba8deff7f 100644
--- a/drivers/iio/common/ssp_sensors/ssp_dev.c
+++ b/drivers/iio/common/ssp_sensors/ssp_dev.c
@@ -612,7 +612,6 @@ static int ssp_remove(struct spi_device *spi)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int ssp_suspend(struct device *dev)
 {
 	int ret;
@@ -661,17 +660,14 @@ static int ssp_resume(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM_SLEEP */
 
-static const struct dev_pm_ops ssp_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(ssp_suspend, ssp_resume)
-};
+DEFINE_SIMPLE_DEV_PM_OPS(ssp_pm_ops, ssp_suspend, ssp_resume);
 
 static struct spi_driver ssp_driver = {
 	.probe = ssp_probe,
 	.remove = ssp_remove,
 	.driver = {
-		.pm = &ssp_pm_ops,
+		.pm = pm_sleep_ptr(&ssp_pm_ops),
 		.of_match_table = of_match_ptr(ssp_of_match),
 		.name = "sensorhub"
 	},
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 21/51] iio:dac:vf610: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (19 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 20/51] iio:common:ssp: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 22/51] iio:light:apds9300: " Jonathan Cameron
                   ` (29 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/dac/vf610_dac.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c
index 636b4009f763..8f937d1b3c56 100644
--- a/drivers/iio/dac/vf610_dac.c
+++ b/drivers/iio/dac/vf610_dac.c
@@ -242,7 +242,6 @@ static int vf610_dac_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int vf610_dac_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -268,9 +267,8 @@ static int vf610_dac_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(vf610_dac_pm_ops, vf610_dac_suspend, vf610_dac_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(vf610_dac_pm_ops, vf610_dac_suspend, vf610_dac_resume);
 
 static struct platform_driver vf610_dac_driver = {
 	.probe          = vf610_dac_probe,
@@ -278,7 +276,7 @@ static struct platform_driver vf610_dac_driver = {
 	.driver         = {
 		.name   = "vf610-dac",
 		.of_match_table = vf610_dac_match,
-		.pm     = &vf610_dac_pm_ops,
+		.pm     = pm_sleep_ptr(&vf610_dac_pm_ops),
 	},
 };
 module_platform_driver(vf610_dac_driver);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 22/51] iio:light:apds9300: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (20 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 21/51] iio:dac:vf610: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 23/51] iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
                   ` (28 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/apds9300.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/light/apds9300.c b/drivers/iio/light/apds9300.c
index baaf202dce05..b1e36e0954de 100644
--- a/drivers/iio/light/apds9300.c
+++ b/drivers/iio/light/apds9300.c
@@ -466,7 +466,6 @@ static int apds9300_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int apds9300_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -493,11 +492,7 @@ static int apds9300_resume(struct device *dev)
 	return ret;
 }
 
-static SIMPLE_DEV_PM_OPS(apds9300_pm_ops, apds9300_suspend, apds9300_resume);
-#define APDS9300_PM_OPS (&apds9300_pm_ops)
-#else
-#define APDS9300_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(apds9300_pm_ops, apds9300_suspend, apds9300_resume);
 
 static const struct i2c_device_id apds9300_id[] = {
 	{ APDS9300_DRV_NAME, 0 },
@@ -509,7 +504,7 @@ MODULE_DEVICE_TABLE(i2c, apds9300_id);
 static struct i2c_driver apds9300_driver = {
 	.driver = {
 		.name	= APDS9300_DRV_NAME,
-		.pm	= APDS9300_PM_OPS,
+		.pm	= pm_sleep_ptr(&apds9300_pm_ops),
 	},
 	.probe		= apds9300_probe,
 	.remove		= apds9300_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 23/51] iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (21 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 22/51] iio:light:apds9300: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 24/51] iio:light:cm3232: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
                   ` (27 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Linus Walleij

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.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/bh1780.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c
index abbf2e662e7d..e30f0bb4e6ca 100644
--- a/drivers/iio/light/bh1780.c
+++ b/drivers/iio/light/bh1780.c
@@ -221,7 +221,6 @@ static int bh1780_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int bh1780_runtime_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -256,13 +255,10 @@ static int bh1780_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM */
 
 static const struct dev_pm_ops bh1780_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(bh1780_runtime_suspend,
-			   bh1780_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(bh1780_runtime_suspend, bh1780_runtime_resume, NULL)
 };
 
 static const struct i2c_device_id bh1780_id[] = {
@@ -284,7 +280,7 @@ static struct i2c_driver bh1780_driver = {
 	.id_table	= bh1780_id,
 	.driver = {
 		.name = "bh1780",
-		.pm = &bh1780_dev_pm_ops,
+		.pm = pm_ptr(&bh1780_dev_pm_ops),
 		.of_match_table = of_bh1780_match,
 	},
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 24/51] iio:light:cm3232: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (22 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 23/51] iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 25/51] iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
                   ` (26 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP support is simpler and less error prone than the
use of #ifdef based config guards.  Also switch to SIMPLE_DEV_PM_OPS rather
than opencoding the same.

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

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/cm3232.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c
index 18a410340dc5..122130f1a683 100644
--- a/drivers/iio/light/cm3232.c
+++ b/drivers/iio/light/cm3232.c
@@ -374,7 +374,6 @@ static const struct i2c_device_id cm3232_id[] = {
 	{}
 };
 
-#ifdef CONFIG_PM_SLEEP
 static int cm3232_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -403,9 +402,7 @@ static int cm3232_resume(struct device *dev)
 	return ret;
 }
 
-static const struct dev_pm_ops cm3232_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(cm3232_suspend, cm3232_resume)};
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(cm3232_pm_ops, cm3232_suspend, cm3232_resume);
 
 MODULE_DEVICE_TABLE(i2c, cm3232_id);
 
@@ -419,9 +416,7 @@ static struct i2c_driver cm3232_driver = {
 	.driver = {
 		.name	= "cm3232",
 		.of_match_table = cm3232_of_match,
-#ifdef CONFIG_PM_SLEEP
-		.pm	= &cm3232_pm_ops,
-#endif
+		.pm	= pm_sleep_ptr(&cm3232_pm_ops),
 	},
 	.id_table	= cm3232_id,
 	.probe		= cm3232_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 25/51] iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr()
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (23 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 24/51] iio:light:cm3232: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 26/51] iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
                   ` (25 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Anson Huang, Brian Masney

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Anson Huang <anson.huang@nxp.com>
Cc: Brian Masney <masneyb@onstation.org>
---
 drivers/iio/light/isl29018.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
index 2689867467a8..55d068940e9f 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -784,7 +784,6 @@ static int isl29018_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int isl29018_suspend(struct device *dev)
 {
 	struct isl29018_chip *chip = iio_priv(dev_get_drvdata(dev));
@@ -830,11 +829,7 @@ static int isl29018_resume(struct device *dev)
 	return err;
 }
 
-static SIMPLE_DEV_PM_OPS(isl29018_pm_ops, isl29018_suspend, isl29018_resume);
-#define ISL29018_PM_OPS (&isl29018_pm_ops)
-#else
-#define ISL29018_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(isl29018_pm_ops, isl29018_suspend, isl29018_resume);
 
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id isl29018_acpi_match[] = {
@@ -866,7 +861,7 @@ static struct i2c_driver isl29018_driver = {
 	.driver	 = {
 			.name = "isl29018",
 			.acpi_match_table = ACPI_PTR(isl29018_acpi_match),
-			.pm = ISL29018_PM_OPS,
+			.pm = pm_sleep_ptr(&isl29018_pm_ops),
 			.of_match_table = isl29018_of_match,
 		    },
 	.probe	 = isl29018_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 26/51] iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (24 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 25/51] iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 27/51] iio:light:jsa1212: " Jonathan Cameron
                   ` (24 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/isl29125.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
index ba53b50d711a..756015b5cfd6 100644
--- a/drivers/iio/light/isl29125.c
+++ b/drivers/iio/light/isl29125.c
@@ -311,7 +311,6 @@ static int isl29125_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int isl29125_suspend(struct device *dev)
 {
 	struct isl29125_data *data = iio_priv(i2c_get_clientdata(
@@ -326,9 +325,8 @@ static int isl29125_resume(struct device *dev)
 	return i2c_smbus_write_byte_data(data->client, ISL29125_CONF1,
 		data->conf1);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(isl29125_pm_ops, isl29125_suspend, isl29125_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(isl29125_pm_ops, isl29125_suspend, isl29125_resume);
 
 static const struct i2c_device_id isl29125_id[] = {
 	{ "isl29125", 0 },
@@ -339,7 +337,7 @@ MODULE_DEVICE_TABLE(i2c, isl29125_id);
 static struct i2c_driver isl29125_driver = {
 	.driver = {
 		.name	= ISL29125_DRV_NAME,
-		.pm	= &isl29125_pm_ops,
+		.pm	= pm_sleep_ptr(&isl29125_pm_ops),
 	},
 	.probe		= isl29125_probe,
 	.remove		= isl29125_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 27/51] iio:light:jsa1212: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (25 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 26/51] iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 28/51] iio:light:ltr501: " Jonathan Cameron
                   ` (23 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/jsa1212.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/light/jsa1212.c b/drivers/iio/light/jsa1212.c
index 724a0ec9f35c..4bf899337384 100644
--- a/drivers/iio/light/jsa1212.c
+++ b/drivers/iio/light/jsa1212.c
@@ -383,7 +383,6 @@ static int jsa1212_remove(struct i2c_client *client)
 	return jsa1212_power_off(data);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int jsa1212_suspend(struct device *dev)
 {
 	struct jsa1212_data *data;
@@ -421,12 +420,7 @@ static int jsa1212_resume(struct device *dev)
 	return ret;
 }
 
-static SIMPLE_DEV_PM_OPS(jsa1212_pm_ops, jsa1212_suspend, jsa1212_resume);
-
-#define JSA1212_PM_OPS (&jsa1212_pm_ops)
-#else
-#define JSA1212_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(jsa1212_pm_ops, jsa1212_suspend, jsa1212_resume);
 
 static const struct acpi_device_id jsa1212_acpi_match[] = {
 	{"JSA1212", 0},
@@ -443,7 +437,7 @@ MODULE_DEVICE_TABLE(i2c, jsa1212_id);
 static struct i2c_driver jsa1212_driver = {
 	.driver = {
 		.name	= JSA1212_DRIVER_NAME,
-		.pm	= JSA1212_PM_OPS,
+		.pm	= pm_sleep_ptr(&jsa1212_pm_ops),
 		.acpi_match_table = ACPI_PTR(jsa1212_acpi_match),
 	},
 	.probe		= jsa1212_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 28/51] iio:light:ltr501: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (26 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 27/51] iio:light:jsa1212: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 29/51] iio:light:stk3310: " Jonathan Cameron
                   ` (22 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Maslov Dmitry

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Maslov Dmitry <maslovdmitry@seeed.cc>
---
 drivers/iio/light/ltr501.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 47d61ec2bb50..08d03101653f 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -1611,7 +1611,6 @@ static int ltr501_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int ltr501_suspend(struct device *dev)
 {
 	struct ltr501_data *data = iio_priv(i2c_get_clientdata(
@@ -1627,9 +1626,8 @@ static int ltr501_resume(struct device *dev)
 	return ltr501_write_contr(data, data->als_contr,
 		data->ps_contr);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resume);
 
 static const struct acpi_device_id ltr_acpi_match[] = {
 	{"LTER0501", ltr501},
@@ -1661,7 +1659,7 @@ static struct i2c_driver ltr501_driver = {
 	.driver = {
 		.name   = LTR501_DRV_NAME,
 		.of_match_table = ltr501_of_match,
-		.pm	= &ltr501_pm_ops,
+		.pm	= pm_sleep_ptr(&ltr501_pm_ops),
 		.acpi_match_table = ACPI_PTR(ltr_acpi_match),
 	},
 	.probe  = ltr501_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 29/51] iio:light:stk3310: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (27 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 28/51] iio:light:ltr501: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 30/51] iio:light:tcs3414: " Jonathan Cameron
                   ` (21 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Icenowy Zheng, Luca Weiss,
	Martijn Braam

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Icenowy Zheng <icenowy@aosc.io>
Cc: Luca Weiss <luca@z3ntu.xyz>
Cc: Martijn Braam <martijn@brixit.nl>
---
 drivers/iio/light/stk3310.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index fc63856ed54d..36f8227ac800 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -632,7 +632,6 @@ static int stk3310_remove(struct i2c_client *client)
 	return stk3310_set_state(iio_priv(indio_dev), STK3310_STATE_STANDBY);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int stk3310_suspend(struct device *dev)
 {
 	struct stk3310_data *data;
@@ -656,12 +655,7 @@ static int stk3310_resume(struct device *dev)
 	return stk3310_set_state(data, state);
 }
 
-static SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk3310_suspend, stk3310_resume);
-
-#define STK3310_PM_OPS (&stk3310_pm_ops)
-#else
-#define STK3310_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk3310_suspend, stk3310_resume);
 
 static const struct i2c_device_id stk3310_i2c_id[] = {
 	{"STK3310", 0},
@@ -692,7 +686,7 @@ static struct i2c_driver stk3310_driver = {
 	.driver = {
 		.name = "stk3310",
 		.of_match_table = stk3310_of_match,
-		.pm = STK3310_PM_OPS,
+		.pm = pm_sleep_ptr(&stk3310_pm_ops),
 		.acpi_match_table = ACPI_PTR(stk3310_acpi_id),
 	},
 	.probe =            stk3310_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 30/51] iio:light:tcs3414: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (28 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 29/51] iio:light:stk3310: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 31/51] iio:light:tcs3472: " Jonathan Cameron
                   ` (20 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/tcs3414.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/light/tcs3414.c b/drivers/iio/light/tcs3414.c
index b87222141429..3e0944c3e36f 100644
--- a/drivers/iio/light/tcs3414.c
+++ b/drivers/iio/light/tcs3414.c
@@ -345,7 +345,6 @@ static int tcs3414_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int tcs3414_suspend(struct device *dev)
 {
 	struct tcs3414_data *data = iio_priv(i2c_get_clientdata(
@@ -360,9 +359,8 @@ static int tcs3414_resume(struct device *dev)
 	return i2c_smbus_write_byte_data(data->client, TCS3414_CONTROL,
 		data->control);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(tcs3414_pm_ops, tcs3414_suspend, tcs3414_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(tcs3414_pm_ops, tcs3414_suspend, tcs3414_resume);
 
 static const struct i2c_device_id tcs3414_id[] = {
 	{ "tcs3414", 0 },
@@ -373,7 +371,7 @@ MODULE_DEVICE_TABLE(i2c, tcs3414_id);
 static struct i2c_driver tcs3414_driver = {
 	.driver = {
 		.name	= TCS3414_DRV_NAME,
-		.pm	= &tcs3414_pm_ops,
+		.pm	= pm_sleep_ptr(&tcs3414_pm_ops),
 	},
 	.probe		= tcs3414_probe,
 	.id_table	= tcs3414_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 31/51] iio:light:tcs3472: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (29 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 30/51] iio:light:tcs3414: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 32/51] iio:light:tsl2563: " Jonathan Cameron
                   ` (19 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/tcs3472.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
index 371c6a39a165..a886b1cd11ce 100644
--- a/drivers/iio/light/tcs3472.c
+++ b/drivers/iio/light/tcs3472.c
@@ -572,7 +572,6 @@ static int tcs3472_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int tcs3472_suspend(struct device *dev)
 {
 	struct tcs3472_data *data = iio_priv(i2c_get_clientdata(
@@ -598,9 +597,8 @@ static int tcs3472_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(tcs3472_pm_ops, tcs3472_suspend, tcs3472_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(tcs3472_pm_ops, tcs3472_suspend, tcs3472_resume);
 
 static const struct i2c_device_id tcs3472_id[] = {
 	{ "tcs3472", 0 },
@@ -611,7 +609,7 @@ MODULE_DEVICE_TABLE(i2c, tcs3472_id);
 static struct i2c_driver tcs3472_driver = {
 	.driver = {
 		.name	= TCS3472_DRV_NAME,
-		.pm	= &tcs3472_pm_ops,
+		.pm	= pm_sleep_ptr(&tcs3472_pm_ops),
 	},
 	.probe		= tcs3472_probe,
 	.remove		= tcs3472_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 32/51] iio:light:tsl2563: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (30 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 31/51] iio:light:tcs3472: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:55 ` [PATCH v2 33/51] iio:light:tsl4531: " Jonathan Cameron
                   ` (18 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Vaishnav M A

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Vaishnav M A <vaishnav@beagleboard.org>
---
 drivers/iio/light/tsl2563.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
index 5bf2bfbc5379..f3ad3158b199 100644
--- a/drivers/iio/light/tsl2563.c
+++ b/drivers/iio/light/tsl2563.c
@@ -814,7 +814,6 @@ static int tsl2563_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int tsl2563_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -857,11 +856,7 @@ static int tsl2563_resume(struct device *dev)
 	return ret;
 }
 
-static SIMPLE_DEV_PM_OPS(tsl2563_pm_ops, tsl2563_suspend, tsl2563_resume);
-#define TSL2563_PM_OPS (&tsl2563_pm_ops)
-#else
-#define TSL2563_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(tsl2563_pm_ops, tsl2563_suspend, tsl2563_resume);
 
 static const struct i2c_device_id tsl2563_id[] = {
 	{ "tsl2560", 0 },
@@ -885,7 +880,7 @@ static struct i2c_driver tsl2563_i2c_driver = {
 	.driver = {
 		.name	 = "tsl2563",
 		.of_match_table = tsl2563_of_match,
-		.pm	= TSL2563_PM_OPS,
+		.pm	= pm_sleep_ptr(&tsl2563_pm_ops),
 	},
 	.probe		= tsl2563_probe,
 	.remove		= tsl2563_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 33/51] iio:light:tsl4531: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (31 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 32/51] iio:light:tsl2563: " Jonathan Cameron
@ 2022-01-02 12:55 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 34/51] iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
                   ` (17 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:55 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/tsl4531.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c
index 70505ba6d858..637ae1a765fb 100644
--- a/drivers/iio/light/tsl4531.c
+++ b/drivers/iio/light/tsl4531.c
@@ -215,7 +215,6 @@ static int tsl4531_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int tsl4531_suspend(struct device *dev)
 {
 	return tsl4531_powerdown(to_i2c_client(dev));
@@ -227,11 +226,7 @@ static int tsl4531_resume(struct device *dev)
 		TSL4531_MODE_NORMAL);
 }
 
-static SIMPLE_DEV_PM_OPS(tsl4531_pm_ops, tsl4531_suspend, tsl4531_resume);
-#define TSL4531_PM_OPS (&tsl4531_pm_ops)
-#else
-#define TSL4531_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(tsl4531_pm_ops, tsl4531_suspend, tsl4531_resume);
 
 static const struct i2c_device_id tsl4531_id[] = {
 	{ "tsl4531", 0 },
@@ -242,7 +237,7 @@ MODULE_DEVICE_TABLE(i2c, tsl4531_id);
 static struct i2c_driver tsl4531_driver = {
 	.driver = {
 		.name   = TSL4531_DRV_NAME,
-		.pm	= TSL4531_PM_OPS,
+		.pm	= pm_sleep_ptr(&tsl4531_pm_ops),
 	},
 	.probe  = tsl4531_probe,
 	.remove = tsl4531_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 34/51] iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (32 preceding siblings ...)
  2022-01-02 12:55 ` [PATCH v2 33/51] iio:light:tsl4531: " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-30 19:12   ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 35/51] iio:magn:ak8975: " Jonathan Cameron
                   ` (16 subsequent siblings)
  50 siblings, 1 reply; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/light/us5182d.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c
index 96e4a66ddf28..fdabf601d15e 100644
--- a/drivers/iio/light/us5182d.c
+++ b/drivers/iio/light/us5182d.c
@@ -916,7 +916,6 @@ static int us5182d_remove(struct i2c_client *client)
 	return us5182d_shutdown_en(data, US5182D_CFG0_SHUTDOWN_EN);
 }
 
-#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM)
 static int us5182d_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -939,11 +938,10 @@ static int us5182d_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops us5182d_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(us5182d_suspend, us5182d_resume)
-	SET_RUNTIME_PM_OPS(us5182d_suspend, us5182d_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(us5182d_suspend, us5182d_resume)
+	RUNTIME_PM_OPS(us5182d_suspend, us5182d_resume, NULL)
 };
 
 static const struct acpi_device_id us5182d_acpi_match[] = {
@@ -969,7 +967,7 @@ MODULE_DEVICE_TABLE(of, us5182d_of_match);
 static struct i2c_driver us5182d_driver = {
 	.driver = {
 		.name = US5182D_DRV_NAME,
-		.pm = &us5182d_pm_ops,
+		.pm = pm_ptr(&us5182d_pm_ops),
 		.of_match_table = us5182d_of_match,
 		.acpi_match_table = ACPI_PTR(us5182d_acpi_match),
 	},
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 35/51] iio:magn:ak8975: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (33 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 34/51] iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 36/51] iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
                   ` (15 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Matt Ranostay,
	Jonathan Albrieux, Linus Walleij

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.

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jonathan Albrieux <jonathan.albrieux@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/magnetometer/ak8975.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 55879a20ae52..103d2f751c9f 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -1033,7 +1033,6 @@ static int ak8975_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int ak8975_runtime_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -1074,13 +1073,10 @@ static int ak8975_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM */
 
 static const struct dev_pm_ops ak8975_dev_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(ak8975_runtime_suspend,
-			   ak8975_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	RUNTIME_PM_OPS(ak8975_runtime_suspend, ak8975_runtime_resume, NULL)
 };
 
 static const struct i2c_device_id ak8975_id[] = {
@@ -1113,7 +1109,7 @@ MODULE_DEVICE_TABLE(of, ak8975_of_match);
 static struct i2c_driver ak8975_driver = {
 	.driver = {
 		.name	= "ak8975",
-		.pm = &ak8975_dev_pm_ops,
+		.pm = pm_ptr(&ak8975_dev_pm_ops),
 		.of_match_table = ak8975_of_match,
 		.acpi_match_table = ak_acpi_match,
 	},
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 36/51] iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (34 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 35/51] iio:magn:ak8975: " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 37/51] iio:magn:mmc35240: " Jonathan Cameron
                   ` (14 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/magnetometer/mag3110.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c
index 17c62d806218..7d4b87da29ef 100644
--- a/drivers/iio/magnetometer/mag3110.c
+++ b/drivers/iio/magnetometer/mag3110.c
@@ -573,7 +573,6 @@ static int mag3110_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int mag3110_suspend(struct device *dev)
 {
 	struct mag3110_data *data = iio_priv(i2c_get_clientdata(
@@ -623,11 +622,7 @@ static int mag3110_resume(struct device *dev)
 		data->ctrl_reg1);
 }
 
-static SIMPLE_DEV_PM_OPS(mag3110_pm_ops, mag3110_suspend, mag3110_resume);
-#define MAG3110_PM_OPS (&mag3110_pm_ops)
-#else
-#define MAG3110_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(mag3110_pm_ops, mag3110_suspend, mag3110_resume);
 
 static const struct i2c_device_id mag3110_id[] = {
 	{ "mag3110", 0 },
@@ -645,7 +640,7 @@ static struct i2c_driver mag3110_driver = {
 	.driver = {
 		.name	= "mag3110",
 		.of_match_table = mag3110_of_match,
-		.pm	= MAG3110_PM_OPS,
+		.pm	= pm_sleep_ptr(&mag3110_pm_ops),
 	},
 	.probe = mag3110_probe,
 	.remove = mag3110_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 37/51] iio:magn:mmc35240: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (35 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 36/51] iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 38/51] iio:pressure:mpl3115: " Jonathan Cameron
                   ` (13 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP support is simpler and less error prone than the
use of #ifdef based config guards. Also use SIMPLE_DEV_PM_OPS instead
of open-coding the equivalent.

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

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/magnetometer/mmc35240.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
index 65f3d1ed0d59..97af02dc6245 100644
--- a/drivers/iio/magnetometer/mmc35240.c
+++ b/drivers/iio/magnetometer/mmc35240.c
@@ -521,7 +521,6 @@ static int mmc35240_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int mmc35240_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -548,11 +547,8 @@ static int mmc35240_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static const struct dev_pm_ops mmc35240_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(mmc35240_suspend, mmc35240_resume)
-};
+DEFINE_SIMPLE_DEV_PM_OPS(mmc35240_pm_ops, mmc35240_suspend, mmc35240_resume);
 
 static const struct of_device_id mmc35240_of_match[] = {
 	{ .compatible = "memsic,mmc35240", },
@@ -576,7 +572,7 @@ static struct i2c_driver mmc35240_driver = {
 	.driver = {
 		.name = MMC35240_DRV_NAME,
 		.of_match_table = mmc35240_of_match,
-		.pm = &mmc35240_pm_ops,
+		.pm = pm_sleep_ptr(&mmc35240_pm_ops),
 		.acpi_match_table = ACPI_PTR(mmc35240_acpi_match),
 	},
 	.probe		= mmc35240_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 38/51] iio:pressure:mpl3115: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (36 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 37/51] iio:magn:mmc35240: " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 39/51] iio:proximity:as3935: " Jonathan Cameron
                   ` (12 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/pressure/mpl3115.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c
index e95b9a5475b4..e118d3067228 100644
--- a/drivers/iio/pressure/mpl3115.c
+++ b/drivers/iio/pressure/mpl3115.c
@@ -301,7 +301,6 @@ static int mpl3115_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int mpl3115_suspend(struct device *dev)
 {
 	return mpl3115_standby(iio_priv(i2c_get_clientdata(
@@ -317,11 +316,7 @@ static int mpl3115_resume(struct device *dev)
 		data->ctrl_reg1);
 }
 
-static SIMPLE_DEV_PM_OPS(mpl3115_pm_ops, mpl3115_suspend, mpl3115_resume);
-#define MPL3115_PM_OPS (&mpl3115_pm_ops)
-#else
-#define MPL3115_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(mpl3115_pm_ops, mpl3115_suspend, mpl3115_resume);
 
 static const struct i2c_device_id mpl3115_id[] = {
 	{ "mpl3115", 0 },
@@ -339,7 +334,7 @@ static struct i2c_driver mpl3115_driver = {
 	.driver = {
 		.name	= "mpl3115",
 		.of_match_table = mpl3115_of_match,
-		.pm	= MPL3115_PM_OPS,
+		.pm	= pm_sleep_ptr(&mpl3115_pm_ops),
 	},
 	.probe = mpl3115_probe,
 	.remove = mpl3115_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 39/51] iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (37 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 38/51] iio:pressure:mpl3115: " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-04  6:41   ` Gwendal Grignou
  2022-01-02 12:56 ` [PATCH v2 40/51] iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
                   ` (11 subsequent siblings)
  50 siblings, 1 reply; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Matt Ranostay

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/proximity/as3935.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
index 51f4f92ae84a..5716048e228c 100644
--- a/drivers/iio/proximity/as3935.c
+++ b/drivers/iio/proximity/as3935.c
@@ -295,7 +295,6 @@ static void calibrate_as3935(struct as3935_state *st)
 	as3935_write(st, AS3935_NFLWDTH, st->nflwdth_reg);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int as3935_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -337,12 +336,7 @@ static int as3935_resume(struct device *dev)
 	return ret;
 }
 
-static SIMPLE_DEV_PM_OPS(as3935_pm_ops, as3935_suspend, as3935_resume);
-#define AS3935_PM_OPS (&as3935_pm_ops)
-
-#else
-#define AS3935_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(as3935_pm_ops, as3935_suspend, as3935_resume);
 
 static void as3935_stop_work(void *data)
 {
@@ -472,7 +466,7 @@ static struct spi_driver as3935_driver = {
 	.driver = {
 		.name	= "as3935",
 		.of_match_table = as3935_of_match,
-		.pm	= AS3935_PM_OPS,
+		.pm	= pm_sleep_ptr(&as3935_pm_ops),
 	},
 	.probe		= as3935_probe,
 	.id_table	= as3935_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 40/51] iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (38 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 39/51] iio:proximity:as3935: " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 41/51] iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
                   ` (10 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Matt Ranostay

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.

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
index 27026c060ab9..648ae576d6fa 100644
--- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
+++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
@@ -338,7 +338,6 @@ static const struct of_device_id lidar_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, lidar_dt_ids);
 
-#ifdef CONFIG_PM
 static int lidar_pm_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -358,18 +357,16 @@ static int lidar_pm_runtime_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
 static const struct dev_pm_ops lidar_pm_ops = {
-	SET_RUNTIME_PM_OPS(lidar_pm_runtime_suspend,
-			   lidar_pm_runtime_resume, NULL)
+	RUNTIME_PM_OPS(lidar_pm_runtime_suspend, lidar_pm_runtime_resume, NULL)
 };
 
 static struct i2c_driver lidar_driver = {
 	.driver = {
 		.name	= LIDAR_DRV_NAME,
 		.of_match_table	= lidar_dt_ids,
-		.pm	= &lidar_pm_ops,
+		.pm	= pm_ptr(&lidar_pm_ops),
 	},
 	.probe		= lidar_probe,
 	.remove		= lidar_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 41/51] iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (39 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 40/51] iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 42/51] iio:proximity:sx9500: " Jonathan Cameron
                   ` (9 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/proximity/rfd77402.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77402.c
index 8c06d02139b6..4f594d71f15d 100644
--- a/drivers/iio/proximity/rfd77402.c
+++ b/drivers/iio/proximity/rfd77402.c
@@ -295,7 +295,6 @@ static int rfd77402_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int rfd77402_suspend(struct device *dev)
 {
 	return rfd77402_powerdown(to_i2c_client(dev));
@@ -305,9 +304,8 @@ static int rfd77402_resume(struct device *dev)
 {
 	return rfd77402_init(to_i2c_client(dev));
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(rfd77402_pm_ops, rfd77402_suspend, rfd77402_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(rfd77402_pm_ops, rfd77402_suspend, rfd77402_resume);
 
 static const struct i2c_device_id rfd77402_id[] = {
 	{ "rfd77402", 0},
@@ -318,7 +316,7 @@ MODULE_DEVICE_TABLE(i2c, rfd77402_id);
 static struct i2c_driver rfd77402_driver = {
 	.driver = {
 		.name   = RFD77402_DRV_NAME,
-		.pm     = &rfd77402_pm_ops,
+		.pm     = pm_sleep_ptr(&rfd77402_pm_ops),
 	},
 	.probe  = rfd77402_probe,
 	.id_table = rfd77402_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 42/51] iio:proximity:sx9500: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (40 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 41/51] iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-03 18:58   ` Gwendal Grignou
  2022-01-02 12:56 ` [PATCH v2 43/51] iio:temperature:tmp006: " Jonathan Cameron
                   ` (8 subsequent siblings)
  50 siblings, 1 reply; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/proximity/sx9500.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 3e4ddb2e8c2b..01bfd748d820 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -993,7 +993,6 @@ static int sx9500_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sx9500_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -1030,11 +1029,8 @@ static int sx9500_resume(struct device *dev)
 
 	return ret;
 }
-#endif /* CONFIG_PM_SLEEP */
 
-static const struct dev_pm_ops sx9500_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sx9500_suspend, sx9500_resume)
-};
+DEFINE_SIMPLE_DEV_PM_OPS(sx9500_pm_ops, sx9500_suspend, sx9500_resume);
 
 static const struct acpi_device_id sx9500_acpi_match[] = {
 	{"SSX9500", 0},
@@ -1060,7 +1056,7 @@ static struct i2c_driver sx9500_driver = {
 		.name	= SX9500_DRIVER_NAME,
 		.acpi_match_table = ACPI_PTR(sx9500_acpi_match),
 		.of_match_table = of_match_ptr(sx9500_of_match),
-		.pm = &sx9500_pm_ops,
+		.pm = pm_sleep_ptr(&sx9500_pm_ops),
 	},
 	.probe		= sx9500_probe,
 	.remove		= sx9500_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 43/51] iio:temperature:tmp006: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (41 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 42/51] iio:proximity:sx9500: " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 44/51] iio:temperature:tmp007: " Jonathan Cameron
                   ` (7 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/temperature/tmp006.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c
index e4943a0bc9aa..bb72df22d63b 100644
--- a/drivers/iio/temperature/tmp006.c
+++ b/drivers/iio/temperature/tmp006.c
@@ -261,7 +261,6 @@ static int tmp006_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int tmp006_suspend(struct device *dev)
 {
 	return tmp006_power(dev, false);
@@ -271,9 +270,8 @@ static int tmp006_resume(struct device *dev)
 {
 	return tmp006_power(dev, true);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(tmp006_pm_ops, tmp006_suspend, tmp006_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(tmp006_pm_ops, tmp006_suspend, tmp006_resume);
 
 static const struct i2c_device_id tmp006_id[] = {
 	{ "tmp006", 0 },
@@ -284,7 +282,7 @@ MODULE_DEVICE_TABLE(i2c, tmp006_id);
 static struct i2c_driver tmp006_driver = {
 	.driver = {
 		.name	= "tmp006",
-		.pm	= &tmp006_pm_ops,
+		.pm	= pm_sleep_ptr(&tmp006_pm_ops),
 	},
 	.probe = tmp006_probe,
 	.id_table = tmp006_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 44/51] iio:temperature:tmp007: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (42 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 43/51] iio:temperature:tmp006: " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-03  6:03   ` Manivannan Sadhasivam
  2022-01-02 12:56 ` [PATCH v2 45/51] iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
                   ` (6 subsequent siblings)
  50 siblings, 1 reply; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Manivannan Sadhasivam

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>
---
 drivers/iio/temperature/tmp007.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/temperature/tmp007.c b/drivers/iio/temperature/tmp007.c
index b422371a4674..f7a040f0ee4c 100644
--- a/drivers/iio/temperature/tmp007.c
+++ b/drivers/iio/temperature/tmp007.c
@@ -537,7 +537,6 @@ static int tmp007_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int tmp007_suspend(struct device *dev)
 {
 	struct tmp007_data *data = iio_priv(i2c_get_clientdata(
@@ -554,9 +553,8 @@ static int tmp007_resume(struct device *dev)
 	return i2c_smbus_write_word_swapped(data->client, TMP007_CONFIG,
 			data->config | TMP007_CONFIG_CONV_EN);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(tmp007_pm_ops, tmp007_suspend, tmp007_resume);
+DEFINE_SIMPLE_DEV_PM_OPS(tmp007_pm_ops, tmp007_suspend, tmp007_resume);
 
 static const struct of_device_id tmp007_of_match[] = {
 	{ .compatible = "ti,tmp007", },
@@ -574,7 +572,7 @@ static struct i2c_driver tmp007_driver = {
 	.driver = {
 		.name	= "tmp007",
 		.of_match_table = tmp007_of_match,
-		.pm	= &tmp007_pm_ops,
+		.pm	= pm_sleep_ptr(&tmp007_pm_ops),
 	},
 	.probe		= tmp007_probe,
 	.id_table	= tmp007_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 45/51] iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (43 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 44/51] iio:temperature:tmp007: " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 46/51] iio:accel:stk8312: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
                   ` (5 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Matt Ranostay

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.

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/chemical/atlas-sensor.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
index 04b44a327614..c489d5593ba0 100644
--- a/drivers/iio/chemical/atlas-sensor.c
+++ b/drivers/iio/chemical/atlas-sensor.c
@@ -737,7 +737,6 @@ static int atlas_remove(struct i2c_client *client)
 	return atlas_set_powermode(data, 0);
 }
 
-#ifdef CONFIG_PM
 static int atlas_runtime_suspend(struct device *dev)
 {
 	struct atlas_data *data =
@@ -753,18 +752,16 @@ static int atlas_runtime_resume(struct device *dev)
 
 	return atlas_set_powermode(data, 1);
 }
-#endif
 
 static const struct dev_pm_ops atlas_pm_ops = {
-	SET_RUNTIME_PM_OPS(atlas_runtime_suspend,
-			   atlas_runtime_resume, NULL)
+	RUNTIME_PM_OPS(atlas_runtime_suspend, atlas_runtime_resume, NULL)
 };
 
 static struct i2c_driver atlas_driver = {
 	.driver = {
 		.name	= ATLAS_DRV_NAME,
 		.of_match_table	= atlas_dt_ids,
-		.pm	= &atlas_pm_ops,
+		.pm	= pm_ptr(&atlas_pm_ops),
 	},
 	.probe		= atlas_probe,
 	.remove		= atlas_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 46/51] iio:accel:stk8312: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (44 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 45/51] iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 47/51] iio:accel:bma180: " Jonathan Cameron
                   ` (4 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/stk8312.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
index de0cdf8c1f94..48d9090862e0 100644
--- a/drivers/iio/accel/stk8312.c
+++ b/drivers/iio/accel/stk8312.c
@@ -611,7 +611,6 @@ static int stk8312_remove(struct i2c_client *client)
 	return stk8312_set_mode(data, STK8312_MODE_STANDBY);
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int stk8312_suspend(struct device *dev)
 {
 	struct stk8312_data *data;
@@ -630,12 +629,7 @@ static int stk8312_resume(struct device *dev)
 	return stk8312_set_mode(data, data->mode | STK8312_MODE_ACTIVE);
 }
 
-static SIMPLE_DEV_PM_OPS(stk8312_pm_ops, stk8312_suspend, stk8312_resume);
-
-#define STK8312_PM_OPS (&stk8312_pm_ops)
-#else
-#define STK8312_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(stk8312_pm_ops, stk8312_suspend, stk8312_resume);
 
 static const struct i2c_device_id stk8312_i2c_id[] = {
 	/* Deprecated in favour of lowercase form */
@@ -648,7 +642,7 @@ MODULE_DEVICE_TABLE(i2c, stk8312_i2c_id);
 static struct i2c_driver stk8312_driver = {
 	.driver = {
 		.name = STK8312_DRIVER_NAME,
-		.pm = STK8312_PM_OPS,
+		.pm = pm_sleep_ptr(&stk8312_pm_ops),
 	},
 	.probe =            stk8312_probe,
 	.remove =           stk8312_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 47/51] iio:accel:bma180: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (45 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 46/51] iio:accel:stk8312: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 48/51] iio:dac:m62332: " Jonathan Cameron
                   ` (3 subsequent siblings)
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/accel/bma180.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index d8a454c266d5..4d99c61bec82 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -1065,7 +1065,6 @@ static int bma180_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int bma180_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -1092,11 +1091,7 @@ static int bma180_resume(struct device *dev)
 	return ret;
 }
 
-static SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume);
-#define BMA180_PM_OPS (&bma180_pm_ops)
-#else
-#define BMA180_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume);
 
 static const struct i2c_device_id bma180_ids[] = {
 	{ "bma023", BMA023 },
@@ -1137,7 +1132,7 @@ MODULE_DEVICE_TABLE(of, bma180_of_match);
 static struct i2c_driver bma180_driver = {
 	.driver = {
 		.name	= "bma180",
-		.pm	= BMA180_PM_OPS,
+		.pm	= pm_sleep_ptr(&bma180_pm_ops),
 		.of_match_table = bma180_of_match,
 	},
 	.probe		= bma180_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 48/51] iio:dac:m62332: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (46 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 47/51] iio:accel:bma180: " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-05 10:52   ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 49/51] iio:imu:kmx61: Switch from CONFIG_PM* guards to pm_ptr() etc Jonathan Cameron
                   ` (2 subsequent siblings)
  50 siblings, 1 reply; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/dac/m62332.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c
index 225b1a374dc1..4a413936fabb 100644
--- a/drivers/iio/dac/m62332.c
+++ b/drivers/iio/dac/m62332.c
@@ -124,7 +124,6 @@ static int m62332_write_raw(struct iio_dev *indio_dev,
 	return -EINVAL;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int m62332_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -156,11 +155,7 @@ static int m62332_resume(struct device *dev)
 	return m62332_set_value(indio_dev, data->save[1], 1);
 }
 
-static SIMPLE_DEV_PM_OPS(m62332_pm_ops, m62332_suspend, m62332_resume);
-#define M62332_PM_OPS (&m62332_pm_ops)
-#else
-#define M62332_PM_OPS NULL
-#endif
+DEFINE_SIMPLE_DEV_PM_OPS(m62332_pm_ops, m62332_suspend, m62332_resume);
 
 static const struct iio_info m62332_info = {
 	.read_raw = m62332_read_raw,
@@ -246,7 +241,7 @@ MODULE_DEVICE_TABLE(i2c, m62332_id);
 static struct i2c_driver m62332_driver = {
 	.driver = {
 		.name	= "m62332",
-		.pm	= M62332_PM_OPS,
+		.pm	= pm_sleep_ptr(&m62332_pm_ops),
 	},
 	.probe		= m62332_probe,
 	.remove		= m62332_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 49/51] iio:imu:kmx61: Switch from CONFIG_PM* guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (47 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 48/51] iio:dac:m62332: " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 50/51] iio:light:rpr0521: Switch from CONFIG_PM " Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 51/51] iio:temperature:mlx90614: Switch from CONFIG_PM* " Jonathan Cameron
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

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

Letting the compiler remove these functions when the kernel is built
without one or  more of CONFIG_PM/CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/imu/kmx61.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
index 1dabfd615dab..20ac1b4c8923 100644
--- a/drivers/iio/imu/kmx61.c
+++ b/drivers/iio/imu/kmx61.c
@@ -1440,7 +1440,6 @@ static int kmx61_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int kmx61_suspend(struct device *dev)
 {
 	int ret;
@@ -1466,9 +1465,7 @@ static int kmx61_resume(struct device *dev)
 
 	return kmx61_set_mode(data, stby, KMX61_ACC | KMX61_MAG, true);
 }
-#endif
 
-#ifdef CONFIG_PM
 static int kmx61_runtime_suspend(struct device *dev)
 {
 	struct kmx61_data *data = i2c_get_clientdata(to_i2c_client(dev));
@@ -1493,11 +1490,10 @@ static int kmx61_runtime_resume(struct device *dev)
 
 	return kmx61_set_mode(data, stby, KMX61_ACC | KMX61_MAG, true);
 }
-#endif
 
 static const struct dev_pm_ops kmx61_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(kmx61_suspend, kmx61_resume)
-	SET_RUNTIME_PM_OPS(kmx61_runtime_suspend, kmx61_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(kmx61_suspend, kmx61_resume)
+	RUNTIME_PM_OPS(kmx61_runtime_suspend, kmx61_runtime_resume, NULL)
 };
 
 static const struct acpi_device_id kmx61_acpi_match[] = {
@@ -1518,7 +1514,7 @@ static struct i2c_driver kmx61_driver = {
 	.driver = {
 		.name = KMX61_DRV_NAME,
 		.acpi_match_table = ACPI_PTR(kmx61_acpi_match),
-		.pm = &kmx61_pm_ops,
+		.pm = pm_ptr(&kmx61_pm_ops),
 	},
 	.probe		= kmx61_probe,
 	.remove		= kmx61_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 50/51] iio:light:rpr0521: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (48 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 49/51] iio:imu:kmx61: Switch from CONFIG_PM* guards to pm_ptr() etc Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  2022-01-02 12:56 ` [PATCH v2 51/51] iio:temperature:mlx90614: Switch from CONFIG_PM* " Jonathan Cameron
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Mikko Koivunen

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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Mikko Koivunen <mikko.koivunen@fi.rohmeurope.com>
---
 drivers/iio/light/rpr0521.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c
index c2dd8a3d4217..dabdd05f0e2c 100644
--- a/drivers/iio/light/rpr0521.c
+++ b/drivers/iio/light/rpr0521.c
@@ -1055,7 +1055,6 @@ static int rpr0521_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int rpr0521_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -1101,11 +1100,9 @@ static int rpr0521_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops rpr0521_pm_ops = {
-	SET_RUNTIME_PM_OPS(rpr0521_runtime_suspend,
-			   rpr0521_runtime_resume, NULL)
+	RUNTIME_PM_OPS(rpr0521_runtime_suspend, rpr0521_runtime_resume, NULL)
 };
 
 static const struct acpi_device_id rpr0521_acpi_match[] = {
@@ -1124,7 +1121,7 @@ MODULE_DEVICE_TABLE(i2c, rpr0521_id);
 static struct i2c_driver rpr0521_driver = {
 	.driver = {
 		.name	= RPR0521_DRV_NAME,
-		.pm	= &rpr0521_pm_ops,
+		.pm	= pm_ptr(&rpr0521_pm_ops),
 		.acpi_match_table = ACPI_PTR(rpr0521_acpi_match),
 	},
 	.probe		= rpr0521_probe,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH v2 51/51] iio:temperature:mlx90614: Switch from CONFIG_PM* guards to pm_ptr() etc
  2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
                   ` (49 preceding siblings ...)
  2022-01-02 12:56 ` [PATCH v2 50/51] iio:light:rpr0521: Switch from CONFIG_PM " Jonathan Cameron
@ 2022-01-02 12:56 ` Jonathan Cameron
  50 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-02 12:56 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron, Crt Mori

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

Letting the compiler remove these functions when the kernel is built
without one or  more of CONFIG_PM/CONFIG_PM_SLEEP 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Crt Mori <cmo@melexis.com>
---
 drivers/iio/temperature/mlx90614.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index afcb10ea7c44..c253a5315988 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -600,7 +600,6 @@ static const struct of_device_id mlx90614_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, mlx90614_of_match);
 
-#ifdef CONFIG_PM_SLEEP
 static int mlx90614_pm_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -630,9 +629,7 @@ static int mlx90614_pm_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-#ifdef CONFIG_PM
 static int mlx90614_pm_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -648,19 +645,18 @@ static int mlx90614_pm_runtime_resume(struct device *dev)
 
 	return mlx90614_wakeup(data);
 }
-#endif
 
 static const struct dev_pm_ops mlx90614_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(mlx90614_pm_suspend, mlx90614_pm_resume)
-	SET_RUNTIME_PM_OPS(mlx90614_pm_runtime_suspend,
-			   mlx90614_pm_runtime_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(mlx90614_pm_suspend, mlx90614_pm_resume)
+	RUNTIME_PM_OPS(mlx90614_pm_runtime_suspend,
+		       mlx90614_pm_runtime_resume, NULL)
 };
 
 static struct i2c_driver mlx90614_driver = {
 	.driver = {
 		.name	= "mlx90614",
 		.of_match_table = mlx90614_of_match,
-		.pm	= &mlx90614_pm_ops,
+		.pm	= pm_ptr(&mlx90614_pm_ops),
 	},
 	.probe = mlx90614_probe,
 	.remove = mlx90614_remove,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:55 ` [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
@ 2022-01-02 14:15   ` Arnd Bergmann
  2022-01-03 15:24     ` Jonathan Cameron
  0 siblings, 1 reply; 65+ messages in thread
From: Arnd Bergmann @ 2022-01-02 14:15 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

On Sun, Jan 2, 2022 at 7:55 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> -static SIMPLE_DEV_PM_OPS(da311_pm_ops, da311_suspend, da311_resume);
> +DEFINE_SIMPLE_DEV_PM_OPS(da311_pm_ops, da311_suspend, da311_resume);
>

Does the new DEFINE_SIMPLE_DEV_PM_OPS imply 'static'? I see that you remove
the specifier in all the patches, which would not work otherwise, but
I wonder what that
means for drivers that actually define the pm-ops globally on purpose
and can't do
that any more after the conversion.

      Arnd

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 44/51] iio:temperature:tmp007: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:56 ` [PATCH v2 44/51] iio:temperature:tmp007: " Jonathan Cameron
@ 2022-01-03  6:03   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 65+ messages in thread
From: Manivannan Sadhasivam @ 2022-01-03  6:03 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

On Sun, Jan 02, 2022 at 12:56:10PM +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Letting the compiler remove these functions when the kernel is built
> without CONFIG_PM_SLEEP 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.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Acked-by: Manivannan Sadhasivam <mani@kernel.org>

Thanks,
Mani

> Cc: Manivannan Sadhasivam <mani@kernel.org>
> ---
>  drivers/iio/temperature/tmp007.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/temperature/tmp007.c b/drivers/iio/temperature/tmp007.c
> index b422371a4674..f7a040f0ee4c 100644
> --- a/drivers/iio/temperature/tmp007.c
> +++ b/drivers/iio/temperature/tmp007.c
> @@ -537,7 +537,6 @@ static int tmp007_probe(struct i2c_client *client,
>  	return devm_iio_device_register(&client->dev, indio_dev);
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
>  static int tmp007_suspend(struct device *dev)
>  {
>  	struct tmp007_data *data = iio_priv(i2c_get_clientdata(
> @@ -554,9 +553,8 @@ static int tmp007_resume(struct device *dev)
>  	return i2c_smbus_write_word_swapped(data->client, TMP007_CONFIG,
>  			data->config | TMP007_CONFIG_CONV_EN);
>  }
> -#endif
>  
> -static SIMPLE_DEV_PM_OPS(tmp007_pm_ops, tmp007_suspend, tmp007_resume);
> +DEFINE_SIMPLE_DEV_PM_OPS(tmp007_pm_ops, tmp007_suspend, tmp007_resume);
>  
>  static const struct of_device_id tmp007_of_match[] = {
>  	{ .compatible = "ti,tmp007", },
> @@ -574,7 +572,7 @@ static struct i2c_driver tmp007_driver = {
>  	.driver = {
>  		.name	= "tmp007",
>  		.of_match_table = tmp007_of_match,
> -		.pm	= &tmp007_pm_ops,
> +		.pm	= pm_sleep_ptr(&tmp007_pm_ops),
>  	},
>  	.probe		= tmp007_probe,
>  	.id_table	= tmp007_id,
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 14:15   ` Arnd Bergmann
@ 2022-01-03 15:24     ` Jonathan Cameron
  2022-01-03 17:58       ` Arnd Bergmann
  0 siblings, 1 reply; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-03 15:24 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-iio, Paul Cercueil, Rafael J . Wysocki, Gwendal Grignou,
	Jonathan Cameron

On Sun, 2 Jan 2022 09:15:06 -0500
Arnd Bergmann <arnd@arndb.de> wrote:

> On Sun, Jan 2, 2022 at 7:55 AM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > -static SIMPLE_DEV_PM_OPS(da311_pm_ops, da311_suspend, da311_resume);
> > +DEFINE_SIMPLE_DEV_PM_OPS(da311_pm_ops, da311_suspend, da311_resume);
> >  

Hi Arnd,

> 
> Does the new DEFINE_SIMPLE_DEV_PM_OPS imply 'static'? 

It does.

> I see that you remove
> the specifier in all the patches, which would not work otherwise, but
> I wonder what that
> means for drivers that actually define the pm-ops globally on purpose
> and can't do
> that any more after the conversion.

That came up in discussion of the patch series introducing this macro
https://lore.kernel.org/linux-pm/20211216110936.6ccd07d3@jic23-huawei/

Most of the cases that don't define it as static
also export the symbol for use by other modules so the approach of letting
the compiler detect it as dead code won't always work.

Exceptions from a bit of grepping are
net/ethernet/broadcom/bnx2x/
scsi/esas2r/esas2r_init.c
  not sure on reasoning behind the file splits in these drivers
  but definitely looks like it we could just merge a few files
  and let this be static + the compiler remove it neatly.

vs 17 cases where the symbol is exported and more cleverness will
be needed.

Jonathan

> 
>       Arnd


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-03 15:24     ` Jonathan Cameron
@ 2022-01-03 17:58       ` Arnd Bergmann
  2022-01-04 14:16         ` Jonathan Cameron
  0 siblings, 1 reply; 65+ messages in thread
From: Arnd Bergmann @ 2022-01-03 17:58 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Arnd Bergmann, linux-iio, Paul Cercueil, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

On Mon, Jan 3, 2022 at 10:24 AM Jonathan Cameron <jic23@kernel.org> wrote:
> On Sun, 2 Jan 2022 09:15:06 -0500 Arnd Bergmann <arnd@arndb.de> wrote:
>
> That came up in discussion of the patch series introducing this macro
> https://lore.kernel.org/linux-pm/20211216110936.6ccd07d3@jic23-huawei/
>
> Most of the cases that don't define it as static
> also export the symbol for use by other modules so the approach of letting
> the compiler detect it as dead code won't always work.
>
> Exceptions from a bit of grepping are
> net/ethernet/broadcom/bnx2x/
> scsi/esas2r/esas2r_init.c
>   not sure on reasoning behind the file splits in these drivers
>   but definitely looks like it we could just merge a few files
>   and let this be static + the compiler remove it neatly.
>
> vs 17 cases where the symbol is exported and more cleverness will
> be needed.

I don't see why exporting the symbol makes a difference at all, either
it is needed in another file or it is not.

I think it would be more natural to not include 'static' in the macro,
that is certainly what all other macros like this do, and it's still
trivial to add 'static' manually, but impossible to remove it.

       Arnd

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 42/51] iio:proximity:sx9500: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:56 ` [PATCH v2 42/51] iio:proximity:sx9500: " Jonathan Cameron
@ 2022-01-03 18:58   ` Gwendal Grignou
  0 siblings, 0 replies; 65+ messages in thread
From: Gwendal Grignou @ 2022-01-03 18:58 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Jonathan Cameron

On Sun, Jan 2, 2022 at 4:52 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Letting the compiler remove these functions when the kernel is built
> without CONFIG_PM_SLEEP 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.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
>  drivers/iio/proximity/sx9500.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index 3e4ddb2e8c2b..01bfd748d820 100644
> --- a/drivers/iio/proximity/sx9500.c
> +++ b/drivers/iio/proximity/sx9500.c
> @@ -993,7 +993,6 @@ static int sx9500_remove(struct i2c_client *client)
>         return 0;
>  }
>
> -#ifdef CONFIG_PM_SLEEP
>  static int sx9500_suspend(struct device *dev)
>  {
>         struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> @@ -1030,11 +1029,8 @@ static int sx9500_resume(struct device *dev)
>
>         return ret;
>  }
> -#endif /* CONFIG_PM_SLEEP */
>
> -static const struct dev_pm_ops sx9500_pm_ops = {
> -       SET_SYSTEM_SLEEP_PM_OPS(sx9500_suspend, sx9500_resume)
> -};
> +DEFINE_SIMPLE_DEV_PM_OPS(sx9500_pm_ops, sx9500_suspend, sx9500_resume);
>
>  static const struct acpi_device_id sx9500_acpi_match[] = {
>         {"SSX9500", 0},
> @@ -1060,7 +1056,7 @@ static struct i2c_driver sx9500_driver = {
>                 .name   = SX9500_DRIVER_NAME,
>                 .acpi_match_table = ACPI_PTR(sx9500_acpi_match),
>                 .of_match_table = of_match_ptr(sx9500_of_match),
> -               .pm = &sx9500_pm_ops,
> +               .pm = pm_sleep_ptr(&sx9500_pm_ops),
>         },
>         .probe          = sx9500_probe,
>         .remove         = sx9500_remove,
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 39/51] iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:56 ` [PATCH v2 39/51] iio:proximity:as3935: " Jonathan Cameron
@ 2022-01-04  6:41   ` Gwendal Grignou
  0 siblings, 0 replies; 65+ messages in thread
From: Gwendal Grignou @ 2022-01-04  6:41 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Jonathan Cameron, Matt Ranostay

On Sun, Jan 2, 2022 at 4:52 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Letting the compiler remove these functions when the kernel is built
> without CONFIG_PM_SLEEP 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.
>
> Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>

To speed the transition to the new PM_OPS macros, we can use cocci to
automate the process a little. I had to use sed script so cocci can
identify the structure and function names:

find $DIR -type f -name \*.c \ -exec sed -i 's/static
SIMPLE_DEV_PM_OPS(\(.*\), */gg_type \1 = gg_arg(/' {} \+
spatch -sp_file no_SIMPLE_DEV_PM_OPS.cocci -dir $DIR | patch -p 1 -d $DIR
sed -i 's/gg_type \(.*\) = gg_arg(/DEFINE_SIMPLE_DEV_PM_OPS(\1, /'
$(git diff --name-only)

where no_SIMPLE_DEV_PM_OPS.cocci is:
@ Replacement @
identifier operation;
identifier suspend, resume;
@@

gg_type operation = gg_arg(suspend, resume);

@@
identifier Replacement.suspend;
identifier dev;
@@

- __maybe_unused
suspend(struct device* dev ) { ... }

@@
identifier Replacement.resume;
identifier dev;
@@

- __maybe_unused
resume(struct device* dev ) { ... }

@@
identifier Replacement.operation;
@@

- &operation
+ pm_sleep_ptr(&operation)


>  drivers/iio/proximity/as3935.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
> index 51f4f92ae84a..5716048e228c 100644
> --- a/drivers/iio/proximity/as3935.c
> +++ b/drivers/iio/proximity/as3935.c
> @@ -295,7 +295,6 @@ static void calibrate_as3935(struct as3935_state *st)
>         as3935_write(st, AS3935_NFLWDTH, st->nflwdth_reg);
>  }
>
> -#ifdef CONFIG_PM_SLEEP
>  static int as3935_suspend(struct device *dev)
>  {
>         struct iio_dev *indio_dev = dev_get_drvdata(dev);
> @@ -337,12 +336,7 @@ static int as3935_resume(struct device *dev)
>         return ret;
>  }
>
> -static SIMPLE_DEV_PM_OPS(as3935_pm_ops, as3935_suspend, as3935_resume);
> -#define AS3935_PM_OPS (&as3935_pm_ops)
> -
> -#else
> -#define AS3935_PM_OPS NULL
> -#endif
> +DEFINE_SIMPLE_DEV_PM_OPS(as3935_pm_ops, as3935_suspend, as3935_resume);
>
>  static void as3935_stop_work(void *data)
>  {
> @@ -472,7 +466,7 @@ static struct spi_driver as3935_driver = {
>         .driver = {
>                 .name   = "as3935",
>                 .of_match_table = as3935_of_match,
> -               .pm     = AS3935_PM_OPS,
> +               .pm     = pm_sleep_ptr(&as3935_pm_ops),
>         },
>         .probe          = as3935_probe,
>         .id_table       = as3935_id,
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-03 17:58       ` Arnd Bergmann
@ 2022-01-04 14:16         ` Jonathan Cameron
  2022-01-04 14:24           ` Rafael J. Wysocki
  2022-01-04 15:08           ` Paul Cercueil
  0 siblings, 2 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-04 14:16 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jonathan Cameron, linux-iio, Paul Cercueil, Rafael J . Wysocki,
	Gwendal Grignou

On Mon, 3 Jan 2022 12:58:46 -0500
Arnd Bergmann <arnd@arndb.de> wrote:

> On Mon, Jan 3, 2022 at 10:24 AM Jonathan Cameron <jic23@kernel.org> wrote:
> > On Sun, 2 Jan 2022 09:15:06 -0500 Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > That came up in discussion of the patch series introducing this macro
> > https://lore.kernel.org/linux-pm/20211216110936.6ccd07d3@jic23-huawei/
> >
> > Most of the cases that don't define it as static
> > also export the symbol for use by other modules so the approach of letting
> > the compiler detect it as dead code won't always work.
> >
> > Exceptions from a bit of grepping are
> > net/ethernet/broadcom/bnx2x/
> > scsi/esas2r/esas2r_init.c
> >   not sure on reasoning behind the file splits in these drivers
> >   but definitely looks like it we could just merge a few files
> >   and let this be static + the compiler remove it neatly.
> >
> > vs 17 cases where the symbol is exported and more cleverness will
> > be needed.  
> 
> I don't see why exporting the symbol makes a difference at all, either
> it is needed in another file or it is not.

Ah. My reasoning was that the purpose behind that patch set (letting
compiler remove the functions etc when unused) was not applicable in EXPORT*
cases.  However, I'd neglected that the DEFINE_SIMPLE_DEV_PM_OPS()
macro is probably useful anyway as those cases would need CONFIG_PM*
guards if they want to remove the code when PM stuff isn't enabled.

> 
> I think it would be more natural to not include 'static' in the macro,
> that is certainly what all other macros like this do, and it's still
> trivial to add 'static' manually, but impossible to remove it.

IIRC there are other cases like this, but it was exactly this somewhat
unusual element that made me raise the question in the original discussion.

Paul, over to you for reasoning.  If we are going to change this
now is the time before they get significant use and we end up having
to add static to lots of places.

Jonathan

> 
>        Arnd


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-04 14:16         ` Jonathan Cameron
@ 2022-01-04 14:24           ` Rafael J. Wysocki
  2022-01-04 15:08           ` Paul Cercueil
  1 sibling, 0 replies; 65+ messages in thread
From: Rafael J. Wysocki @ 2022-01-04 14:24 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Arnd Bergmann, Jonathan Cameron, linux-iio, Paul Cercueil,
	Rafael J . Wysocki, Gwendal Grignou

On Tue, Jan 4, 2022 at 3:16 PM Jonathan Cameron
<Jonathan.Cameron@huawei.com> wrote:
>
> On Mon, 3 Jan 2022 12:58:46 -0500
> Arnd Bergmann <arnd@arndb.de> wrote:
>
> > On Mon, Jan 3, 2022 at 10:24 AM Jonathan Cameron <jic23@kernel.org> wrote:
> > > On Sun, 2 Jan 2022 09:15:06 -0500 Arnd Bergmann <arnd@arndb.de> wrote:
> > >
> > > That came up in discussion of the patch series introducing this macro
> > > https://lore.kernel.org/linux-pm/20211216110936.6ccd07d3@jic23-huawei/
> > >
> > > Most of the cases that don't define it as static
> > > also export the symbol for use by other modules so the approach of letting
> > > the compiler detect it as dead code won't always work.
> > >
> > > Exceptions from a bit of grepping are
> > > net/ethernet/broadcom/bnx2x/
> > > scsi/esas2r/esas2r_init.c
> > >   not sure on reasoning behind the file splits in these drivers
> > >   but definitely looks like it we could just merge a few files
> > >   and let this be static + the compiler remove it neatly.
> > >
> > > vs 17 cases where the symbol is exported and more cleverness will
> > > be needed.
> >
> > I don't see why exporting the symbol makes a difference at all, either
> > it is needed in another file or it is not.
>
> Ah. My reasoning was that the purpose behind that patch set (letting
> compiler remove the functions etc when unused) was not applicable in EXPORT*
> cases.  However, I'd neglected that the DEFINE_SIMPLE_DEV_PM_OPS()
> macro is probably useful anyway as those cases would need CONFIG_PM*
> guards if they want to remove the code when PM stuff isn't enabled.

I agree with Arnd that including "static" in the
DEFINE_UNIVERSAL_DEV_PM_OPS and DEFINE_SIMPLE_DEV_PM_OPS is not
particularly useful.

> >
> > I think it would be more natural to not include 'static' in the macro,
> > that is certainly what all other macros like this do, and it's still
> > trivial to add 'static' manually, but impossible to remove it.
>
> IIRC there are other cases like this, but it was exactly this somewhat
> unusual element that made me raise the question in the original discussion.
>
> Paul, over to you for reasoning.  If we are going to change this
> now is the time before they get significant use and we end up having
> to add static to lots of places.

So please feel free to submit a patch removing these "static"
qualifiers from the macros in question or I will do that.

Thanks!

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-04 14:16         ` Jonathan Cameron
  2022-01-04 14:24           ` Rafael J. Wysocki
@ 2022-01-04 15:08           ` Paul Cercueil
  2022-01-04 18:06             ` Arnd Bergmann
  1 sibling, 1 reply; 65+ messages in thread
From: Paul Cercueil @ 2022-01-04 15:08 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Arnd Bergmann, Jonathan Cameron, linux-iio, Rafael J . Wysocki,
	Gwendal Grignou

Hi,

Le mar., janv. 4 2022 at 14:16:01 +0000, Jonathan Cameron 
<Jonathan.Cameron@Huawei.com> a écrit :
> On Mon, 3 Jan 2022 12:58:46 -0500
> Arnd Bergmann <arnd@arndb.de> wrote:
> 
>>  On Mon, Jan 3, 2022 at 10:24 AM Jonathan Cameron <jic23@kernel.org> 
>> wrote:
>>  > On Sun, 2 Jan 2022 09:15:06 -0500 Arnd Bergmann <arnd@arndb.de> 
>> wrote:
>>  >
>>  > That came up in discussion of the patch series introducing this 
>> macro
>>  > 
>> https://lore.kernel.org/linux-pm/20211216110936.6ccd07d3@jic23-huawei/
>>  >
>>  > Most of the cases that don't define it as static
>>  > also export the symbol for use by other modules so the approach 
>> of letting
>>  > the compiler detect it as dead code won't always work.
>>  >
>>  > Exceptions from a bit of grepping are
>>  > net/ethernet/broadcom/bnx2x/
>>  > scsi/esas2r/esas2r_init.c
>>  >   not sure on reasoning behind the file splits in these drivers
>>  >   but definitely looks like it we could just merge a few files
>>  >   and let this be static + the compiler remove it neatly.
>>  >
>>  > vs 17 cases where the symbol is exported and more cleverness will
>>  > be needed.
>> 
>>  I don't see why exporting the symbol makes a difference at all, 
>> either
>>  it is needed in another file or it is not.
> 
> Ah. My reasoning was that the purpose behind that patch set (letting
> compiler remove the functions etc when unused) was not applicable in 
> EXPORT*
> cases.  However, I'd neglected that the DEFINE_SIMPLE_DEV_PM_OPS()
> macro is probably useful anyway as those cases would need CONFIG_PM*
> guards if they want to remove the code when PM stuff isn't enabled.
> 
>> 
>>  I think it would be more natural to not include 'static' in the 
>> macro,
>>  that is certainly what all other macros like this do, and it's still
>>  trivial to add 'static' manually, but impossible to remove it.
> 
> IIRC there are other cases like this, but it was exactly this somewhat
> unusual element that made me raise the question in the original 
> discussion.
> 
> Paul, over to you for reasoning.  If we are going to change this
> now is the time before they get significant use and we end up having
> to add static to lots of places.

I have an idea on how to tackle automatic dead code removal on exported 
dev_pm_ops symbols. It means introducing a separate 
EXPORTED_SIMPLE_DEV_PM_OPS(), so the current DEFINE_SIMPLE_DEV_PM_OPS() 
macro could keep the "static". Unless you still think it's a bad idea, 
then in this case we can remove it.

Cheers,
-Paul



^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-04 15:08           ` Paul Cercueil
@ 2022-01-04 18:06             ` Arnd Bergmann
  0 siblings, 0 replies; 65+ messages in thread
From: Arnd Bergmann @ 2022-01-04 18:06 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Jonathan Cameron, Arnd Bergmann, Jonathan Cameron, linux-iio,
	Rafael J . Wysocki, Gwendal Grignou

On Tue, Jan 4, 2022 at 10:08 AM Paul Cercueil <paul@crapouillou.net> wrote:
> Le mar., janv. 4 2022 at 14:16:01 +0000, Jonathan Cameron
> >
> > Paul, over to you for reasoning.  If we are going to change this
> > now is the time before they get significant use and we end up having
> > to add static to lots of places.
>
> I have an idea on how to tackle automatic dead code removal on exported
> dev_pm_ops symbols. It means introducing a separate
> EXPORTED_SIMPLE_DEV_PM_OPS(), so the current DEFINE_SIMPLE_DEV_PM_OPS()
> macro could keep the "static". Unless you still think it's a bad idea,
> then in this case we can remove it.

I would prefer removing the implicit 'static' if only for consistency reasons,
which to me outweighs the simplicity aspect in this case.

         Arnd

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 48/51] iio:dac:m62332: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
  2022-01-02 12:56 ` [PATCH v2 48/51] iio:dac:m62332: " Jonathan Cameron
@ 2022-01-05 10:52   ` Jonathan Cameron
  0 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-05 10:52 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou

On Sun,  2 Jan 2022 12:56:14 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Letting the compiler remove these functions when the kernel is built
> without CONFIG_PM_SLEEP 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.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

I missed that there were some CONFIG_PM guards around iio_priv()->save
that also need dropping.  Will do that in v3.

Jonathan

> ---
>  drivers/iio/dac/m62332.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c
> index 225b1a374dc1..4a413936fabb 100644
> --- a/drivers/iio/dac/m62332.c
> +++ b/drivers/iio/dac/m62332.c
> @@ -124,7 +124,6 @@ static int m62332_write_raw(struct iio_dev *indio_dev,
>  	return -EINVAL;
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
>  static int m62332_suspend(struct device *dev)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
> @@ -156,11 +155,7 @@ static int m62332_resume(struct device *dev)
>  	return m62332_set_value(indio_dev, data->save[1], 1);
>  }
>  
> -static SIMPLE_DEV_PM_OPS(m62332_pm_ops, m62332_suspend, m62332_resume);
> -#define M62332_PM_OPS (&m62332_pm_ops)
> -#else
> -#define M62332_PM_OPS NULL
> -#endif
> +DEFINE_SIMPLE_DEV_PM_OPS(m62332_pm_ops, m62332_suspend, m62332_resume);
>  
>  static const struct iio_info m62332_info = {
>  	.read_raw = m62332_read_raw,
> @@ -246,7 +241,7 @@ MODULE_DEVICE_TABLE(i2c, m62332_id);
>  static struct i2c_driver m62332_driver = {
>  	.driver = {
>  		.name	= "m62332",
> -		.pm	= M62332_PM_OPS,
> +		.pm	= pm_sleep_ptr(&m62332_pm_ops),
>  	},
>  	.probe		= m62332_probe,
>  	.remove		= m62332_remove,


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 10/51] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:55 ` [PATCH v2 10/51] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
@ 2022-01-30 19:08   ` Jonathan Cameron
  0 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-30 19:08 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

On Sun,  2 Jan 2022 12:55:36 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> 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.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
I'm going to drop this from v3 because of the clash with the namespace
patch that is already on list.

Once that's in I'll post an updated version with the a precursor patch
to add new PM macros to export the pm_ops in a namespace.

Jonathan

> ---
>  drivers/iio/accel/kxsd9-i2c.c | 2 +-
>  drivers/iio/accel/kxsd9-spi.c | 2 +-
>  drivers/iio/accel/kxsd9.c     | 8 ++------
>  3 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
> index 274b41a6e603..ffe8066b4025 100644
> --- a/drivers/iio/accel/kxsd9-i2c.c
> +++ b/drivers/iio/accel/kxsd9-i2c.c
> @@ -55,7 +55,7 @@ static struct i2c_driver kxsd9_i2c_driver = {
>  	.driver = {
>  		.name	= "kxsd9",
>  		.of_match_table = kxsd9_of_match,
> -		.pm = &kxsd9_dev_pm_ops,
> +		.pm = pm_ptr(&kxsd9_dev_pm_ops),
>  	},
>  	.probe		= kxsd9_i2c_probe,
>  	.remove		= kxsd9_i2c_remove,
> diff --git a/drivers/iio/accel/kxsd9-spi.c b/drivers/iio/accel/kxsd9-spi.c
> index 441e6b764281..44edf39fc5ff 100644
> --- a/drivers/iio/accel/kxsd9-spi.c
> +++ b/drivers/iio/accel/kxsd9-spi.c
> @@ -54,7 +54,7 @@ MODULE_DEVICE_TABLE(of, kxsd9_of_match);
>  static struct spi_driver kxsd9_spi_driver = {
>  	.driver = {
>  		.name = "kxsd9",
> -		.pm = &kxsd9_dev_pm_ops,
> +		.pm = pm_ptr(&kxsd9_dev_pm_ops),
>  		.of_match_table = kxsd9_of_match,
>  	},
>  	.probe = kxsd9_spi_probe,
> diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
> index 552eba5e8b4f..39059ddca441 100644
> --- a/drivers/iio/accel/kxsd9.c
> +++ b/drivers/iio/accel/kxsd9.c
> @@ -492,7 +492,6 @@ void kxsd9_common_remove(struct device *dev)
>  }
>  EXPORT_SYMBOL(kxsd9_common_remove);
>  
> -#ifdef CONFIG_PM
>  static int kxsd9_runtime_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> @@ -508,13 +507,10 @@ static int kxsd9_runtime_resume(struct device *dev)
>  
>  	return kxsd9_power_up(st);
>  }
> -#endif /* CONFIG_PM */
>  
>  const struct dev_pm_ops kxsd9_dev_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> -				pm_runtime_force_resume)
> -	SET_RUNTIME_PM_OPS(kxsd9_runtime_suspend,
> -			   kxsd9_runtime_resume, NULL)
> +	SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
> +	RUNTIME_PM_OPS(kxsd9_runtime_suspend, kxsd9_runtime_resume, NULL)
>  };
>  EXPORT_SYMBOL(kxsd9_dev_pm_ops);
>  


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH v2 34/51] iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() etc
  2022-01-02 12:56 ` [PATCH v2 34/51] iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
@ 2022-01-30 19:12   ` Jonathan Cameron
  0 siblings, 0 replies; 65+ messages in thread
From: Jonathan Cameron @ 2022-01-30 19:12 UTC (permalink / raw)
  To: linux-iio
  Cc: Paul Cercueil, Arnd Bergmann, Rafael J . Wysocki,
	Gwendal Grignou, Jonathan Cameron

On Sun,  2 Jan 2022 12:56:00 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> 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.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Dropping this (for now) from v3 as need to take a closer look at
what we should be doing for the interaction of sleep and runtime
pm ops.  Probably wants to use the force runtime macros but needs
more care than I'm going to give it today!

Jonathan

> ---
>  drivers/iio/light/us5182d.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c
> index 96e4a66ddf28..fdabf601d15e 100644
> --- a/drivers/iio/light/us5182d.c
> +++ b/drivers/iio/light/us5182d.c
> @@ -916,7 +916,6 @@ static int us5182d_remove(struct i2c_client *client)
>  	return us5182d_shutdown_en(data, US5182D_CFG0_SHUTDOWN_EN);
>  }
>  
> -#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM)
>  static int us5182d_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> @@ -939,11 +938,10 @@ static int us5182d_resume(struct device *dev)
>  
>  	return 0;
>  }
> -#endif
>  
>  static const struct dev_pm_ops us5182d_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(us5182d_suspend, us5182d_resume)
> -	SET_RUNTIME_PM_OPS(us5182d_suspend, us5182d_resume, NULL)
> +	SYSTEM_SLEEP_PM_OPS(us5182d_suspend, us5182d_resume)
> +	RUNTIME_PM_OPS(us5182d_suspend, us5182d_resume, NULL)
>  };
>  
>  static const struct acpi_device_id us5182d_acpi_match[] = {
> @@ -969,7 +967,7 @@ MODULE_DEVICE_TABLE(of, us5182d_of_match);
>  static struct i2c_driver us5182d_driver = {
>  	.driver = {
>  		.name = US5182D_DRV_NAME,
> -		.pm = &us5182d_pm_ops,
> +		.pm = pm_ptr(&us5182d_pm_ops),
>  		.of_match_table = us5182d_of_match,
>  		.acpi_match_table = ACPI_PTR(us5182d_acpi_match),
>  	},


^ permalink raw reply	[flat|nested] 65+ messages in thread

end of thread, other threads:[~2022-01-30 19:06 UTC | newest]

Thread overview: 65+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-02 12:55 [PATCH v2 00/51] iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 01/51] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-02 14:15   ` Arnd Bergmann
2022-01-03 15:24     ` Jonathan Cameron
2022-01-03 17:58       ` Arnd Bergmann
2022-01-04 14:16         ` Jonathan Cameron
2022-01-04 14:24           ` Rafael J. Wysocki
2022-01-04 15:08           ` Paul Cercueil
2022-01-04 18:06             ` Arnd Bergmann
2022-01-02 12:55 ` [PATCH v2 02/51] iio:accel:da280: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 03/51] iio:accel:dmard06: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 04/51] iio:accel:dmard10: Switch from CONFIG_PM " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 05/51] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 06/51] iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 07/51] iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 08/51] iio:accel:mma9553: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 09/51] iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 10/51] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
2022-01-30 19:08   ` Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 11/51] iio:adc:ab8500: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 12/51] iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 13/51] iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 14/51] iio:adc:palmas_gpadc: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 15/51] iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr() Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 16/51] iio:adc:rcar: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 17/51] iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 18/51] iio:adc:twl6030: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 19/51] iio:adc:vf610: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 20/51] iio:common:ssp: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 21/51] iio:dac:vf610: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 22/51] iio:light:apds9300: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 23/51] iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 24/51] iio:light:cm3232: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 25/51] iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 26/51] iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 27/51] iio:light:jsa1212: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 28/51] iio:light:ltr501: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 29/51] iio:light:stk3310: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 30/51] iio:light:tcs3414: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 31/51] iio:light:tcs3472: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 32/51] iio:light:tsl2563: " Jonathan Cameron
2022-01-02 12:55 ` [PATCH v2 33/51] iio:light:tsl4531: " Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 34/51] iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
2022-01-30 19:12   ` Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 35/51] iio:magn:ak8975: " Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 36/51] iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 37/51] iio:magn:mmc35240: " Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 38/51] iio:pressure:mpl3115: " Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 39/51] iio:proximity:as3935: " Jonathan Cameron
2022-01-04  6:41   ` Gwendal Grignou
2022-01-02 12:56 ` [PATCH v2 40/51] iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 41/51] iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 42/51] iio:proximity:sx9500: " Jonathan Cameron
2022-01-03 18:58   ` Gwendal Grignou
2022-01-02 12:56 ` [PATCH v2 43/51] iio:temperature:tmp006: " Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 44/51] iio:temperature:tmp007: " Jonathan Cameron
2022-01-03  6:03   ` Manivannan Sadhasivam
2022-01-02 12:56 ` [PATCH v2 45/51] iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() etc Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 46/51] iio:accel:stk8312: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 47/51] iio:accel:bma180: " Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 48/51] iio:dac:m62332: " Jonathan Cameron
2022-01-05 10:52   ` Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 49/51] iio:imu:kmx61: Switch from CONFIG_PM* guards to pm_ptr() etc Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 50/51] iio:light:rpr0521: Switch from CONFIG_PM " Jonathan Cameron
2022-01-02 12:56 ` [PATCH v2 51/51] iio:temperature:mlx90614: Switch from CONFIG_PM* " Jonathan Cameron

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.