All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
@ 2021-11-23 21:09 Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 01/49] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused Jonathan Cameron
                   ` (50 more replies)
  0 siblings, 51 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron,
	Alexandre Belloni, Anson Huang, Brian Masney, 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, Olivier Moysan, Stefan-Gabriel Mirea,
	Vaishnav M A

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

Note this series includes many drivers that are quite old and I'm not
sure have active maintainers.  Hence if anyone has time to look at some
of these beyond their own drivers and sanity check them it would be much
appreciated!

Two motivations behind this set.
1 - General code reduction and improvement in readability in these drivers.
2 - Reduce change I'll have to ask people to change how they do this in
    future patches.

Mostly this is just a case of letting the compiler work out it can remove
the PM related functions rather than using #ifdefs in the code to do so.

The __maybe_unused markings make it clear we are intentionally building
functions that the compiler can see are unused and remove in some build
configurations.

The new pm_ptr() macro is rather convenient to got futher than many of
the drivers were and when CONFIG_PM is not define ensure that the
struct dev_pm_ops can also be removed.  Note there is a subtlty in that
we only remove that whe CONFIG_PM is not defined whereas a few of these
drivers were using CONFIG_PM_SLEEP which is a tighter condition (will
remove the structure in more configurations).  I think that's a small
price to pay for the convenience this macro brings.

I did this set as one patch per driver, as personally I prefer that
option for all but the most trivial patches because it makes backports
that cross with this series simpler and also avoid the complex
tag giving we get for sets touching code from many authors.

All comments welcome.

Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Anson Huang <anson.huang@nxp.com>
Cc: Brian Masney <masneyb@onstation.org>
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: 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 (49):
  iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:accel:da280: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:accel:dmard06: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:accel:dmard10: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:accel:mc3230: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:accel:mma9553: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:adc:ab8500: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:adc:ad7606: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:adc:palmas_gpadc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:adc:rcar: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:adc:twl6030: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:adc:vf610: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:common:ssp: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:dac:vf610: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:apds9300: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:light:cm3232: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:jsa1212: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:ltr501: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:stk3310: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:tcs3414: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:tcs3472: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:tsl2563: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:tsl4531: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:magn:ak8975: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:magn:mmc35240: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:pressure:mpl3115: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:pressure:bmp280: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to pm_ptr()
    / __maybe_unused
  iio:proximity:sx9500: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
    __maybe_unused
  iio:temperature:tmp006: Switch from CONFIG_PM_SLEEP guards to pm_ptr()
    / __maybe_unused
  iio:temperature:tmp007: Switch from CONFIG_PM_SLEEP guards to pm_ptr()
    / __maybe_unused
  iio:gyro:mpu3050: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused
  iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() /
    __maybe_unused

 drivers/iio/accel/da280.c                        |  6 ++----
 drivers/iio/accel/da311.c                        |  8 +++-----
 drivers/iio/accel/dmard06.c                      | 12 ++++--------
 drivers/iio/accel/dmard10.c                      |  9 ++++-----
 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                       |  8 +++-----
 drivers/iio/accel/mma7660.c                      | 12 +++---------
 drivers/iio/accel/mma9551.c                      | 16 ++++++----------
 drivers/iio/accel/mma9553.c                      | 16 ++++++----------
 drivers/iio/accel/stk8ba50.c                     | 12 +++---------
 drivers/iio/adc/ab8500-gpadc.c                   | 10 ++++------
 drivers/iio/adc/ad7606.c                         |  8 ++------
 drivers/iio/adc/ad7606.h                         |  5 -----
 drivers/iio/adc/ad7606_par.c                     |  2 +-
 drivers/iio/adc/ad7606_spi.c                     |  2 +-
 drivers/iio/adc/at91_adc.c                       |  8 +++-----
 drivers/iio/adc/exynos_adc.c                     |  8 +++-----
 drivers/iio/adc/palmas_gpadc.c                   | 14 ++++++--------
 drivers/iio/adc/rcar-gyroadc.c                   | 10 ++++------
 drivers/iio/adc/rockchip_saradc.c                |  8 +++-----
 drivers/iio/adc/stm32-adc-core.c                 | 12 +++++-------
 drivers/iio/adc/stm32-adc.c                      | 16 ++++++----------
 drivers/iio/adc/twl6030-gpadc.c                  |  8 +++-----
 drivers/iio/adc/vf610_adc.c                      |  8 +++-----
 drivers/iio/chemical/atlas-sensor.c              | 10 ++++------
 drivers/iio/common/ssp_sensors/ssp_dev.c         | 12 ++++--------
 drivers/iio/dac/vf610_dac.c                      |  8 +++-----
 drivers/iio/gyro/mpu3050-core.c                  |  8 +++-----
 drivers/iio/gyro/mpu3050-i2c.c                   |  2 +-
 drivers/iio/light/apds9300.c                     | 11 +++--------
 drivers/iio/light/bh1780.c                       | 10 ++++------
 drivers/iio/light/cm3232.c                       | 13 ++++---------
 drivers/iio/light/isl29018.c                     | 11 +++--------
 drivers/iio/light/isl29125.c                     |  8 +++-----
 drivers/iio/light/jsa1212.c                      | 12 +++---------
 drivers/iio/light/ltr501.c                       |  8 +++-----
 drivers/iio/light/stk3310.c                      | 12 +++---------
 drivers/iio/light/tcs3414.c                      |  8 +++-----
 drivers/iio/light/tcs3472.c                      |  8 +++-----
 drivers/iio/light/tsl2563.c                      | 11 +++--------
 drivers/iio/light/tsl4531.c                      | 11 +++--------
 drivers/iio/light/us5182d.c                      | 10 ++++------
 drivers/iio/magnetometer/ak8975.c                | 10 ++++------
 drivers/iio/magnetometer/hmc5843.h               |  5 -----
 drivers/iio/magnetometer/hmc5843_i2c.c           |  2 +-
 drivers/iio/magnetometer/hmc5843_spi.c           |  2 +-
 drivers/iio/magnetometer/mag3110.c               | 11 +++--------
 drivers/iio/magnetometer/mmc35240.c              | 12 ++++--------
 drivers/iio/pressure/bmp280-core.c               |  6 ++----
 drivers/iio/pressure/bmp280-i2c.c                |  2 +-
 drivers/iio/pressure/bmp280-spi.c                |  2 +-
 drivers/iio/pressure/mpl3115.c                   | 11 +++--------
 drivers/iio/proximity/as3935.c                   | 12 +++---------
 .../iio/proximity/pulsedlight-lidar-lite-v2.c    | 10 ++++------
 drivers/iio/proximity/rfd77402.c                 |  8 +++-----
 drivers/iio/proximity/sx9500.c                   | 12 ++++--------
 drivers/iio/temperature/tmp006.c                 |  8 +++-----
 drivers/iio/temperature/tmp007.c                 |  8 +++-----
 60 files changed, 180 insertions(+), 344 deletions(-)

-- 
2.34.0


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

* [PATCH 01/49] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 02/49] iio:accel:da280: " Jonathan Cameron
                   ` (49 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/accel/da311.c b/drivers/iio/accel/da311.c
index 04e13487e706..b65f47dc4945 100644
--- a/drivers/iio/accel/da311.c
+++ b/drivers/iio/accel/da311.c
@@ -256,17 +256,15 @@ 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)
+static __maybe_unused int da311_suspend(struct device *dev)
 {
 	return da311_enable(to_i2c_client(dev), false);
 }
 
-static int da311_resume(struct device *dev)
+static __maybe_unused 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);
 
@@ -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_ptr(&da311_pm_ops),
 	},
 	.probe		= da311_probe,
 	.id_table	= da311_i2c_id,
-- 
2.34.0


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

* [PATCH 02/49] iio:accel:da280: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 01/49] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 22:17   ` Paul Cercueil
  2021-11-23 21:09 ` [PATCH 03/49] iio:accel:dmard06: " Jonathan Cameron
                   ` (48 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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..91ac478891ce 100644
--- a/drivers/iio/accel/da280.c
+++ b/drivers/iio/accel/da280.c
@@ -153,17 +153,15 @@ 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)
+static __maybe_unused int da280_suspend(struct device *dev)
 {
 	return da280_enable(to_i2c_client(dev), false);
 }
 
-static int da280_resume(struct device *dev)
+static __maybe_unused 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);
 
-- 
2.34.0


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

* [PATCH 03/49] iio:accel:dmard06: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 01/49] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 02/49] iio:accel:da280: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 04/49] iio:accel:dmard10: Switch from CONFIG_PM " Jonathan Cameron
                   ` (47 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/accel/dmard06.c b/drivers/iio/accel/dmard06.c
index de2868c28d95..a0e8d0ab700b 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,8 +171,7 @@ 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)
+static __maybe_unused int dmard06_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct dmard06_data *dmard06 = iio_priv(indio_dev);
@@ -185,7 +185,7 @@ static int dmard06_suspend(struct device *dev)
 	return 0;
 }
 
-static int dmard06_resume(struct device *dev)
+static __maybe_unused int dmard06_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct dmard06_data *dmard06 = iio_priv(indio_dev);
@@ -200,10 +200,6 @@ static int dmard06_resume(struct device *dev)
 }
 
 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
 
 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_ptr(&dmard06_pm_ops),
 	},
 };
 module_i2c_driver(dmard06_driver);
-- 
2.34.0


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

* [PATCH 04/49] iio:accel:dmard10: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (2 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 03/49] iio:accel:dmard06: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 05/49] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
                   ` (46 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/accel/dmard10.c b/drivers/iio/accel/dmard10.c
index f9f173eec202..7ad3349ad60f 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,17 +219,15 @@ 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)
+static int __maybe_unused dmard10_suspend(struct device *dev)
 {
 	return dmard10_shutdown(to_i2c_client(dev));
 }
 
-static int dmard10_resume(struct device *dev)
+static int __maybe_unused 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);
 
@@ -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_ptr(&dmard10_pm_ops),
 	},
 	.probe		= dmard10_probe,
 	.id_table	= dmard10_i2c_id,
-- 
2.34.0


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

* [PATCH 05/49] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (3 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 04/49] iio:accel:dmard10: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:37   ` Hans de Goede
  2021-11-23 21:09 ` [PATCH 06/49] iio:accel:mma7660: " Jonathan Cameron
                   ` (45 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c
index 735002b716f3..139c7f6839df 100644
--- a/drivers/iio/accel/mc3230.c
+++ b/drivers/iio/accel/mc3230.c
@@ -160,8 +160,7 @@ 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)
+static __maybe_unused int mc3230_suspend(struct device *dev)
 {
 	struct mc3230_data *data;
 
@@ -170,7 +169,7 @@ static int mc3230_suspend(struct device *dev)
 	return mc3230_set_opcon(data, MC3230_MODE_OPCON_STANDBY);
 }
 
-static int mc3230_resume(struct device *dev)
+static __maybe_unused int mc3230_resume(struct device *dev)
 {
 	struct mc3230_data *data;
 
@@ -178,7 +177,6 @@ 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);
 
@@ -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_ptr(&mc3230_pm_ops),
 	},
 	.probe		= mc3230_probe,
 	.remove		= mc3230_remove,
-- 
2.34.0


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

* [PATCH 06/49] iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (4 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 05/49] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 07/49] iio:accel:mma9551: Switch from CONFIG_PM " Jonathan Cameron
                   ` (44 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/accel/mma7660.c b/drivers/iio/accel/mma7660.c
index 24b83ccdb950..e90463b88b91 100644
--- a/drivers/iio/accel/mma7660.c
+++ b/drivers/iio/accel/mma7660.c
@@ -222,8 +222,7 @@ static int mma7660_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int mma7660_suspend(struct device *dev)
+static __maybe_unused int mma7660_suspend(struct device *dev)
 {
 	struct mma7660_data *data;
 
@@ -232,7 +231,7 @@ static int mma7660_suspend(struct device *dev)
 	return mma7660_set_mode(data, MMA7660_MODE_STANDBY);
 }
 
-static int mma7660_resume(struct device *dev)
+static __maybe_unused int mma7660_resume(struct device *dev)
 {
 	struct mma7660_data *data;
 
@@ -243,11 +242,6 @@ static int mma7660_resume(struct device *dev)
 
 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
-
 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_ptr(&mma7660_pm_ops),
 		.of_match_table = mma7660_of_match,
 		.acpi_match_table = ACPI_PTR(mma7660_acpi_id),
 	},
-- 
2.34.0


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

* [PATCH 07/49] iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (5 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 06/49] iio:accel:mma7660: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 08/49] iio:accel:mma9553: " Jonathan Cameron
                   ` (43 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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 | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c
index 4c359fb05480..67fdd53b811f 100644
--- a/drivers/iio/accel/mma9551.c
+++ b/drivers/iio/accel/mma9551.c
@@ -523,8 +523,7 @@ static int mma9551_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int mma9551_runtime_suspend(struct device *dev)
+static __maybe_unused int mma9551_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct mma9551_data *data = iio_priv(indio_dev);
@@ -541,7 +540,7 @@ static int mma9551_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int mma9551_runtime_resume(struct device *dev)
+static __maybe_unused int mma9551_runtime_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct mma9551_data *data = iio_priv(indio_dev);
@@ -555,10 +554,8 @@ static int mma9551_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-#ifdef CONFIG_PM_SLEEP
-static int mma9551_suspend(struct device *dev)
+static __maybe_unused int mma9551_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct mma9551_data *data = iio_priv(indio_dev);
@@ -571,7 +568,7 @@ static int mma9551_suspend(struct device *dev)
 	return ret;
 }
 
-static int mma9551_resume(struct device *dev)
+static __maybe_unused int mma9551_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct mma9551_data *data = iio_priv(indio_dev);
@@ -583,9 +580,8 @@ static int mma9551_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops mma9551_pm_ops = {
+static __maybe_unused 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)
@@ -609,7 +605,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.0


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

* [PATCH 08/49] iio:accel:mma9553: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (6 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 07/49] iio:accel:mma9551: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 09/49] iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
                   ` (42 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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 | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c
index ba3ecb3b57dc..1597806229f4 100644
--- a/drivers/iio/accel/mma9553.c
+++ b/drivers/iio/accel/mma9553.c
@@ -1162,8 +1162,7 @@ static int mma9553_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int mma9553_runtime_suspend(struct device *dev)
+static __maybe_unused int mma9553_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct mma9553_data *data = iio_priv(indio_dev);
@@ -1180,7 +1179,7 @@ static int mma9553_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int mma9553_runtime_resume(struct device *dev)
+static __maybe_unused int mma9553_runtime_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct mma9553_data *data = iio_priv(indio_dev);
@@ -1194,10 +1193,8 @@ static int mma9553_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-#ifdef CONFIG_PM_SLEEP
-static int mma9553_suspend(struct device *dev)
+static __maybe_unused int mma9553_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct mma9553_data *data = iio_priv(indio_dev);
@@ -1210,7 +1207,7 @@ static int mma9553_suspend(struct device *dev)
 	return ret;
 }
 
-static int mma9553_resume(struct device *dev)
+static __maybe_unused int mma9553_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct mma9553_data *data = iio_priv(indio_dev);
@@ -1222,9 +1219,8 @@ static int mma9553_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops mma9553_pm_ops = {
+static __maybe_unused 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)
@@ -1248,7 +1244,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.0


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

* [PATCH 09/49] iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (7 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 08/49] iio:accel:mma9553: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 10/49] iio:accel:kxsd9: Switch from CONFIG_PM " Jonathan Cameron
                   ` (41 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
index 517c57ed9e94..88506a5e9402 100644
--- a/drivers/iio/accel/stk8ba50.c
+++ b/drivers/iio/accel/stk8ba50.c
@@ -504,8 +504,7 @@ 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)
+static __maybe_unused int stk8ba50_suspend(struct device *dev)
 {
 	struct stk8ba50_data *data;
 
@@ -514,7 +513,7 @@ static int stk8ba50_suspend(struct device *dev)
 	return stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
 }
 
-static int stk8ba50_resume(struct device *dev)
+static __maybe_unused int stk8ba50_resume(struct device *dev)
 {
 	struct stk8ba50_data *data;
 
@@ -525,11 +524,6 @@ static int stk8ba50_resume(struct device *dev)
 
 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
-
 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_ptr(&stk8ba50_pm_ops),
 		.acpi_match_table = ACPI_PTR(stk8ba50_acpi_id),
 	},
 	.probe =            stk8ba50_probe,
-- 
2.34.0


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

* [PATCH 10/49] iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (8 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 09/49] iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 11/49] iio:adc:ab8500: " Jonathan Cameron
                   ` (40 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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, 5 insertions(+), 7 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 2faf85ca996e..f9954288914b 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -492,8 +492,7 @@ void kxsd9_common_remove(struct device *dev)
 }
 EXPORT_SYMBOL(kxsd9_common_remove);
 
-#ifdef CONFIG_PM
-static int kxsd9_runtime_suspend(struct device *dev)
+static __maybe_unused int kxsd9_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct kxsd9_state *st = iio_priv(indio_dev);
@@ -501,16 +500,15 @@ static int kxsd9_runtime_suspend(struct device *dev)
 	return kxsd9_power_down(st);
 }
 
-static int kxsd9_runtime_resume(struct device *dev)
+static __maybe_unused int kxsd9_runtime_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct kxsd9_state *st = iio_priv(indio_dev);
 
 	return kxsd9_power_up(st);
 }
-#endif /* CONFIG_PM */
 
-const struct dev_pm_ops kxsd9_dev_pm_ops = {
+const __maybe_unused 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,
-- 
2.34.0


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

* [PATCH 11/49] iio:adc:ab8500: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (9 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 10/49] iio:accel:kxsd9: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-25 16:55   ` Linus Walleij
  2021-11-23 21:09 ` [PATCH 12/49] iio:adc:ad7606: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
                   ` (39 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/adc/ab8500-gpadc.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/ab8500-gpadc.c b/drivers/iio/adc/ab8500-gpadc.c
index 4c46a201d4ef..3905213e1bfa 100644
--- a/drivers/iio/adc/ab8500-gpadc.c
+++ b/drivers/iio/adc/ab8500-gpadc.c
@@ -942,8 +942,7 @@ 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)
+static __maybe_unused int ab8500_gpadc_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct ab8500_gpadc *gpadc = iio_priv(indio_dev);
@@ -953,7 +952,7 @@ static int ab8500_gpadc_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int ab8500_gpadc_runtime_resume(struct device *dev)
+static __maybe_unused int ab8500_gpadc_runtime_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct ab8500_gpadc *gpadc = iio_priv(indio_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
@@ -1199,7 +1197,7 @@ static int ab8500_gpadc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct dev_pm_ops ab8500_gpadc_pm_ops = {
+static __maybe_unused 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,
@@ -1212,7 +1210,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.0


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

* [PATCH 12/49] iio:adc:ad7606: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (10 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 11/49] iio:adc:ab8500: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2022-01-01 16:27   ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 13/49] iio:adc:at91-adc: " Jonathan Cameron
                   ` (38 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/adc/ad7606.c     | 8 ++------
 drivers/iio/adc/ad7606.h     | 5 -----
 drivers/iio/adc/ad7606_par.c | 2 +-
 drivers/iio/adc/ad7606_spi.c | 2 +-
 4 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 0a60ecc69d38..16a013aad20f 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -695,9 +695,7 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
 }
 EXPORT_SYMBOL_GPL(ad7606_probe);
 
-#ifdef CONFIG_PM_SLEEP
-
-static int ad7606_suspend(struct device *dev)
+static __maybe_unused int ad7606_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct ad7606_state *st = iio_priv(indio_dev);
@@ -710,7 +708,7 @@ static int ad7606_suspend(struct device *dev)
 	return 0;
 }
 
-static int ad7606_resume(struct device *dev)
+static __maybe_unused int ad7606_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct ad7606_state *st = iio_priv(indio_dev);
@@ -727,8 +725,6 @@ static int ad7606_resume(struct device *dev)
 SIMPLE_DEV_PM_OPS(ad7606_pm_ops, ad7606_suspend, ad7606_resume);
 EXPORT_SYMBOL_GPL(ad7606_pm_ops);
 
-#endif
-
 MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
 MODULE_DESCRIPTION("Analog Devices AD7606 ADC");
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
index 9350ef1f63b5..fd545836790e 100644
--- a/drivers/iio/adc/ad7606.h
+++ b/drivers/iio/adc/ad7606.h
@@ -162,11 +162,6 @@ enum ad7606_supported_device_ids {
 	ID_AD7616,
 };
 
-#ifdef CONFIG_PM_SLEEP
 extern const struct dev_pm_ops ad7606_pm_ops;
-#define AD7606_PM_OPS (&ad7606_pm_ops)
-#else
-#define AD7606_PM_OPS NULL
-#endif
 
 #endif /* IIO_ADC_AD7606_H_ */
diff --git a/drivers/iio/adc/ad7606_par.c b/drivers/iio/adc/ad7606_par.c
index f732b3ac7878..60be3fb4ae39 100644
--- a/drivers/iio/adc/ad7606_par.c
+++ b/drivers/iio/adc/ad7606_par.c
@@ -92,7 +92,7 @@ static struct platform_driver ad7606_driver = {
 	.id_table = ad7606_driver_ids,
 	.driver = {
 		.name = "ad7606",
-		.pm = AD7606_PM_OPS,
+		.pm = pm_ptr(&ad7606_pm_ops),
 		.of_match_table = ad7606_of_match,
 	},
 };
diff --git a/drivers/iio/adc/ad7606_spi.c b/drivers/iio/adc/ad7606_spi.c
index 29945ad07dca..8cc525b4b960 100644
--- a/drivers/iio/adc/ad7606_spi.c
+++ b/drivers/iio/adc/ad7606_spi.c
@@ -352,7 +352,7 @@ static struct spi_driver ad7606_driver = {
 	.driver = {
 		.name = "ad7606",
 		.of_match_table = ad7606_of_match,
-		.pm = AD7606_PM_OPS,
+		.pm = pm_ptr(&ad7606_pm_ops),
 	},
 	.probe = ad7606_spi_probe,
 	.id_table = ad7606_id_table,
-- 
2.34.0


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

* [PATCH 13/49] iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (11 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 12/49] iio:adc:ad7606: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-24  9:16   ` Alexandre Belloni
  2021-11-23 21:09 ` [PATCH 14/49] iio:adc:exynos_adc: " Jonathan Cameron
                   ` (37 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 5a7d3a3a5fa8..14a4735d72b5 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -1234,8 +1234,7 @@ static int at91_adc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int at91_adc_suspend(struct device *dev)
+static __maybe_unused int at91_adc_suspend(struct device *dev)
 {
 	struct iio_dev *idev = dev_get_drvdata(dev);
 	struct at91_adc_state *st = iio_priv(idev);
@@ -1246,7 +1245,7 @@ static int at91_adc_suspend(struct device *dev)
 	return 0;
 }
 
-static int at91_adc_resume(struct device *dev)
+static __maybe_unused int at91_adc_resume(struct device *dev)
 {
 	struct iio_dev *idev = dev_get_drvdata(dev);
 	struct at91_adc_state *st = iio_priv(idev);
@@ -1256,7 +1255,6 @@ 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);
 
@@ -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_ptr(&at91_adc_pm_ops),
 	},
 };
 
-- 
2.34.0


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

* [PATCH 14/49] iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (12 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 13/49] iio:adc:at91-adc: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-25  8:50   ` Krzysztof Kozlowski
  2021-11-23 21:09 ` [PATCH 15/49] iio:adc:palmas_gpadc: " Jonathan Cameron
                   ` (36 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/iio/adc/exynos_adc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 3b3868aa2533..01a801d325a9 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -968,8 +968,7 @@ static int exynos_adc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int exynos_adc_suspend(struct device *dev)
+static __maybe_unused int exynos_adc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct exynos_adc *info = iio_priv(indio_dev);
@@ -982,7 +981,7 @@ static int exynos_adc_suspend(struct device *dev)
 	return 0;
 }
 
-static int exynos_adc_resume(struct device *dev)
+static __maybe_unused int exynos_adc_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct exynos_adc *info = iio_priv(indio_dev);
@@ -1001,7 +1000,6 @@ static int exynos_adc_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static SIMPLE_DEV_PM_OPS(exynos_adc_pm_ops,
 			exynos_adc_suspend,
@@ -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_ptr(&exynos_adc_pm_ops),
 	},
 };
 
-- 
2.34.0


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

* [PATCH 15/49] iio:adc:palmas_gpadc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (13 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 14/49] iio:adc:exynos_adc: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2022-01-01 16:38   ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 16/49] iio:adc:stm32:Switch from CONFIG_PM " Jonathan Cameron
                   ` (35 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
index f9c8385c72d3..98d7764e0662 100644
--- a/drivers/iio/adc/palmas_gpadc.c
+++ b/drivers/iio/adc/palmas_gpadc.c
@@ -653,8 +653,7 @@ 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)
+static __maybe_unused int palmas_adc_wakeup_configure(struct palmas_gpadc *adc)
 {
 	int adc_period, conv;
 	int i;
@@ -759,7 +758,7 @@ static int palmas_adc_wakeup_configure(struct palmas_gpadc *adc)
 	return ret;
 }
 
-static int palmas_adc_wakeup_reset(struct palmas_gpadc *adc)
+static __maybe_unused int palmas_adc_wakeup_reset(struct palmas_gpadc *adc)
 {
 	int ret;
 
@@ -777,7 +776,7 @@ static int palmas_adc_wakeup_reset(struct palmas_gpadc *adc)
 	return ret;
 }
 
-static int palmas_gpadc_suspend(struct device *dev)
+static __maybe_unused int palmas_gpadc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct palmas_gpadc *adc = iio_priv(indio_dev);
@@ -800,7 +799,7 @@ static int palmas_gpadc_suspend(struct device *dev)
 	return 0;
 }
 
-static int palmas_gpadc_resume(struct device *dev)
+static __maybe_unused int palmas_gpadc_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct palmas_gpadc *adc = iio_priv(indio_dev);
@@ -822,9 +821,8 @@ static int palmas_gpadc_resume(struct device *dev)
 
 	return 0;
 };
-#endif
 
-static const struct dev_pm_ops palmas_pm_ops = {
+static __maybe_unused const struct dev_pm_ops palmas_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(palmas_gpadc_suspend,
 				palmas_gpadc_resume)
 };
@@ -840,7 +838,7 @@ static struct platform_driver palmas_gpadc_driver = {
 	.remove = palmas_gpadc_remove,
 	.driver = {
 		.name = MOD_NAME,
-		.pm = &palmas_pm_ops,
+		.pm = pm_ptr(&palmas_pm_ops),
 		.of_match_table = of_palmas_gpadc_match_tbl,
 	},
 };
-- 
2.34.0


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

* [PATCH 16/49] iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (14 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 15/49] iio:adc:palmas_gpadc: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-24  9:33   ` Fabrice Gasnier
  2021-11-23 21:09 ` [PATCH 17/49] iio:adc:rcar: Switch " Jonathan Cameron
                   ` (34 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

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

diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
index b6e18eb101f7..316ae84ab961 100644
--- a/drivers/iio/adc/stm32-adc-core.c
+++ b/drivers/iio/adc/stm32-adc-core.c
@@ -763,28 +763,26 @@ 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)
+static __maybe_unused int stm32_adc_core_runtime_suspend(struct device *dev)
 {
 	stm32_adc_core_hw_stop(dev);
 
 	return 0;
 }
 
-static int stm32_adc_core_runtime_resume(struct device *dev)
+static __maybe_unused int stm32_adc_core_runtime_resume(struct device *dev)
 {
 	return stm32_adc_core_hw_start(dev);
 }
 
-static int stm32_adc_core_runtime_idle(struct device *dev)
+static __maybe_unused int stm32_adc_core_runtime_idle(struct device *dev)
 {
 	pm_runtime_mark_last_busy(dev);
 
 	return 0;
 }
-#endif
 
-static const struct dev_pm_ops stm32_adc_core_pm_ops = {
+static __maybe_unused 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,
@@ -836,7 +834,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 7f1fb36c747c..2d94de6de848 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -2351,8 +2351,7 @@ static int stm32_adc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#if defined(CONFIG_PM_SLEEP)
-static int stm32_adc_suspend(struct device *dev)
+static __maybe_unused int stm32_adc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 
@@ -2362,7 +2361,7 @@ static int stm32_adc_suspend(struct device *dev)
 	return pm_runtime_force_suspend(dev);
 }
 
-static int stm32_adc_resume(struct device *dev)
+static __maybe_unused int stm32_adc_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	int ret;
@@ -2381,21 +2380,18 @@ 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)
+static __maybe_unused int stm32_adc_runtime_suspend(struct device *dev)
 {
 	return stm32_adc_hw_stop(dev);
 }
 
-static int stm32_adc_runtime_resume(struct device *dev)
+static __maybe_unused 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 = {
+static __maybe_unused 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)
@@ -2452,7 +2448,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.0


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

* [PATCH 17/49] iio:adc:rcar: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (15 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 16/49] iio:adc:stm32:Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 18/49] iio:adc:rockchip: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
                   ` (33 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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 | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
index a48895046408..947d72457066 100644
--- a/drivers/iio/adc/rcar-gyroadc.c
+++ b/drivers/iio/adc/rcar-gyroadc.c
@@ -578,8 +578,7 @@ static int rcar_gyroadc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#if defined(CONFIG_PM)
-static int rcar_gyroadc_suspend(struct device *dev)
+static __maybe_unused int rcar_gyroadc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct rcar_gyroadc *priv = iio_priv(indio_dev);
@@ -589,7 +588,7 @@ static int rcar_gyroadc_suspend(struct device *dev)
 	return 0;
 }
 
-static int rcar_gyroadc_resume(struct device *dev)
+static __maybe_unused int rcar_gyroadc_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct rcar_gyroadc *priv = iio_priv(indio_dev);
@@ -598,9 +597,8 @@ static int rcar_gyroadc_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static const struct dev_pm_ops rcar_gyroadc_pm_ops = {
+static __maybe_unused  const struct dev_pm_ops rcar_gyroadc_pm_ops = {
 	SET_RUNTIME_PM_OPS(rcar_gyroadc_suspend, rcar_gyroadc_resume, NULL)
 };
 
@@ -610,7 +608,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.0


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

* [PATCH 18/49] iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (16 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 17/49] iio:adc:rcar: Switch " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 19/49] iio:adc:twl6030: " Jonathan Cameron
                   ` (32 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
index 14b8df4ca9c8..fb3b59d76a97 100644
--- a/drivers/iio/adc/rockchip_saradc.c
+++ b/drivers/iio/adc/rockchip_saradc.c
@@ -481,8 +481,7 @@ 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)
+static __maybe_unused int rockchip_saradc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct rockchip_saradc *info = iio_priv(indio_dev);
@@ -494,7 +493,7 @@ static int rockchip_saradc_suspend(struct device *dev)
 	return 0;
 }
 
-static int rockchip_saradc_resume(struct device *dev)
+static __maybe_unused int rockchip_saradc_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct rockchip_saradc *info = iio_priv(indio_dev);
@@ -514,7 +513,6 @@ static int rockchip_saradc_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
 static SIMPLE_DEV_PM_OPS(rockchip_saradc_pm_ops,
 			 rockchip_saradc_suspend, rockchip_saradc_resume);
@@ -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_ptr(&rockchip_saradc_pm_ops),
 	},
 };
 
-- 
2.34.0


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

* [PATCH 19/49] iio:adc:twl6030: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (17 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 18/49] iio:adc:rockchip: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 20/49] iio:adc:vf610: " Jonathan Cameron
                   ` (31 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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..cf8e4ed749d1 100644
--- a/drivers/iio/adc/twl6030-gpadc.c
+++ b/drivers/iio/adc/twl6030-gpadc.c
@@ -944,8 +944,7 @@ static int twl6030_gpadc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int twl6030_gpadc_suspend(struct device *pdev)
+static __maybe_unused int twl6030_gpadc_suspend(struct device *pdev)
 {
 	int ret;
 
@@ -957,7 +956,7 @@ static int twl6030_gpadc_suspend(struct device *pdev)
 	return 0;
 };
 
-static int twl6030_gpadc_resume(struct device *pdev)
+static __maybe_unused int twl6030_gpadc_resume(struct device *pdev)
 {
 	int ret;
 
@@ -968,7 +967,6 @@ 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);
@@ -978,7 +976,7 @@ static struct platform_driver twl6030_gpadc_driver = {
 	.remove		= twl6030_gpadc_remove,
 	.driver		= {
 		.name	= DRIVER_NAME,
-		.pm	= &twl6030_gpadc_pm_ops,
+		.pm	= pm_ptr(&twl6030_gpadc_pm_ops),
 		.of_match_table = of_twl6030_match_tbl,
 	},
 };
-- 
2.34.0


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

* [PATCH 20/49] iio:adc:vf610: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (18 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 19/49] iio:adc:twl6030: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 21/49] iio:common:ssp: " Jonathan Cameron
                   ` (30 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index fd57fc43e8e5..c05ef6d85093 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -912,8 +912,7 @@ static int vf610_adc_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int vf610_adc_suspend(struct device *dev)
+static __maybe_unused int vf610_adc_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct vf610_adc *info = iio_priv(indio_dev);
@@ -930,7 +929,7 @@ static int vf610_adc_suspend(struct device *dev)
 	return 0;
 }
 
-static int vf610_adc_resume(struct device *dev)
+static __maybe_unused int vf610_adc_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct vf610_adc *info = iio_priv(indio_dev);
@@ -952,7 +951,6 @@ 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);
 
@@ -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_ptr(&vf610_adc_pm_ops),
 	},
 };
 
-- 
2.34.0


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

* [PATCH 21/49] iio:common:ssp: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (19 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 20/49] iio:adc:vf610: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 22/49] iio:dac:vf610: " Jonathan Cameron
                   ` (29 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/common/ssp_sensors/ssp_dev.c b/drivers/iio/common/ssp_sensors/ssp_dev.c
index 1aee87100038..b5d2c69b5cc9 100644
--- a/drivers/iio/common/ssp_sensors/ssp_dev.c
+++ b/drivers/iio/common/ssp_sensors/ssp_dev.c
@@ -612,8 +612,7 @@ static int ssp_remove(struct spi_device *spi)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int ssp_suspend(struct device *dev)
+static __maybe_unused int ssp_suspend(struct device *dev)
 {
 	int ret;
 	struct ssp_data *data = spi_get_drvdata(to_spi_device(dev));
@@ -638,7 +637,7 @@ static int ssp_suspend(struct device *dev)
 	return 0;
 }
 
-static int ssp_resume(struct device *dev)
+static __maybe_unused int ssp_resume(struct device *dev)
 {
 	int ret;
 	struct ssp_data *data = spi_get_drvdata(to_spi_device(dev));
@@ -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)
-};
+static 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_ptr(&ssp_pm_ops),
 		.of_match_table = of_match_ptr(ssp_of_match),
 		.name = "sensorhub"
 	},
-- 
2.34.0


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

* [PATCH 22/49] iio:dac:vf610: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (20 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 21/49] iio:common:ssp: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 23/49] iio:light:apds9300: " Jonathan Cameron
                   ` (28 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c
index 636b4009f763..44b290da078d 100644
--- a/drivers/iio/dac/vf610_dac.c
+++ b/drivers/iio/dac/vf610_dac.c
@@ -242,8 +242,7 @@ static int vf610_dac_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int vf610_dac_suspend(struct device *dev)
+static __maybe_unused int vf610_dac_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct vf610_dac *info = iio_priv(indio_dev);
@@ -254,7 +253,7 @@ static int vf610_dac_suspend(struct device *dev)
 	return 0;
 }
 
-static int vf610_dac_resume(struct device *dev)
+static __maybe_unused int vf610_dac_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct vf610_dac *info = iio_priv(indio_dev);
@@ -268,7 +267,6 @@ 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);
 
@@ -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_ptr(&vf610_dac_pm_ops),
 	},
 };
 module_platform_driver(vf610_dac_driver);
-- 
2.34.0


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

* [PATCH 23/49] iio:light:apds9300: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (21 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 22/49] iio:dac:vf610: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 24/49] iio:light:bh1780: Switch from CONFIG_PM " Jonathan Cameron
                   ` (27 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/light/apds9300.c b/drivers/iio/light/apds9300.c
index baaf202dce05..56dcd255a649 100644
--- a/drivers/iio/light/apds9300.c
+++ b/drivers/iio/light/apds9300.c
@@ -466,8 +466,7 @@ static int apds9300_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int apds9300_suspend(struct device *dev)
+static __maybe_unused int apds9300_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct apds9300_data *data = iio_priv(indio_dev);
@@ -480,7 +479,7 @@ static int apds9300_suspend(struct device *dev)
 	return ret;
 }
 
-static int apds9300_resume(struct device *dev)
+static __maybe_unused int apds9300_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct apds9300_data *data = iio_priv(indio_dev);
@@ -494,10 +493,6 @@ static int apds9300_resume(struct device *dev)
 }
 
 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
 
 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_ptr(&apds9300_pm_ops),
 	},
 	.probe		= apds9300_probe,
 	.remove		= apds9300_remove,
-- 
2.34.0


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

* [PATCH 24/49] iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (22 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 23/49] iio:light:apds9300: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-25 16:56   ` Linus Walleij
  2021-11-23 21:09 ` [PATCH 25/49] iio:light:cm3232: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
                   ` (26 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/light/bh1780.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c
index abbf2e662e7d..d72dd825368a 100644
--- a/drivers/iio/light/bh1780.c
+++ b/drivers/iio/light/bh1780.c
@@ -221,8 +221,7 @@ static int bh1780_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int bh1780_runtime_suspend(struct device *dev)
+static __maybe_unused int bh1780_runtime_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct iio_dev *indio_dev = i2c_get_clientdata(client);
@@ -238,7 +237,7 @@ static int bh1780_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int bh1780_runtime_resume(struct device *dev)
+static __maybe_unused int bh1780_runtime_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct iio_dev *indio_dev = i2c_get_clientdata(client);
@@ -256,9 +255,8 @@ static int bh1780_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM */
 
-static const struct dev_pm_ops bh1780_dev_pm_ops = {
+static __maybe_unused 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,
@@ -284,7 +282,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.0


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

* [PATCH 25/49] iio:light:cm3232: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (23 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 24/49] iio:light:bh1780: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 26/49] iio:light:isl29018: " Jonathan Cameron
                   ` (25 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c
index 18a410340dc5..660f3204dc18 100644
--- a/drivers/iio/light/cm3232.c
+++ b/drivers/iio/light/cm3232.c
@@ -374,8 +374,7 @@ static const struct i2c_device_id cm3232_id[] = {
 	{}
 };
 
-#ifdef CONFIG_PM_SLEEP
-static int cm3232_suspend(struct device *dev)
+static __maybe_unused int cm3232_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct cm3232_chip *chip = iio_priv(indio_dev);
@@ -389,7 +388,7 @@ static int cm3232_suspend(struct device *dev)
 	return ret;
 }
 
-static int cm3232_resume(struct device *dev)
+static __maybe_unused int cm3232_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct cm3232_chip *chip = iio_priv(indio_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
+static 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_ptr(&cm3232_pm_ops),
 	},
 	.id_table	= cm3232_id,
 	.probe		= cm3232_probe,
-- 
2.34.0


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

* [PATCH 26/49] iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (24 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 25/49] iio:light:cm3232: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 27/49] iio:light:isl29125: " Jonathan Cameron
                   ` (24 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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 | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
index 2689867467a8..608bb357b9f6 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -784,8 +784,7 @@ 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)
+static __maybe_unused int isl29018_suspend(struct device *dev)
 {
 	struct isl29018_chip *chip = iio_priv(dev_get_drvdata(dev));
 	int ret;
@@ -807,7 +806,7 @@ static int isl29018_suspend(struct device *dev)
 	return ret;
 }
 
-static int isl29018_resume(struct device *dev)
+static __maybe_unused int isl29018_resume(struct device *dev)
 {
 	struct isl29018_chip *chip = iio_priv(dev_get_drvdata(dev));
 	int err;
@@ -831,10 +830,6 @@ static int isl29018_resume(struct device *dev)
 }
 
 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
 
 #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_ptr(&isl29018_pm_ops),
 			.of_match_table = isl29018_of_match,
 		    },
 	.probe	 = isl29018_probe,
-- 
2.34.0


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

* [PATCH 27/49] iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (25 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 26/49] iio:light:isl29018: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 28/49] iio:light:jsa1212: " Jonathan Cameron
                   ` (23 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
index ba53b50d711a..334267595199 100644
--- a/drivers/iio/light/isl29125.c
+++ b/drivers/iio/light/isl29125.c
@@ -311,22 +311,20 @@ static int isl29125_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int isl29125_suspend(struct device *dev)
+static __maybe_unused int isl29125_suspend(struct device *dev)
 {
 	struct isl29125_data *data = iio_priv(i2c_get_clientdata(
 		to_i2c_client(dev)));
 	return isl29125_powerdown(data);
 }
 
-static int isl29125_resume(struct device *dev)
+static __maybe_unused int isl29125_resume(struct device *dev)
 {
 	struct isl29125_data *data = iio_priv(i2c_get_clientdata(
 		to_i2c_client(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);
 
@@ -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_ptr(&isl29125_pm_ops),
 	},
 	.probe		= isl29125_probe,
 	.remove		= isl29125_remove,
-- 
2.34.0


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

* [PATCH 28/49] iio:light:jsa1212: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (26 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 27/49] iio:light:isl29125: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:09 ` [PATCH 29/49] iio:light:ltr501: " Jonathan Cameron
                   ` (22 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/light/jsa1212.c b/drivers/iio/light/jsa1212.c
index 724a0ec9f35c..218b61595436 100644
--- a/drivers/iio/light/jsa1212.c
+++ b/drivers/iio/light/jsa1212.c
@@ -383,8 +383,7 @@ static int jsa1212_remove(struct i2c_client *client)
 	return jsa1212_power_off(data);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int jsa1212_suspend(struct device *dev)
+static __maybe_unused int jsa1212_suspend(struct device *dev)
 {
 	struct jsa1212_data *data;
 
@@ -393,7 +392,7 @@ static int jsa1212_suspend(struct device *dev)
 	return jsa1212_power_off(data);
 }
 
-static int jsa1212_resume(struct device *dev)
+static __maybe_unused int jsa1212_resume(struct device *dev)
 {
 	int ret = 0;
 	struct jsa1212_data *data;
@@ -423,11 +422,6 @@ static int jsa1212_resume(struct device *dev)
 
 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
-
 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_ptr(&jsa1212_pm_ops),
 		.acpi_match_table = ACPI_PTR(jsa1212_acpi_match),
 	},
 	.probe		= jsa1212_probe,
-- 
2.34.0


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

* [PATCH 29/49] iio:light:ltr501: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (27 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 28/49] iio:light:jsa1212: " Jonathan Cameron
@ 2021-11-23 21:09 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 30/49] iio:light:stk3310: " Jonathan Cameron
                   ` (21 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:09 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index bab5b78f2e30..f64135a4bd0c 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -1586,15 +1586,14 @@ static int ltr501_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int ltr501_suspend(struct device *dev)
+static __maybe_unused int ltr501_suspend(struct device *dev)
 {
 	struct ltr501_data *data = iio_priv(i2c_get_clientdata(
 					    to_i2c_client(dev)));
 	return ltr501_powerdown(data);
 }
 
-static int ltr501_resume(struct device *dev)
+static __maybe_unused int ltr501_resume(struct device *dev)
 {
 	struct ltr501_data *data = iio_priv(i2c_get_clientdata(
 					    to_i2c_client(dev)));
@@ -1602,7 +1601,6 @@ 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);
 
@@ -1636,7 +1634,7 @@ static struct i2c_driver ltr501_driver = {
 	.driver = {
 		.name   = LTR501_DRV_NAME,
 		.of_match_table = ltr501_of_match,
-		.pm	= &ltr501_pm_ops,
+		.pm	= pm_ptr(&ltr501_pm_ops),
 		.acpi_match_table = ACPI_PTR(ltr_acpi_match),
 	},
 	.probe  = ltr501_probe,
-- 
2.34.0


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

* [PATCH 30/49] iio:light:stk3310: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (28 preceding siblings ...)
  2021-11-23 21:09 ` [PATCH 29/49] iio:light:ltr501: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 31/49] iio:light:tcs3414: " Jonathan Cameron
                   ` (20 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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 | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
index 07e91846307c..fc2d5ebf0d68 100644
--- a/drivers/iio/light/stk3310.c
+++ b/drivers/iio/light/stk3310.c
@@ -632,8 +632,7 @@ 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)
+static __maybe_unused int stk3310_suspend(struct device *dev)
 {
 	struct stk3310_data *data;
 
@@ -642,7 +641,7 @@ static int stk3310_suspend(struct device *dev)
 	return stk3310_set_state(data, STK3310_STATE_STANDBY);
 }
 
-static int stk3310_resume(struct device *dev)
+static __maybe_unused int stk3310_resume(struct device *dev)
 {
 	u8 state = 0;
 	struct stk3310_data *data;
@@ -658,11 +657,6 @@ static int stk3310_resume(struct device *dev)
 
 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
-
 static const struct i2c_device_id stk3310_i2c_id[] = {
 	{"STK3310", 0},
 	{"STK3311", 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_ptr(&stk3310_pm_ops),
 		.acpi_match_table = ACPI_PTR(stk3310_acpi_id),
 	},
 	.probe =            stk3310_probe,
-- 
2.34.0


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

* [PATCH 31/49] iio:light:tcs3414: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (29 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 30/49] iio:light:stk3310: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 32/49] iio:light:tcs3472: " Jonathan Cameron
                   ` (19 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/light/tcs3414.c b/drivers/iio/light/tcs3414.c
index b87222141429..e6e49054ddfa 100644
--- a/drivers/iio/light/tcs3414.c
+++ b/drivers/iio/light/tcs3414.c
@@ -345,22 +345,20 @@ 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)
+static __maybe_unused int tcs3414_suspend(struct device *dev)
 {
 	struct tcs3414_data *data = iio_priv(i2c_get_clientdata(
 		to_i2c_client(dev)));
 	return tcs3414_powerdown(data);
 }
 
-static int tcs3414_resume(struct device *dev)
+static __maybe_unused int tcs3414_resume(struct device *dev)
 {
 	struct tcs3414_data *data = iio_priv(i2c_get_clientdata(
 		to_i2c_client(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);
 
@@ -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_ptr(&tcs3414_pm_ops),
 	},
 	.probe		= tcs3414_probe,
 	.id_table	= tcs3414_id,
-- 
2.34.0


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

* [PATCH 32/49] iio:light:tcs3472: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (30 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 31/49] iio:light:tcs3414: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 33/49] iio:light:tsl2563: " Jonathan Cameron
                   ` (18 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
index 371c6a39a165..ff548a562fc2 100644
--- a/drivers/iio/light/tcs3472.c
+++ b/drivers/iio/light/tcs3472.c
@@ -572,15 +572,14 @@ static int tcs3472_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int tcs3472_suspend(struct device *dev)
+static __maybe_unused int tcs3472_suspend(struct device *dev)
 {
 	struct tcs3472_data *data = iio_priv(i2c_get_clientdata(
 		to_i2c_client(dev)));
 	return tcs3472_powerdown(data);
 }
 
-static int tcs3472_resume(struct device *dev)
+static __maybe_unused int tcs3472_resume(struct device *dev)
 {
 	struct tcs3472_data *data = iio_priv(i2c_get_clientdata(
 		to_i2c_client(dev)));
@@ -598,7 +597,6 @@ static int tcs3472_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
 static SIMPLE_DEV_PM_OPS(tcs3472_pm_ops, tcs3472_suspend, tcs3472_resume);
 
@@ -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_ptr(&tcs3472_pm_ops),
 	},
 	.probe		= tcs3472_probe,
 	.remove		= tcs3472_remove,
-- 
2.34.0


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

* [PATCH 33/49] iio:light:tsl2563: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (31 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 32/49] iio:light:tcs3472: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 34/49] iio:light:tsl4531: " Jonathan Cameron
                   ` (17 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
index 5bf2bfbc5379..49a45c78603c 100644
--- a/drivers/iio/light/tsl2563.c
+++ b/drivers/iio/light/tsl2563.c
@@ -814,8 +814,7 @@ static int tsl2563_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int tsl2563_suspend(struct device *dev)
+static __maybe_unused int tsl2563_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct tsl2563_chip *chip = iio_priv(indio_dev);
@@ -834,7 +833,7 @@ static int tsl2563_suspend(struct device *dev)
 	return ret;
 }
 
-static int tsl2563_resume(struct device *dev)
+static __maybe_unused int tsl2563_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct tsl2563_chip *chip = iio_priv(indio_dev);
@@ -858,10 +857,6 @@ static int tsl2563_resume(struct device *dev)
 }
 
 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
 
 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_ptr(&tsl2563_pm_ops),
 	},
 	.probe		= tsl2563_probe,
 	.remove		= tsl2563_remove,
-- 
2.34.0


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

* [PATCH 34/49] iio:light:tsl4531: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (32 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 33/49] iio:light:tsl2563: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 35/49] iio:light:us5182: Switch from CONFIG_PM " Jonathan Cameron
                   ` (16 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c
index 70505ba6d858..8632927bc077 100644
--- a/drivers/iio/light/tsl4531.c
+++ b/drivers/iio/light/tsl4531.c
@@ -215,23 +215,18 @@ static int tsl4531_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int tsl4531_suspend(struct device *dev)
+static __maybe_unused int tsl4531_suspend(struct device *dev)
 {
 	return tsl4531_powerdown(to_i2c_client(dev));
 }
 
-static int tsl4531_resume(struct device *dev)
+static __maybe_unused int tsl4531_resume(struct device *dev)
 {
 	return i2c_smbus_write_byte_data(to_i2c_client(dev), TSL4531_CONTROL,
 		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
 
 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_ptr(&tsl4531_pm_ops),
 	},
 	.probe  = tsl4531_probe,
 	.remove = tsl4531_remove,
-- 
2.34.0


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

* [PATCH 35/49] iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (33 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 34/49] iio:light:tsl4531: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 36/49] iio:magn:ak8975: " Jonathan Cameron
                   ` (15 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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 | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c
index 96e4a66ddf28..79d589f2fb79 100644
--- a/drivers/iio/light/us5182d.c
+++ b/drivers/iio/light/us5182d.c
@@ -916,8 +916,7 @@ 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)
+static __maybe_unused int us5182d_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct us5182d_data *data = iio_priv(indio_dev);
@@ -928,7 +927,7 @@ static int us5182d_suspend(struct device *dev)
 	return 0;
 }
 
-static int us5182d_resume(struct device *dev)
+static __maybe_unused int us5182d_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct us5182d_data *data = iio_priv(indio_dev);
@@ -939,9 +938,8 @@ static int us5182d_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
-static const struct dev_pm_ops us5182d_pm_ops = {
+static __maybe_unused 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)
 };
@@ -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.0


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

* [PATCH 36/49] iio:magn:ak8975: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (34 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 35/49] iio:light:us5182: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 22:24   ` Matt Ranostay
  2021-11-23 21:10 ` [PATCH 37/49] iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
                   ` (14 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

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

diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 6e82dc54a417..ced3e674eb5f 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -1033,8 +1033,7 @@ static int ak8975_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int ak8975_runtime_suspend(struct device *dev)
+static __maybe_unused int ak8975_runtime_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct iio_dev *indio_dev = i2c_get_clientdata(client);
@@ -1053,7 +1052,7 @@ static int ak8975_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int ak8975_runtime_resume(struct device *dev)
+static __maybe_unused int ak8975_runtime_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct iio_dev *indio_dev = i2c_get_clientdata(client);
@@ -1074,9 +1073,8 @@ static int ak8975_runtime_resume(struct device *dev)
 
 	return 0;
 }
-#endif /* CONFIG_PM */
 
-static const struct dev_pm_ops ak8975_dev_pm_ops = {
+static __maybe_unused 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,
@@ -1113,7 +1111,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.0


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

* [PATCH 37/49] iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (35 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 36/49] iio:magn:ak8975: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2022-01-01 17:40   ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 38/49] iio:magn:mag3110: " Jonathan Cameron
                   ` (13 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/magnetometer/hmc5843.h     | 5 -----
 drivers/iio/magnetometer/hmc5843_i2c.c | 2 +-
 drivers/iio/magnetometer/hmc5843_spi.c | 2 +-
 3 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/magnetometer/hmc5843.h b/drivers/iio/magnetometer/hmc5843.h
index 9120c8bbf3dd..c3444f3ab1dc 100644
--- a/drivers/iio/magnetometer/hmc5843.h
+++ b/drivers/iio/magnetometer/hmc5843.h
@@ -55,13 +55,8 @@ void hmc5843_common_remove(struct device *dev);
 int hmc5843_common_suspend(struct device *dev);
 int hmc5843_common_resume(struct device *dev);
 
-#ifdef CONFIG_PM_SLEEP
 static __maybe_unused SIMPLE_DEV_PM_OPS(hmc5843_pm_ops,
 					hmc5843_common_suspend,
 					hmc5843_common_resume);
-#define HMC5843_PM_OPS (&hmc5843_pm_ops)
-#else
-#define HMC5843_PM_OPS NULL
-#endif
 
 #endif /* HMC5843_CORE_H */
diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c b/drivers/iio/magnetometer/hmc5843_i2c.c
index bc6e12f1d521..a7359f439f10 100644
--- a/drivers/iio/magnetometer/hmc5843_i2c.c
+++ b/drivers/iio/magnetometer/hmc5843_i2c.c
@@ -93,7 +93,7 @@ MODULE_DEVICE_TABLE(of, hmc5843_of_match);
 static struct i2c_driver hmc5843_driver = {
 	.driver = {
 		.name	= "hmc5843",
-		.pm	= HMC5843_PM_OPS,
+		.pm	= pm_ptr(&hmc5843_pm_ops),
 		.of_match_table = hmc5843_of_match,
 	},
 	.id_table	= hmc5843_id,
diff --git a/drivers/iio/magnetometer/hmc5843_spi.c b/drivers/iio/magnetometer/hmc5843_spi.c
index 89cf59a62c28..c1bd2ff3c64a 100644
--- a/drivers/iio/magnetometer/hmc5843_spi.c
+++ b/drivers/iio/magnetometer/hmc5843_spi.c
@@ -90,7 +90,7 @@ MODULE_DEVICE_TABLE(spi, hmc5843_id);
 static struct spi_driver hmc5843_driver = {
 		.driver = {
 				.name = "hmc5843",
-				.pm = HMC5843_PM_OPS,
+				.pm = pm_ptr(&hmc5843_pm_ops),
 		},
 		.id_table = hmc5843_id,
 		.probe = hmc5843_spi_probe,
-- 
2.34.0


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

* [PATCH 38/49] iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (36 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 37/49] iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 39/49] iio:magn:mmc35240: " Jonathan Cameron
                   ` (12 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c
index 17c62d806218..475fdff037f7 100644
--- a/drivers/iio/magnetometer/mag3110.c
+++ b/drivers/iio/magnetometer/mag3110.c
@@ -573,8 +573,7 @@ static int mag3110_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int mag3110_suspend(struct device *dev)
+static __maybe_unused int mag3110_suspend(struct device *dev)
 {
 	struct mag3110_data *data = iio_priv(i2c_get_clientdata(
 		to_i2c_client(dev)));
@@ -600,7 +599,7 @@ static int mag3110_suspend(struct device *dev)
 	return 0;
 }
 
-static int mag3110_resume(struct device *dev)
+static __maybe_unused int mag3110_resume(struct device *dev)
 {
 	struct mag3110_data *data = iio_priv(i2c_get_clientdata(
 		to_i2c_client(dev)));
@@ -624,10 +623,6 @@ static int mag3110_resume(struct device *dev)
 }
 
 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
 
 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_ptr(&mag3110_pm_ops),
 	},
 	.probe = mag3110_probe,
 	.remove = mag3110_remove,
-- 
2.34.0


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

* [PATCH 39/49] iio:magn:mmc35240: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (37 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 38/49] iio:magn:mag3110: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 40/49] iio:pressure:mpl3115: " Jonathan Cameron
                   ` (11 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
index 65f3d1ed0d59..57ecb6adeb1b 100644
--- a/drivers/iio/magnetometer/mmc35240.c
+++ b/drivers/iio/magnetometer/mmc35240.c
@@ -521,8 +521,7 @@ 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)
+static __maybe_unused int mmc35240_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct mmc35240_data *data = iio_priv(indio_dev);
@@ -532,7 +531,7 @@ static int mmc35240_suspend(struct device *dev)
 	return 0;
 }
 
-static int mmc35240_resume(struct device *dev)
+static __maybe_unused int mmc35240_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct mmc35240_data *data = iio_priv(indio_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)
-};
+static 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_ptr(&mmc35240_pm_ops),
 		.acpi_match_table = ACPI_PTR(mmc35240_acpi_match),
 	},
 	.probe		= mmc35240_probe,
-- 
2.34.0


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

* [PATCH 40/49] iio:pressure:mpl3115: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (38 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 39/49] iio:magn:mmc35240: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 41/49] iio:pressure:bmp280: Switch from CONFIG_PM " Jonathan Cameron
                   ` (10 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c
index e95b9a5475b4..8148655537c9 100644
--- a/drivers/iio/pressure/mpl3115.c
+++ b/drivers/iio/pressure/mpl3115.c
@@ -301,14 +301,13 @@ static int mpl3115_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int mpl3115_suspend(struct device *dev)
+static __maybe_unused int mpl3115_suspend(struct device *dev)
 {
 	return mpl3115_standby(iio_priv(i2c_get_clientdata(
 		to_i2c_client(dev))));
 }
 
-static int mpl3115_resume(struct device *dev)
+static __maybe_unused int mpl3115_resume(struct device *dev)
 {
 	struct mpl3115_data *data = iio_priv(i2c_get_clientdata(
 		to_i2c_client(dev)));
@@ -318,10 +317,6 @@ static int mpl3115_resume(struct device *dev)
 }
 
 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
 
 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_ptr(&mpl3115_pm_ops),
 	},
 	.probe = mpl3115_probe,
 	.remove = mpl3115_remove,
-- 
2.34.0


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

* [PATCH 41/49] iio:pressure:bmp280: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (39 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 40/49] iio:pressure:mpl3115: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-25 16:56   ` Linus Walleij
  2022-01-01 17:50   ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 42/49] iio:proximity:as3935: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
                   ` (9 subsequent siblings)
  50 siblings, 2 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/pressure/bmp280-core.c | 6 ++----
 drivers/iio/pressure/bmp280-i2c.c  | 2 +-
 drivers/iio/pressure/bmp280-spi.c  | 2 +-
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 6b7da40f99c8..0653e1ea88da 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -1138,8 +1138,7 @@ int bmp280_common_probe(struct device *dev,
 }
 EXPORT_SYMBOL(bmp280_common_probe);
 
-#ifdef CONFIG_PM
-static int bmp280_runtime_suspend(struct device *dev)
+static __maybe_unused int bmp280_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct bmp280_data *data = iio_priv(indio_dev);
@@ -1147,7 +1146,7 @@ static int bmp280_runtime_suspend(struct device *dev)
 	return regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies);
 }
 
-static int bmp280_runtime_resume(struct device *dev)
+static __maybe_unused int bmp280_runtime_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct bmp280_data *data = iio_priv(indio_dev);
@@ -1159,7 +1158,6 @@ static int bmp280_runtime_resume(struct device *dev)
 	usleep_range(data->start_up_time, data->start_up_time + 100);
 	return data->chip_info->chip_config(data);
 }
-#endif /* CONFIG_PM */
 
 const struct dev_pm_ops bmp280_dev_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c
index 8b03ea15c0d0..35045bd92846 100644
--- a/drivers/iio/pressure/bmp280-i2c.c
+++ b/drivers/iio/pressure/bmp280-i2c.c
@@ -58,7 +58,7 @@ static struct i2c_driver bmp280_i2c_driver = {
 	.driver = {
 		.name	= "bmp280",
 		.of_match_table = bmp280_of_i2c_match,
-		.pm = &bmp280_dev_pm_ops,
+		.pm = pm_ptr(&bmp280_dev_pm_ops),
 	},
 	.probe		= bmp280_i2c_probe,
 	.id_table	= bmp280_i2c_id,
diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c
index 625b86878ad8..41f6cc56d229 100644
--- a/drivers/iio/pressure/bmp280-spi.c
+++ b/drivers/iio/pressure/bmp280-spi.c
@@ -109,7 +109,7 @@ static struct spi_driver bmp280_spi_driver = {
 	.driver = {
 		.name = "bmp280",
 		.of_match_table = bmp280_of_spi_match,
-		.pm = &bmp280_dev_pm_ops,
+		.pm = pm_ptr(&bmp280_dev_pm_ops),
 	},
 	.id_table = bmp280_spi_id,
 	.probe = bmp280_spi_probe,
-- 
2.34.0


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

* [PATCH 42/49] iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (40 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 41/49] iio:pressure:bmp280: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 22:23   ` Matt Ranostay
  2021-11-23 21:10 ` [PATCH 43/49] iio:proximity:pulsedlight: Switch from CONFIG_PM " Jonathan Cameron
                   ` (8 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
index d62766b6b39e..605c6095d704 100644
--- a/drivers/iio/proximity/as3935.c
+++ b/drivers/iio/proximity/as3935.c
@@ -295,8 +295,7 @@ 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)
+static __maybe_unused int as3935_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct as3935_state *st = iio_priv(indio_dev);
@@ -316,7 +315,7 @@ static int as3935_suspend(struct device *dev)
 	return ret;
 }
 
-static int as3935_resume(struct device *dev)
+static __maybe_unused int as3935_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct as3935_state *st = iio_priv(indio_dev);
@@ -338,11 +337,6 @@ static int as3935_resume(struct device *dev)
 }
 
 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
 
 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_ptr(&as3935_pm_ops),
 	},
 	.probe		= as3935_probe,
 	.id_table	= as3935_id,
-- 
2.34.0


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

* [PATCH 43/49] iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (41 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 42/49] iio:proximity:as3935: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 22:22   ` Matt Ranostay
  2021-11-23 21:10 ` [PATCH 44/49] iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
                   ` (7 subsequent siblings)
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

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

diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
index 27026c060ab9..6adc2a0c27cb 100644
--- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
+++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
@@ -338,8 +338,7 @@ 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)
+static __maybe_unused int lidar_pm_runtime_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct lidar_data *data = iio_priv(indio_dev);
@@ -347,7 +346,7 @@ static int lidar_pm_runtime_suspend(struct device *dev)
 	return lidar_write_power(data, 0x0f);
 }
 
-static int lidar_pm_runtime_resume(struct device *dev)
+static __maybe_unused int lidar_pm_runtime_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct lidar_data *data = iio_priv(indio_dev);
@@ -358,9 +357,8 @@ static int lidar_pm_runtime_resume(struct device *dev)
 
 	return ret;
 }
-#endif
 
-static const struct dev_pm_ops lidar_pm_ops = {
+static __maybe_unused const struct dev_pm_ops lidar_pm_ops = {
 	SET_RUNTIME_PM_OPS(lidar_pm_runtime_suspend,
 			   lidar_pm_runtime_resume, NULL)
 };
@@ -369,7 +367,7 @@ 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.0


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

* [PATCH 44/49] iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (42 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 43/49] iio:proximity:pulsedlight: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 45/49] iio:proximity:sx9500: " Jonathan Cameron
                   ` (6 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77402.c
index 8c06d02139b6..456afeb71db1 100644
--- a/drivers/iio/proximity/rfd77402.c
+++ b/drivers/iio/proximity/rfd77402.c
@@ -295,17 +295,15 @@ 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)
+static __maybe_unused int rfd77402_suspend(struct device *dev)
 {
 	return rfd77402_powerdown(to_i2c_client(dev));
 }
 
-static int rfd77402_resume(struct device *dev)
+static __maybe_unused 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);
 
@@ -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_ptr(&rfd77402_pm_ops),
 	},
 	.probe  = rfd77402_probe,
 	.id_table = rfd77402_id,
-- 
2.34.0


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

* [PATCH 45/49] iio:proximity:sx9500: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (43 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 44/49] iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 46/49] iio:temperature:tmp006: " Jonathan Cameron
                   ` (5 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 3e4ddb2e8c2b..f59bee2707ca 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -993,8 +993,7 @@ static int sx9500_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int sx9500_suspend(struct device *dev)
+static __maybe_unused int sx9500_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct sx9500_data *data = iio_priv(indio_dev);
@@ -1017,7 +1016,7 @@ static int sx9500_suspend(struct device *dev)
 	return ret;
 }
 
-static int sx9500_resume(struct device *dev)
+static __maybe_unused int sx9500_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
 	struct sx9500_data *data = iio_priv(indio_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)
-};
+static 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_ptr(&sx9500_pm_ops),
 	},
 	.probe		= sx9500_probe,
 	.remove		= sx9500_remove,
-- 
2.34.0


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

* [PATCH 46/49] iio:temperature:tmp006: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (44 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 45/49] iio:proximity:sx9500: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 47/49] iio:temperature:tmp007: " Jonathan Cameron
                   ` (4 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c
index e4943a0bc9aa..beac388e56f5 100644
--- a/drivers/iio/temperature/tmp006.c
+++ b/drivers/iio/temperature/tmp006.c
@@ -261,17 +261,15 @@ 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)
+static __maybe_unused int tmp006_suspend(struct device *dev)
 {
 	return tmp006_power(dev, false);
 }
 
-static int tmp006_resume(struct device *dev)
+static __maybe_unused int tmp006_resume(struct device *dev)
 {
 	return tmp006_power(dev, true);
 }
-#endif
 
 static SIMPLE_DEV_PM_OPS(tmp006_pm_ops, tmp006_suspend, tmp006_resume);
 
@@ -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_ptr(&tmp006_pm_ops),
 	},
 	.probe = tmp006_probe,
 	.id_table = tmp006_id,
-- 
2.34.0


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

* [PATCH 47/49] iio:temperature:tmp007: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (45 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 46/49] iio:temperature:tmp006: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 48/49] iio:gyro:mpu3050: Switch from CONFIG_PM " Jonathan Cameron
                   ` (3 subsequent siblings)
  50 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

The pm_ptr() macro only removes the reference if CONFIG_PM is not
set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
will not always remove the pm_ops structure.

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

diff --git a/drivers/iio/temperature/tmp007.c b/drivers/iio/temperature/tmp007.c
index b422371a4674..9a1b7f63500e 100644
--- a/drivers/iio/temperature/tmp007.c
+++ b/drivers/iio/temperature/tmp007.c
@@ -537,8 +537,7 @@ 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)
+static __maybe_unused int tmp007_suspend(struct device *dev)
 {
 	struct tmp007_data *data = iio_priv(i2c_get_clientdata(
 			to_i2c_client(dev)));
@@ -546,7 +545,7 @@ static int tmp007_suspend(struct device *dev)
 	return tmp007_powerdown(data);
 }
 
-static int tmp007_resume(struct device *dev)
+static __maybe_unused int tmp007_resume(struct device *dev)
 {
 	struct tmp007_data *data = iio_priv(i2c_get_clientdata(
 			to_i2c_client(dev)));
@@ -554,7 +553,6 @@ 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);
 
@@ -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_ptr(&tmp007_pm_ops),
 	},
 	.probe		= tmp007_probe,
 	.id_table	= tmp007_id,
-- 
2.34.0


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

* [PATCH 48/49] iio:gyro:mpu3050: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (46 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 47/49] iio:temperature:tmp007: " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-25 16:56   ` Linus Walleij
  2022-01-01 18:00   ` Jonathan Cameron
  2021-11-23 21:10 ` [PATCH 49/49] iio:chemical:atlas: " Jonathan Cameron
                   ` (2 subsequent siblings)
  50 siblings, 2 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/iio/gyro/mpu3050-core.c | 8 +++-----
 drivers/iio/gyro/mpu3050-i2c.c  | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
index ea387efab62d..4ec107b9e779 100644
--- a/drivers/iio/gyro/mpu3050-core.c
+++ b/drivers/iio/gyro/mpu3050-core.c
@@ -1281,19 +1281,17 @@ int mpu3050_common_remove(struct device *dev)
 }
 EXPORT_SYMBOL(mpu3050_common_remove);
 
-#ifdef CONFIG_PM
-static int mpu3050_runtime_suspend(struct device *dev)
+static __maybe_unused int mpu3050_runtime_suspend(struct device *dev)
 {
 	return mpu3050_power_down(iio_priv(dev_get_drvdata(dev)));
 }
 
-static int mpu3050_runtime_resume(struct device *dev)
+static __maybe_unused int mpu3050_runtime_resume(struct device *dev)
 {
 	return mpu3050_power_up(iio_priv(dev_get_drvdata(dev)));
 }
-#endif /* CONFIG_PM */
 
-const struct dev_pm_ops mpu3050_dev_pm_ops = {
+const __maybe_unused struct dev_pm_ops mpu3050_dev_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
 				pm_runtime_force_resume)
 	SET_RUNTIME_PM_OPS(mpu3050_runtime_suspend,
diff --git a/drivers/iio/gyro/mpu3050-i2c.c b/drivers/iio/gyro/mpu3050-i2c.c
index ef5bcbc4b45b..820133cad601 100644
--- a/drivers/iio/gyro/mpu3050-i2c.c
+++ b/drivers/iio/gyro/mpu3050-i2c.c
@@ -114,7 +114,7 @@ static struct i2c_driver mpu3050_i2c_driver = {
 	.driver = {
 		.of_match_table = mpu3050_i2c_of_match,
 		.name = "mpu3050-i2c",
-		.pm = &mpu3050_dev_pm_ops,
+		.pm = pm_ptr(&mpu3050_dev_pm_ops),
 	},
 };
 module_i2c_driver(mpu3050_i2c_driver);
-- 
2.34.0


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

* [PATCH 49/49] iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (47 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 48/49] iio:gyro:mpu3050: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-23 21:10 ` Jonathan Cameron
  2021-11-23 22:22   ` Matt Ranostay
  2021-11-23 22:11 ` [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Paul Cercueil
  2021-11-24  0:58 ` Brian Masney
  50 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-23 21:10 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, 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.

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

diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
index 04b44a327614..7bacd0bd6f19 100644
--- a/drivers/iio/chemical/atlas-sensor.c
+++ b/drivers/iio/chemical/atlas-sensor.c
@@ -737,8 +737,7 @@ 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)
+static __maybe_unused int atlas_runtime_suspend(struct device *dev)
 {
 	struct atlas_data *data =
 		     iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
@@ -746,16 +745,15 @@ static int atlas_runtime_suspend(struct device *dev)
 	return atlas_set_powermode(data, 0);
 }
 
-static int atlas_runtime_resume(struct device *dev)
+static __maybe_unused int atlas_runtime_resume(struct device *dev)
 {
 	struct atlas_data *data =
 		     iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
 
 	return atlas_set_powermode(data, 1);
 }
-#endif
 
-static const struct dev_pm_ops atlas_pm_ops = {
+static __maybe_unused const struct dev_pm_ops atlas_pm_ops = {
 	SET_RUNTIME_PM_OPS(atlas_runtime_suspend,
 			   atlas_runtime_resume, NULL)
 };
@@ -764,7 +762,7 @@ 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.0


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

* Re: [PATCH 05/49] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 ` [PATCH 05/49] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2021-11-23 21:37   ` Hans de Goede
  0 siblings, 0 replies; 83+ messages in thread
From: Hans de Goede @ 2021-11-23 21:37 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron

Hi,

On 11/23/21 22:09, 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.
> 
> The pm_ptr() macro only removes the reference if CONFIG_PM is not
> set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> will not always remove the pm_ops structure.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Hans de Goede <hdegoede@redhat.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>  drivers/iio/accel/mc3230.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c
> index 735002b716f3..139c7f6839df 100644
> --- a/drivers/iio/accel/mc3230.c
> +++ b/drivers/iio/accel/mc3230.c
> @@ -160,8 +160,7 @@ 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)
> +static __maybe_unused int mc3230_suspend(struct device *dev)
>  {
>  	struct mc3230_data *data;
>  
> @@ -170,7 +169,7 @@ static int mc3230_suspend(struct device *dev)
>  	return mc3230_set_opcon(data, MC3230_MODE_OPCON_STANDBY);
>  }
>  
> -static int mc3230_resume(struct device *dev)
> +static __maybe_unused int mc3230_resume(struct device *dev)
>  {
>  	struct mc3230_data *data;
>  
> @@ -178,7 +177,6 @@ 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);
>  
> @@ -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_ptr(&mc3230_pm_ops),
>  	},
>  	.probe		= mc3230_probe,
>  	.remove		= mc3230_remove,
> 


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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (48 preceding siblings ...)
  2021-11-23 21:10 ` [PATCH 49/49] iio:chemical:atlas: " Jonathan Cameron
@ 2021-11-23 22:11 ` Paul Cercueil
  2021-11-24  7:29   ` Arnd Bergmann
  2021-11-27 18:02   ` Jonathan Cameron
  2021-11-24  0:58 ` Brian Masney
  50 siblings, 2 replies; 83+ messages in thread
From: Paul Cercueil @ 2021-11-23 22:11 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Lars-Peter Clausen, Jonathan Cameron,
	Alexandre Belloni, Anson Huang, Brian Masney, 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, Olivier Moysan, Stefan-Gabriel Mirea,
	Vaishnav M A, Arnd Bergmann

Hi Jonathan,

Cc'd Arnd who may have some interest in the topic.

Le mar., nov. 23 2021 at 21:09:30 +0000, Jonathan Cameron 
<jic23@kernel.org> a écrit :
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Note this series includes many drivers that are quite old and I'm not
> sure have active maintainers.  Hence if anyone has time to look at 
> some
> of these beyond their own drivers and sanity check them it would be 
> much
> appreciated!
> 
> Two motivations behind this set.
> 1 - General code reduction and improvement in readability in these 
> drivers.
> 2 - Reduce change I'll have to ask people to change how they do this 
> in
>     future patches.
> 
> Mostly this is just a case of letting the compiler work out it can 
> remove
> the PM related functions rather than using #ifdefs in the code to do 
> so.
> 
> The __maybe_unused markings make it clear we are intentionally 
> building
> functions that the compiler can see are unused and remove in some 
> build
> configurations.
> 
> The new pm_ptr() macro is rather convenient to got futher than many of
> the drivers were and when CONFIG_PM is not define ensure that the
> struct dev_pm_ops can also be removed.  Note there is a subtlty in 
> that
> we only remove that whe CONFIG_PM is not defined whereas a few of 
> these
> drivers were using CONFIG_PM_SLEEP which is a tighter condition (will
> remove the structure in more configurations).  I think that's a small
> price to pay for the convenience this macro brings.
> 
> I did this set as one patch per driver, as personally I prefer that
> option for all but the most trivial patches because it makes backports
> that cross with this series simpler and also avoid the complex
> tag giving we get for sets touching code from many authors.
> 
> All comments welcome.

One word about the pm_ptr() macro. Right now it's defined as:
  #ifdef CONFIG_PM
  #define pm_ptr(_ptr) (_ptr)
  #else
  #define pm_ptr(_ptr) NULL
  #endif

It could be possible to define it like this instead:
  #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))

The difference is that if !CONFIG_PM, in the first case the (_ptr) is 
not visible by the compiler and the __maybe_unused is required, while 
in the second case the (_ptr) is always visible by the compiler, but 
discarded as dead code. The reason we'd want that is the same reason we 
use IS_ENABLED() instead of macro guards; and you wouldn't need the 
__maybe_unused attribute anywhere.

The problem then is that the SET_*_PM_OPS macros are defined 
differently according to CONFIG_PM, so their definition would need to 
be changed to use the (redefined) pm_ptr() macro and a corresponding 
pm_sleep_ptr() macro. Unfortunately since the SET_*_PM_OPS macros are 
used everywhere with code wrapped around #ifdef CONFIG_PM guards, it 
wouldn't be easy to change them, and it would just be easier to 
introduce new macros.

The patchset looks fine as-is and I am not asking you to work on 
anything I just said, I just thought it was worth mentioning.

Cheers,
-Paul

> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Anson Huang <anson.huang@nxp.com>
> Cc: Brian Masney <masneyb@onstation.org>
> 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: 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 (49):
>   iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:accel:da280: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:accel:dmard06: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:accel:dmard10: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:accel:mc3230: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:accel:mma9553: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:adc:ab8500: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:adc:ad7606: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:adc:palmas_gpadc: Switch from CONFIG_PM_SLEEP guards to 
> pm_ptr() /
>     __maybe_unused
>   iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:adc:rcar: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:adc:twl6030: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:adc:vf610: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:common:ssp: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:dac:vf610: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:apds9300: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:light:cm3232: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:jsa1212: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:ltr501: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:stk3310: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:tcs3414: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:tcs3472: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:tsl2563: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:tsl4531: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:magn:ak8975: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:magn:mmc35240: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
>     __maybe_unused
>   iio:pressure:mpl3115: Switch from CONFIG_PM_SLEEP guards to 
> pm_ptr() /
>     __maybe_unused
>   iio:pressure:bmp280: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to 
> pm_ptr() /
>     __maybe_unused
>   iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() 
> /
>     __maybe_unused
>   iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to 
> pm_ptr()
>     / __maybe_unused
>   iio:proximity:sx9500: Switch from CONFIG_PM_SLEEP guards to 
> pm_ptr() /
>     __maybe_unused
>   iio:temperature:tmp006: Switch from CONFIG_PM_SLEEP guards to 
> pm_ptr()
>     / __maybe_unused
>   iio:temperature:tmp007: Switch from CONFIG_PM_SLEEP guards to 
> pm_ptr()
>     / __maybe_unused
>   iio:gyro:mpu3050: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
>   iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() /
>     __maybe_unused
> 
>  drivers/iio/accel/da280.c                        |  6 ++----
>  drivers/iio/accel/da311.c                        |  8 +++-----
>  drivers/iio/accel/dmard06.c                      | 12 ++++--------
>  drivers/iio/accel/dmard10.c                      |  9 ++++-----
>  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                       |  8 +++-----
>  drivers/iio/accel/mma7660.c                      | 12 +++---------
>  drivers/iio/accel/mma9551.c                      | 16 
> ++++++----------
>  drivers/iio/accel/mma9553.c                      | 16 
> ++++++----------
>  drivers/iio/accel/stk8ba50.c                     | 12 +++---------
>  drivers/iio/adc/ab8500-gpadc.c                   | 10 ++++------
>  drivers/iio/adc/ad7606.c                         |  8 ++------
>  drivers/iio/adc/ad7606.h                         |  5 -----
>  drivers/iio/adc/ad7606_par.c                     |  2 +-
>  drivers/iio/adc/ad7606_spi.c                     |  2 +-
>  drivers/iio/adc/at91_adc.c                       |  8 +++-----
>  drivers/iio/adc/exynos_adc.c                     |  8 +++-----
>  drivers/iio/adc/palmas_gpadc.c                   | 14 ++++++--------
>  drivers/iio/adc/rcar-gyroadc.c                   | 10 ++++------
>  drivers/iio/adc/rockchip_saradc.c                |  8 +++-----
>  drivers/iio/adc/stm32-adc-core.c                 | 12 +++++-------
>  drivers/iio/adc/stm32-adc.c                      | 16 
> ++++++----------
>  drivers/iio/adc/twl6030-gpadc.c                  |  8 +++-----
>  drivers/iio/adc/vf610_adc.c                      |  8 +++-----
>  drivers/iio/chemical/atlas-sensor.c              | 10 ++++------
>  drivers/iio/common/ssp_sensors/ssp_dev.c         | 12 ++++--------
>  drivers/iio/dac/vf610_dac.c                      |  8 +++-----
>  drivers/iio/gyro/mpu3050-core.c                  |  8 +++-----
>  drivers/iio/gyro/mpu3050-i2c.c                   |  2 +-
>  drivers/iio/light/apds9300.c                     | 11 +++--------
>  drivers/iio/light/bh1780.c                       | 10 ++++------
>  drivers/iio/light/cm3232.c                       | 13 ++++---------
>  drivers/iio/light/isl29018.c                     | 11 +++--------
>  drivers/iio/light/isl29125.c                     |  8 +++-----
>  drivers/iio/light/jsa1212.c                      | 12 +++---------
>  drivers/iio/light/ltr501.c                       |  8 +++-----
>  drivers/iio/light/stk3310.c                      | 12 +++---------
>  drivers/iio/light/tcs3414.c                      |  8 +++-----
>  drivers/iio/light/tcs3472.c                      |  8 +++-----
>  drivers/iio/light/tsl2563.c                      | 11 +++--------
>  drivers/iio/light/tsl4531.c                      | 11 +++--------
>  drivers/iio/light/us5182d.c                      | 10 ++++------
>  drivers/iio/magnetometer/ak8975.c                | 10 ++++------
>  drivers/iio/magnetometer/hmc5843.h               |  5 -----
>  drivers/iio/magnetometer/hmc5843_i2c.c           |  2 +-
>  drivers/iio/magnetometer/hmc5843_spi.c           |  2 +-
>  drivers/iio/magnetometer/mag3110.c               | 11 +++--------
>  drivers/iio/magnetometer/mmc35240.c              | 12 ++++--------
>  drivers/iio/pressure/bmp280-core.c               |  6 ++----
>  drivers/iio/pressure/bmp280-i2c.c                |  2 +-
>  drivers/iio/pressure/bmp280-spi.c                |  2 +-
>  drivers/iio/pressure/mpl3115.c                   | 11 +++--------
>  drivers/iio/proximity/as3935.c                   | 12 +++---------
>  .../iio/proximity/pulsedlight-lidar-lite-v2.c    | 10 ++++------
>  drivers/iio/proximity/rfd77402.c                 |  8 +++-----
>  drivers/iio/proximity/sx9500.c                   | 12 ++++--------
>  drivers/iio/temperature/tmp006.c                 |  8 +++-----
>  drivers/iio/temperature/tmp007.c                 |  8 +++-----
>  60 files changed, 180 insertions(+), 344 deletions(-)
> 
> --
> 2.34.0
> 



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

* Re: [PATCH 02/49] iio:accel:da280: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 ` [PATCH 02/49] iio:accel:da280: " Jonathan Cameron
@ 2021-11-23 22:17   ` Paul Cercueil
  2021-11-24  9:48     ` Jonathan Cameron
  0 siblings, 1 reply; 83+ messages in thread
From: Paul Cercueil @ 2021-11-23 22:17 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Jonathan Cameron

Hi,

Le mar., nov. 23 2021 at 21:09:32 +0000, Jonathan Cameron 
<jic23@kernel.org> a écrit :
> 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.
> 
> The pm_ptr() macro only removes the reference if CONFIG_PM is not
> set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> will not always remove the pm_ops structure.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

No pm_ptr() for this one?

-Paul

> ---
>  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..91ac478891ce 100644
> --- a/drivers/iio/accel/da280.c
> +++ b/drivers/iio/accel/da280.c
> @@ -153,17 +153,15 @@ 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)
> +static __maybe_unused int da280_suspend(struct device *dev)
>  {
>  	return da280_enable(to_i2c_client(dev), false);
>  }
> 
> -static int da280_resume(struct device *dev)
> +static __maybe_unused 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);
> 
> --
> 2.34.0
> 



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

* Re: [PATCH 49/49] iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:10 ` [PATCH 49/49] iio:chemical:atlas: " Jonathan Cameron
@ 2021-11-23 22:22   ` Matt Ranostay
  0 siblings, 0 replies; 83+ messages in thread
From: Matt Ranostay @ 2021-11-23 22:22 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: open list:IIO SUBSYSTEM AND DRIVERS, Lars-Peter Clausen,
	Paul Cercueil, Jonathan Cameron

On Tue, Nov 23, 2021 at 1:07 PM 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.
>

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>


> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Matt Ranostay <matt.ranostay@konsulko.com>
> ---
>  drivers/iio/chemical/atlas-sensor.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
> index 04b44a327614..7bacd0bd6f19 100644
> --- a/drivers/iio/chemical/atlas-sensor.c
> +++ b/drivers/iio/chemical/atlas-sensor.c
> @@ -737,8 +737,7 @@ 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)
> +static __maybe_unused int atlas_runtime_suspend(struct device *dev)
>  {
>         struct atlas_data *data =
>                      iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
> @@ -746,16 +745,15 @@ static int atlas_runtime_suspend(struct device *dev)
>         return atlas_set_powermode(data, 0);
>  }
>
> -static int atlas_runtime_resume(struct device *dev)
> +static __maybe_unused int atlas_runtime_resume(struct device *dev)
>  {
>         struct atlas_data *data =
>                      iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
>
>         return atlas_set_powermode(data, 1);
>  }
> -#endif
>
> -static const struct dev_pm_ops atlas_pm_ops = {
> +static __maybe_unused const struct dev_pm_ops atlas_pm_ops = {
>         SET_RUNTIME_PM_OPS(atlas_runtime_suspend,
>                            atlas_runtime_resume, NULL)
>  };
> @@ -764,7 +762,7 @@ 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.0
>

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

* Re: [PATCH 43/49] iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:10 ` [PATCH 43/49] iio:proximity:pulsedlight: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-23 22:22   ` Matt Ranostay
  2021-11-28 16:44     ` Jonathan Cameron
  0 siblings, 1 reply; 83+ messages in thread
From: Matt Ranostay @ 2021-11-23 22:22 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: open list:IIO SUBSYSTEM AND DRIVERS, Lars-Peter Clausen,
	Paul Cercueil, Jonathan Cameron

On Tue, Nov 23, 2021 at 1:07 PM 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>
> Cc: Matt Ranostay <matt.ranostay@konsulko.com>

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>

> ---
>  drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
> index 27026c060ab9..6adc2a0c27cb 100644
> --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
> +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
> @@ -338,8 +338,7 @@ 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)
> +static __maybe_unused int lidar_pm_runtime_suspend(struct device *dev)
>  {
>         struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
>         struct lidar_data *data = iio_priv(indio_dev);
> @@ -347,7 +346,7 @@ static int lidar_pm_runtime_suspend(struct device *dev)
>         return lidar_write_power(data, 0x0f);
>  }
>
> -static int lidar_pm_runtime_resume(struct device *dev)
> +static __maybe_unused int lidar_pm_runtime_resume(struct device *dev)
>  {
>         struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
>         struct lidar_data *data = iio_priv(indio_dev);
> @@ -358,9 +357,8 @@ static int lidar_pm_runtime_resume(struct device *dev)
>
>         return ret;
>  }
> -#endif
>
> -static const struct dev_pm_ops lidar_pm_ops = {
> +static __maybe_unused const struct dev_pm_ops lidar_pm_ops = {
>         SET_RUNTIME_PM_OPS(lidar_pm_runtime_suspend,
>                            lidar_pm_runtime_resume, NULL)
>  };
> @@ -369,7 +367,7 @@ 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.0
>

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

* Re: [PATCH 42/49] iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:10 ` [PATCH 42/49] iio:proximity:as3935: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2021-11-23 22:23   ` Matt Ranostay
  0 siblings, 0 replies; 83+ messages in thread
From: Matt Ranostay @ 2021-11-23 22:23 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: open list:IIO SUBSYSTEM AND DRIVERS, Lars-Peter Clausen,
	Paul Cercueil, Jonathan Cameron

On Tue, Nov 23, 2021 at 1:07 PM 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.
>
> The pm_ptr() macro only removes the reference if CONFIG_PM is not
> set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> will not always remove the pm_ops structure.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Matt Ranostay <matt.ranostay@konsulko.com>

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>

> ---
>  drivers/iio/proximity/as3935.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
> index d62766b6b39e..605c6095d704 100644
> --- a/drivers/iio/proximity/as3935.c
> +++ b/drivers/iio/proximity/as3935.c
> @@ -295,8 +295,7 @@ 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)
> +static __maybe_unused int as3935_suspend(struct device *dev)
>  {
>         struct iio_dev *indio_dev = dev_get_drvdata(dev);
>         struct as3935_state *st = iio_priv(indio_dev);
> @@ -316,7 +315,7 @@ static int as3935_suspend(struct device *dev)
>         return ret;
>  }
>
> -static int as3935_resume(struct device *dev)
> +static __maybe_unused int as3935_resume(struct device *dev)
>  {
>         struct iio_dev *indio_dev = dev_get_drvdata(dev);
>         struct as3935_state *st = iio_priv(indio_dev);
> @@ -338,11 +337,6 @@ static int as3935_resume(struct device *dev)
>  }
>
>  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
>
>  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_ptr(&as3935_pm_ops),
>         },
>         .probe          = as3935_probe,
>         .id_table       = as3935_id,
> --
> 2.34.0
>

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

* Re: [PATCH 36/49] iio:magn:ak8975: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:10 ` [PATCH 36/49] iio:magn:ak8975: " Jonathan Cameron
@ 2021-11-23 22:24   ` Matt Ranostay
  0 siblings, 0 replies; 83+ messages in thread
From: Matt Ranostay @ 2021-11-23 22:24 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: open list:IIO SUBSYSTEM AND DRIVERS, Lars-Peter Clausen,
	Paul Cercueil, Jonathan Cameron, Jonathan Albrieux,
	Linus Walleij

On Tue, Nov 23, 2021 at 1:07 PM 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>
> Cc: Matt Ranostay <matt.ranostay@konsulko.com>

Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>


> Cc: Jonathan Albrieux <jonathan.albrieux@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/iio/magnetometer/ak8975.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
> index 6e82dc54a417..ced3e674eb5f 100644
> --- a/drivers/iio/magnetometer/ak8975.c
> +++ b/drivers/iio/magnetometer/ak8975.c
> @@ -1033,8 +1033,7 @@ static int ak8975_remove(struct i2c_client *client)
>         return 0;
>  }
>
> -#ifdef CONFIG_PM
> -static int ak8975_runtime_suspend(struct device *dev)
> +static __maybe_unused int ak8975_runtime_suspend(struct device *dev)
>  {
>         struct i2c_client *client = to_i2c_client(dev);
>         struct iio_dev *indio_dev = i2c_get_clientdata(client);
> @@ -1053,7 +1052,7 @@ static int ak8975_runtime_suspend(struct device *dev)
>         return 0;
>  }
>
> -static int ak8975_runtime_resume(struct device *dev)
> +static __maybe_unused int ak8975_runtime_resume(struct device *dev)
>  {
>         struct i2c_client *client = to_i2c_client(dev);
>         struct iio_dev *indio_dev = i2c_get_clientdata(client);
> @@ -1074,9 +1073,8 @@ static int ak8975_runtime_resume(struct device *dev)
>
>         return 0;
>  }
> -#endif /* CONFIG_PM */
>
> -static const struct dev_pm_ops ak8975_dev_pm_ops = {
> +static __maybe_unused 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,
> @@ -1113,7 +1111,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.0
>

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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
                   ` (49 preceding siblings ...)
  2021-11-23 22:11 ` [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Paul Cercueil
@ 2021-11-24  0:58 ` Brian Masney
  50 siblings, 0 replies; 83+ messages in thread
From: Brian Masney @ 2021-11-24  0:58 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron,
	Alexandre Belloni, Anson Huang, Brian Masney, 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, Olivier Moysan, Stefan-Gabriel Mirea,
	Vaishnav M A

On Tue, Nov 23, 2021 at 09:09:30PM +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Note this series includes many drivers that are quite old and I'm not
> sure have active maintainers.  Hence if anyone has time to look at some
> of these beyond their own drivers and sanity check them it would be much
> appreciated!
> 
> Two motivations behind this set.
> 1 - General code reduction and improvement in readability in these drivers.
> 2 - Reduce change I'll have to ask people to change how they do this in
>     future patches.
> 
> Mostly this is just a case of letting the compiler work out it can remove
> the PM related functions rather than using #ifdefs in the code to do so.
> 
> The __maybe_unused markings make it clear we are intentionally building
> functions that the compiler can see are unused and remove in some build
> configurations.
> 
> The new pm_ptr() macro is rather convenient to got futher than many of
> the drivers were and when CONFIG_PM is not define ensure that the
> struct dev_pm_ops can also be removed.  Note there is a subtlty in that
> we only remove that whe CONFIG_PM is not defined whereas a few of these
> drivers were using CONFIG_PM_SLEEP which is a tighter condition (will
> remove the structure in more configurations).  I think that's a small
> price to pay for the convenience this macro brings.
> 
> I did this set as one patch per driver, as personally I prefer that
> option for all but the most trivial patches because it makes backports
> that cross with this series simpler and also avoid the complex
> tag giving we get for sets touching code from many authors.
> 
> All comments welcome.

Nice cleanup! Assuming that you add the missing pm_ptr() to patch 2
(iio:accel:da280) you can add this to the series:

Reviewed-by: Brian Masney <bmasney@redhat.com>


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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-23 22:11 ` [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Paul Cercueil
@ 2021-11-24  7:29   ` Arnd Bergmann
  2021-11-24 10:11     ` Jonathan Cameron
  2021-11-27 18:02   ` Jonathan Cameron
  1 sibling, 1 reply; 83+ messages in thread
From: Arnd Bergmann @ 2021-11-24  7:29 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Jonathan Cameron, linux-iio, Lars-Peter Clausen,
	Jonathan Cameron, Alexandre Belloni, Anson Huang, Brian Masney,
	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, Olivier Moysan,
	Stefan-Gabriel Mirea, Vaishnav M A, Arnd Bergmann

On Tue, Nov 23, 2021 at 11:11 PM Paul Cercueil <paul@crapouillou.net> wrote:
>
> One word about the pm_ptr() macro. Right now it's defined as:
>   #ifdef CONFIG_PM
>   #define pm_ptr(_ptr) (_ptr)
>   #else
>   #define pm_ptr(_ptr) NULL
>   #endif
>
> It could be possible to define it like this instead:
>   #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))
>
> The difference is that if !CONFIG_PM, in the first case the (_ptr) is
> not visible by the compiler and the __maybe_unused is required, while
> in the second case the (_ptr) is always visible by the compiler, but
> discarded as dead code. The reason we'd want that is the same reason we
> use IS_ENABLED() instead of macro guards; and you wouldn't need the
> __maybe_unused attribute anywhere.

That sounds like a great idea. I see there are only 12 users of pm_ptr at
the moment, so auditing all of these should not be a problem.

I gave it a brief look and found that we probably only need to fix
drivers/net/ethernet/realtek/r8169_main.c if we change the definition.

> The problem then is that the SET_*_PM_OPS macros are defined
> differently according to CONFIG_PM, so their definition would need to
> be changed to use the (redefined) pm_ptr() macro and a corresponding
> pm_sleep_ptr() macro. Unfortunately since the SET_*_PM_OPS macros are
> used everywhere with code wrapped around #ifdef CONFIG_PM guards, it
> wouldn't be easy to change them, and it would just be easier to
> introduce new macros.

Right, this is what we've discussed multiple times, and I think everyone
agreed we should do this, but so far we could not come up with a name
for the new macro, and changing the macro in place is not practical unless
we change hundreds of drivers in the same way as the iio series first.

       Arnd

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

* Re: [PATCH 13/49] iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 ` [PATCH 13/49] iio:adc:at91-adc: " Jonathan Cameron
@ 2021-11-24  9:16   ` Alexandre Belloni
  0 siblings, 0 replies; 83+ messages in thread
From: Alexandre Belloni @ 2021-11-24  9:16 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron,
	Ludovic Desroches

On 23/11/2021 21:09:43+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.
> 
> The pm_ptr() macro only removes the reference if CONFIG_PM is not
> set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> will not always remove the pm_ops structure.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> ---
>  drivers/iio/adc/at91_adc.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 5a7d3a3a5fa8..14a4735d72b5 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -1234,8 +1234,7 @@ static int at91_adc_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#ifdef CONFIG_PM_SLEEP
> -static int at91_adc_suspend(struct device *dev)
> +static __maybe_unused int at91_adc_suspend(struct device *dev)
>  {
>  	struct iio_dev *idev = dev_get_drvdata(dev);
>  	struct at91_adc_state *st = iio_priv(idev);
> @@ -1246,7 +1245,7 @@ static int at91_adc_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int at91_adc_resume(struct device *dev)
> +static __maybe_unused int at91_adc_resume(struct device *dev)
>  {
>  	struct iio_dev *idev = dev_get_drvdata(dev);
>  	struct at91_adc_state *st = iio_priv(idev);
> @@ -1256,7 +1255,6 @@ 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);
>  
> @@ -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_ptr(&at91_adc_pm_ops),
>  	},
>  };
>  
> -- 
> 2.34.0
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH 16/49] iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 ` [PATCH 16/49] iio:adc:stm32:Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-24  9:33   ` Fabrice Gasnier
  0 siblings, 0 replies; 83+ messages in thread
From: Fabrice Gasnier @ 2021-11-24  9:33 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron, Olivier Moysan

On 11/23/21 10:09 PM, Jonathan Cameron 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.
> 

Hi Jonathan,

You can add my:
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>

Thanks for your patch,
Best Regards,
Fabrice

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
> Cc: Olivier Moysan <olivier.moysan@foss.st.com>
> ---
>  drivers/iio/adc/stm32-adc-core.c | 12 +++++-------
>  drivers/iio/adc/stm32-adc.c      | 16 ++++++----------
>  2 files changed, 11 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
> index b6e18eb101f7..316ae84ab961 100644
> --- a/drivers/iio/adc/stm32-adc-core.c
> +++ b/drivers/iio/adc/stm32-adc-core.c
> @@ -763,28 +763,26 @@ 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)
> +static __maybe_unused int stm32_adc_core_runtime_suspend(struct device *dev)
>  {
>  	stm32_adc_core_hw_stop(dev);
>  
>  	return 0;
>  }
>  
> -static int stm32_adc_core_runtime_resume(struct device *dev)
> +static __maybe_unused int stm32_adc_core_runtime_resume(struct device *dev)
>  {
>  	return stm32_adc_core_hw_start(dev);
>  }
>  
> -static int stm32_adc_core_runtime_idle(struct device *dev)
> +static __maybe_unused int stm32_adc_core_runtime_idle(struct device *dev)
>  {
>  	pm_runtime_mark_last_busy(dev);
>  
>  	return 0;
>  }
> -#endif
>  
> -static const struct dev_pm_ops stm32_adc_core_pm_ops = {
> +static __maybe_unused 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,
> @@ -836,7 +834,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 7f1fb36c747c..2d94de6de848 100644
> --- a/drivers/iio/adc/stm32-adc.c
> +++ b/drivers/iio/adc/stm32-adc.c
> @@ -2351,8 +2351,7 @@ static int stm32_adc_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -#if defined(CONFIG_PM_SLEEP)
> -static int stm32_adc_suspend(struct device *dev)
> +static __maybe_unused int stm32_adc_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  
> @@ -2362,7 +2361,7 @@ static int stm32_adc_suspend(struct device *dev)
>  	return pm_runtime_force_suspend(dev);
>  }
>  
> -static int stm32_adc_resume(struct device *dev)
> +static __maybe_unused int stm32_adc_resume(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	int ret;
> @@ -2381,21 +2380,18 @@ 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)
> +static __maybe_unused int stm32_adc_runtime_suspend(struct device *dev)
>  {
>  	return stm32_adc_hw_stop(dev);
>  }
>  
> -static int stm32_adc_runtime_resume(struct device *dev)
> +static __maybe_unused 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 = {
> +static __maybe_unused 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)
> @@ -2452,7 +2448,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);
> 

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

* Re: [PATCH 02/49] iio:accel:da280: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 22:17   ` Paul Cercueil
@ 2021-11-24  9:48     ` Jonathan Cameron
  0 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-24  9:48 UTC (permalink / raw)
  To: Paul Cercueil; +Cc: Jonathan Cameron, linux-iio, Lars-Peter Clausen

On Tue, 23 Nov 2021 22:17:52 +0000
Paul Cercueil <paul@crapouillou.net> wrote:

> Hi,
> 
> Le mar., nov. 23 2021 at 21:09:32 +0000, Jonathan Cameron 
> <jic23@kernel.org> a écrit :
> > 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.
> > 
> > The pm_ptr() macro only removes the reference if CONFIG_PM is not
> > set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> > will not always remove the pm_ops structure.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>  
> 
> No pm_ptr() for this one?
> 

Gah. I changed my mind about this half way through doing this and
decided to use it throughout rather than just in places that had
defined the pm_ops out by hand.

Missed this one in the update!  Anyhow, easy fix :)

Thanks,

Jonathan

> -Paul
> 
> > ---
> >  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..91ac478891ce 100644
> > --- a/drivers/iio/accel/da280.c
> > +++ b/drivers/iio/accel/da280.c
> > @@ -153,17 +153,15 @@ 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)
> > +static __maybe_unused int da280_suspend(struct device *dev)
> >  {
> >  	return da280_enable(to_i2c_client(dev), false);
> >  }
> > 
> > -static int da280_resume(struct device *dev)
> > +static __maybe_unused 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);
> > 
> > --
> > 2.34.0
> >   
> 
> 


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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-24  7:29   ` Arnd Bergmann
@ 2021-11-24 10:11     ` Jonathan Cameron
  2021-11-24 10:58       ` Paul Cercueil
  2021-11-24 12:23       ` Arnd Bergmann
  0 siblings, 2 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-24 10:11 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Paul Cercueil, Jonathan Cameron, linux-iio, Lars-Peter Clausen,
	Alexandre Belloni, Anson Huang, Brian Masney, 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, Olivier Moysan, Stefan-Gabriel Mirea,
	Vaishnav M A

On Wed, 24 Nov 2021 08:29:40 +0100
Arnd Bergmann <arnd@arndb.de> wrote:

> On Tue, Nov 23, 2021 at 11:11 PM Paul Cercueil <paul@crapouillou.net> wrote:
> >
> > One word about the pm_ptr() macro. Right now it's defined as:
> >   #ifdef CONFIG_PM
> >   #define pm_ptr(_ptr) (_ptr)
> >   #else
> >   #define pm_ptr(_ptr) NULL
> >   #endif
> >
> > It could be possible to define it like this instead:
> >   #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))
> >
> > The difference is that if !CONFIG_PM, in the first case the (_ptr) is
> > not visible by the compiler and the __maybe_unused is required, while
> > in the second case the (_ptr) is always visible by the compiler, but
> > discarded as dead code. The reason we'd want that is the same reason we
> > use IS_ENABLED() instead of macro guards; and you wouldn't need the
> > __maybe_unused attribute anywhere.  
> 
> That sounds like a great idea. I see there are only 12 users of pm_ptr at
> the moment, so auditing all of these should not be a problem.
> 
> I gave it a brief look and found that we probably only need to fix
> drivers/net/ethernet/realtek/r8169_main.c if we change the definition.

Cool.  

> 
> > The problem then is that the SET_*_PM_OPS macros are defined
> > differently according to CONFIG_PM, so their definition would need to
> > be changed to use the (redefined) pm_ptr() macro and a corresponding
> > pm_sleep_ptr() macro. Unfortunately since the SET_*_PM_OPS macros are
> > used everywhere with code wrapped around #ifdef CONFIG_PM guards, it
> > wouldn't be easy to change them, and it would just be easier to
> > introduce new macros.  
> 
> Right, this is what we've discussed multiple times, and I think everyone
> agreed we should do this, but so far we could not come up with a name
> for the new macro, and changing the macro in place is not practical unless
> we change hundreds of drivers in the same way as the iio series first.

Nasty indeed and I'm not sure how scriptable either as lots of subtle variants
unfortunately.

I'm cynical - don't need a good name.  *_OPS2 works fine for me as long as
the docs are good. 

Jonathan

> 
>        Arnd


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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-24 10:11     ` Jonathan Cameron
@ 2021-11-24 10:58       ` Paul Cercueil
  2021-11-24 12:23       ` Arnd Bergmann
  1 sibling, 0 replies; 83+ messages in thread
From: Paul Cercueil @ 2021-11-24 10:58 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Arnd Bergmann, Jonathan Cameron, linux-iio, Lars-Peter Clausen,
	Alexandre Belloni, Anson Huang, Brian Masney, 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, Olivier Moysan, Stefan-Gabriel Mirea,
	Vaishnav M A



Le mer., nov. 24 2021 at 10:11:13 +0000, Jonathan Cameron 
<Jonathan.Cameron@Huawei.com> a écrit :
> On Wed, 24 Nov 2021 08:29:40 +0100
> Arnd Bergmann <arnd@arndb.de> wrote:
> 
>>  On Tue, Nov 23, 2021 at 11:11 PM Paul Cercueil 
>> <paul@crapouillou.net> wrote:
>>  >
>>  > One word about the pm_ptr() macro. Right now it's defined as:
>>  >   #ifdef CONFIG_PM
>>  >   #define pm_ptr(_ptr) (_ptr)
>>  >   #else
>>  >   #define pm_ptr(_ptr) NULL
>>  >   #endif
>>  >
>>  > It could be possible to define it like this instead:
>>  >   #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))
>>  >
>>  > The difference is that if !CONFIG_PM, in the first case the 
>> (_ptr) is
>>  > not visible by the compiler and the __maybe_unused is required, 
>> while
>>  > in the second case the (_ptr) is always visible by the compiler, 
>> but
>>  > discarded as dead code. The reason we'd want that is the same 
>> reason we
>>  > use IS_ENABLED() instead of macro guards; and you wouldn't need 
>> the
>>  > __maybe_unused attribute anywhere.
>> 
>>  That sounds like a great idea. I see there are only 12 users of 
>> pm_ptr at
>>  the moment, so auditing all of these should not be a problem.
>> 
>>  I gave it a brief look and found that we probably only need to fix
>>  drivers/net/ethernet/realtek/r8169_main.c if we change the 
>> definition.
> 
> Cool.
> 
>> 
>>  > The problem then is that the SET_*_PM_OPS macros are defined
>>  > differently according to CONFIG_PM, so their definition would 
>> need to
>>  > be changed to use the (redefined) pm_ptr() macro and a 
>> corresponding
>>  > pm_sleep_ptr() macro. Unfortunately since the SET_*_PM_OPS macros 
>> are
>>  > used everywhere with code wrapped around #ifdef CONFIG_PM guards, 
>> it
>>  > wouldn't be easy to change them, and it would just be easier to
>>  > introduce new macros.
>> 
>>  Right, this is what we've discussed multiple times, and I think 
>> everyone
>>  agreed we should do this, but so far we could not come up with a 
>> name
>>  for the new macro, and changing the macro in place is not practical 
>> unless
>>  we change hundreds of drivers in the same way as the iio series 
>> first.
> 
> Nasty indeed and I'm not sure how scriptable either as lots of subtle 
> variants
> unfortunately.
> 
> I'm cynical - don't need a good name.  *_OPS2 works fine for me as 
> long as
> the docs are good.

We could just remove the SET_ prefix,
SET_SYSTEM_SLEEP_PM_OPS -> SYSTEM_SLEEP_PM_OPS,

Or would that be too confusing?

-Paul



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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-24 10:11     ` Jonathan Cameron
  2021-11-24 10:58       ` Paul Cercueil
@ 2021-11-24 12:23       ` Arnd Bergmann
  2021-11-24 15:10         ` Paul Cercueil
  1 sibling, 1 reply; 83+ messages in thread
From: Arnd Bergmann @ 2021-11-24 12:23 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Arnd Bergmann, Paul Cercueil, Jonathan Cameron, linux-iio,
	Lars-Peter Clausen, Alexandre Belloni, Anson Huang, Brian Masney,
	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, Olivier Moysan,
	Stefan-Gabriel Mirea, Vaishnav M A

On Wed, Nov 24, 2021 at 11:11 AM Jonathan Cameron
<Jonathan.Cameron@huawei.com> wrote:
> On Wed, 24 Nov 2021 08:29:40 +0100 Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > > The problem then is that the SET_*_PM_OPS macros are defined
> > > differently according to CONFIG_PM, so their definition would need to
> > > be changed to use the (redefined) pm_ptr() macro and a corresponding
> > > pm_sleep_ptr() macro. Unfortunately since the SET_*_PM_OPS macros are
> > > used everywhere with code wrapped around #ifdef CONFIG_PM guards, it
> > > wouldn't be easy to change them, and it would just be easier to
> > > introduce new macros.
> >
> > Right, this is what we've discussed multiple times, and I think everyone
> > agreed we should do this, but so far we could not come up with a name
> > for the new macro, and changing the macro in place is not practical unless
> > we change hundreds of drivers in the same way as the iio series first.
>
> Nasty indeed and I'm not sure how scriptable either as lots of subtle variants
> unfortunately.

The minor variants (late, noirq) are actually the easy part, for the macros that
have fewer users, we can just have one patch per macro that changes it treewide.
For SET_SYSTEM_SLEEP_PM_OPS/SET_RUNTIME_PM_OPS and their
DEV_PM_OPS variants, this would be a lot harder:

$ for i in SET_SYSTEM_SLEEP_PM_OPS SET_LATE_SYSTEM_SLEEP_PM_OPS
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS SET_RUNTIME_PM_OPS SIMPLE_DEV_PM_OPS
UNIVERSAL_DEV_PM_OPS ; do echo `git grep -wl $i | wc  -l` $i ; done

459 SET_SYSTEM_SLEEP_PM_OPS
51 SET_LATE_SYSTEM_SLEEP_PM_OPS
59 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS
497 SET_RUNTIME_PM_OPS
797 SIMPLE_DEV_PM_OPS
20 UNIVERSAL_DEV_PM_OPS

About half of those actually use an #ifdef, while the other half does
not:

$ git grep -wl 'SET_SYSTEM_SLEEP_PM_OPS\|SET_RUNTIME_PM_OPS\|SIMPLE_DEV_PM_OPS\|UNIVERSAL_DEV_PM_OPS'
 | xargs grep -l CONFIG_PM | wc -l
712
$ git grep -wl 'SET_SYSTEM_SLEEP_PM_OPS\|SET_RUNTIME_PM_OPS\|SIMPLE_DEV_PM_OPS\|UNIVERSAL_DEV_PM_OPS'
 | xargs grep -L CONFIG_PM | wc -l
745

If we rename the macros in the first half of this using a script, then we should
be able to change the behavior of the normal macros to use the new pm_ptr().

         Arnd

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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-24 12:23       ` Arnd Bergmann
@ 2021-11-24 15:10         ` Paul Cercueil
  2021-11-27 18:09           ` Jonathan Cameron
  0 siblings, 1 reply; 83+ messages in thread
From: Paul Cercueil @ 2021-11-24 15:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jonathan Cameron, Jonathan Cameron, linux-iio,
	Lars-Peter Clausen, Alexandre Belloni, Anson Huang, Brian Masney,
	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, Olivier Moysan,
	Stefan-Gabriel Mirea, Vaishnav M A



Le mer., nov. 24 2021 at 13:23:47 +0100, Arnd Bergmann <arnd@arndb.de> 
a écrit :
> On Wed, Nov 24, 2021 at 11:11 AM Jonathan Cameron
> <Jonathan.Cameron@huawei.com> wrote:
>>  On Wed, 24 Nov 2021 08:29:40 +0100 Arnd Bergmann <arnd@arndb.de> 
>> wrote:
>>  >
>>  > > The problem then is that the SET_*_PM_OPS macros are defined
>>  > > differently according to CONFIG_PM, so their definition would 
>> need to
>>  > > be changed to use the (redefined) pm_ptr() macro and a 
>> corresponding
>>  > > pm_sleep_ptr() macro. Unfortunately since the SET_*_PM_OPS 
>> macros are
>>  > > used everywhere with code wrapped around #ifdef CONFIG_PM 
>> guards, it
>>  > > wouldn't be easy to change them, and it would just be easier to
>>  > > introduce new macros.
>>  >
>>  > Right, this is what we've discussed multiple times, and I think 
>> everyone
>>  > agreed we should do this, but so far we could not come up with a 
>> name
>>  > for the new macro, and changing the macro in place is not 
>> practical unless
>>  > we change hundreds of drivers in the same way as the iio series 
>> first.
>> 
>>  Nasty indeed and I'm not sure how scriptable either as lots of 
>> subtle variants
>>  unfortunately.
> 
> The minor variants (late, noirq) are actually the easy part, for the 
> macros that
> have fewer users, we can just have one patch per macro that changes 
> it treewide.
> For SET_SYSTEM_SLEEP_PM_OPS/SET_RUNTIME_PM_OPS and their
> DEV_PM_OPS variants, this would be a lot harder:
> 
> $ for i in SET_SYSTEM_SLEEP_PM_OPS SET_LATE_SYSTEM_SLEEP_PM_OPS
> SET_NOIRQ_SYSTEM_SLEEP_PM_OPS SET_RUNTIME_PM_OPS SIMPLE_DEV_PM_OPS
> UNIVERSAL_DEV_PM_OPS ; do echo `git grep -wl $i | wc  -l` $i ; done
> 
> 459 SET_SYSTEM_SLEEP_PM_OPS
> 51 SET_LATE_SYSTEM_SLEEP_PM_OPS
> 59 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS
> 497 SET_RUNTIME_PM_OPS
> 797 SIMPLE_DEV_PM_OPS
> 20 UNIVERSAL_DEV_PM_OPS
> 
> About half of those actually use an #ifdef, while the other half does
> not:
> 
> $ git grep -wl 
> 'SET_SYSTEM_SLEEP_PM_OPS\|SET_RUNTIME_PM_OPS\|SIMPLE_DEV_PM_OPS\|UNIVERSAL_DEV_PM_OPS'
>  | xargs grep -l CONFIG_PM | wc -l
> 712
> $ git grep -wl 
> 'SET_SYSTEM_SLEEP_PM_OPS\|SET_RUNTIME_PM_OPS\|SIMPLE_DEV_PM_OPS\|UNIVERSAL_DEV_PM_OPS'
>  | xargs grep -L CONFIG_PM | wc -l
> 745
> 
> If we rename the macros in the first half of this using a script, 
> then we should
> be able to change the behavior of the normal macros to use the new 
> pm_ptr().

So you want to rename the current macros (to e.g. *_PM_OPS_LEGACY) 
everywhere so that new ones can be defined?

What about we introduce new macros, and just deprecate the old ones 
(with e.g. a checkpatch warning)? That would be way less work.

-Paul



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

* Re: [PATCH 14/49] iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 ` [PATCH 14/49] iio:adc:exynos_adc: " Jonathan Cameron
@ 2021-11-25  8:50   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 83+ messages in thread
From: Krzysztof Kozlowski @ 2021-11-25  8:50 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron

On 23/11/2021 22:09, 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.
> 
> The pm_ptr() macro only removes the reference if CONFIG_PM is not
> set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> will not always remove the pm_ops structure.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Krzysztof Kozlowski <krzk@kernel.org>
> ---
>  drivers/iio/adc/exynos_adc.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 

Looks good:

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

Best regards,
Krzysztof

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

* Re: [PATCH 11/49] iio:adc:ab8500: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 ` [PATCH 11/49] iio:adc:ab8500: " Jonathan Cameron
@ 2021-11-25 16:55   ` Linus Walleij
  0 siblings, 0 replies; 83+ messages in thread
From: Linus Walleij @ 2021-11-25 16:55 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron

On Tue, Nov 23, 2021 at 10:06 PM 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>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 24/49] iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 ` [PATCH 24/49] iio:light:bh1780: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-25 16:56   ` Linus Walleij
  0 siblings, 0 replies; 83+ messages in thread
From: Linus Walleij @ 2021-11-25 16:56 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron

On Tue, Nov 23, 2021 at 10:06 PM 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>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 41/49] iio:pressure:bmp280: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:10 ` [PATCH 41/49] iio:pressure:bmp280: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-25 16:56   ` Linus Walleij
  2022-01-01 17:50   ` Jonathan Cameron
  1 sibling, 0 replies; 83+ messages in thread
From: Linus Walleij @ 2021-11-25 16:56 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron

On Tue, Nov 23, 2021 at 10:07 PM 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>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 48/49] iio:gyro:mpu3050: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:10 ` [PATCH 48/49] iio:gyro:mpu3050: Switch from CONFIG_PM " Jonathan Cameron
@ 2021-11-25 16:56   ` Linus Walleij
  2022-01-01 18:00   ` Jonathan Cameron
  1 sibling, 0 replies; 83+ messages in thread
From: Linus Walleij @ 2021-11-25 16:56 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron

On Tue, Nov 23, 2021 at 10:07 PM 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>
> Cc: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-23 22:11 ` [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Paul Cercueil
  2021-11-24  7:29   ` Arnd Bergmann
@ 2021-11-27 18:02   ` Jonathan Cameron
  2021-11-28  9:26     ` Arnd Bergmann
  1 sibling, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-27 18:02 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: linux-iio, Lars-Peter Clausen, Jonathan Cameron,
	Alexandre Belloni, Anson Huang, Brian Masney, 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, Olivier Moysan, Stefan-Gabriel Mirea,
	Vaishnav M A, Arnd Bergmann

On Tue, 23 Nov 2021 22:11:08 +0000
Paul Cercueil <paul@crapouillou.net> wrote:

> Hi Jonathan,
> 
> Cc'd Arnd who may have some interest in the topic.
> 
> Le mar., nov. 23 2021 at 21:09:30 +0000, Jonathan Cameron 
> <jic23@kernel.org> a écrit :
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > Note this series includes many drivers that are quite old and I'm not
> > sure have active maintainers.  Hence if anyone has time to look at 
> > some
> > of these beyond their own drivers and sanity check them it would be 
> > much
> > appreciated!
> > 
> > Two motivations behind this set.
> > 1 - General code reduction and improvement in readability in these 
> > drivers.
> > 2 - Reduce change I'll have to ask people to change how they do this 
> > in
> >     future patches.
> > 
> > Mostly this is just a case of letting the compiler work out it can 
> > remove
> > the PM related functions rather than using #ifdefs in the code to do 
> > so.
> > 
> > The __maybe_unused markings make it clear we are intentionally 
> > building
> > functions that the compiler can see are unused and remove in some 
> > build
> > configurations.
> > 
> > The new pm_ptr() macro is rather convenient to got futher than many of
> > the drivers were and when CONFIG_PM is not define ensure that the
> > struct dev_pm_ops can also be removed.  Note there is a subtlty in 
> > that
> > we only remove that whe CONFIG_PM is not defined whereas a few of 
> > these
> > drivers were using CONFIG_PM_SLEEP which is a tighter condition (will
> > remove the structure in more configurations).  I think that's a small
> > price to pay for the convenience this macro brings.
> > 
> > I did this set as one patch per driver, as personally I prefer that
> > option for all but the most trivial patches because it makes backports
> > that cross with this series simpler and also avoid the complex
> > tag giving we get for sets touching code from many authors.
> > 
> > All comments welcome.  
> 
> One word about the pm_ptr() macro. Right now it's defined as:
>   #ifdef CONFIG_PM
>   #define pm_ptr(_ptr) (_ptr)
>   #else
>   #define pm_ptr(_ptr) NULL
>   #endif
> 
> It could be possible to define it like this instead:
>   #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr))
> 
> The difference is that if !CONFIG_PM, in the first case the (_ptr) is 
> not visible by the compiler and the __maybe_unused is required, while 
> in the second case the (_ptr) is always visible by the compiler, but 
> discarded as dead code. The reason we'd want that is the same reason we 
> use IS_ENABLED() instead of macro guards; and you wouldn't need the 
> __maybe_unused attribute anywhere.
> 
> The problem then is that the SET_*_PM_OPS macros are defined 
> differently according to CONFIG_PM, so their definition would need to 
> be changed to use the (redefined) pm_ptr() macro and a corresponding 
> pm_sleep_ptr() macro.

Small question here.  Why would these macros need to use pm_ptr() macro at all?

Why not just stop them being conditional on CONFIG_PM at all and let dead
code removal kill them off for us?  You might want to do something different
for the CONFIG_PM_SLEEP ones though if we care about having it that fine
grained.

Obviously still need new macros to do this, so doesn't change the
fundamental question.

> Unfortunately since the SET_*_PM_OPS macros are 
> used everywhere with code wrapped around #ifdef CONFIG_PM guards, it 
> wouldn't be easy to change them, and it would just be easier to 
> introduce new macros.
> 
> The patchset looks fine as-is and I am not asking you to work on 
> anything I just said, I just thought it was worth mentioning.
> 
> Cheers,
> -Paul
> 
> > Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: Anson Huang <anson.huang@nxp.com>
> > Cc: Brian Masney <masneyb@onstation.org>
> > 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: 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 (49):
> >   iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:accel:da280: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:accel:dmard06: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:accel:dmard10: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:accel:mc3230: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:accel:mma7660: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:accel:mma9551: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:accel:mma9553: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:accel:kxsd9: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:adc:ab8500: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:adc:ad7606: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:adc:at91-adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:adc:exynos_adc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:adc:palmas_gpadc: Switch from CONFIG_PM_SLEEP guards to 
> > pm_ptr() /
> >     __maybe_unused
> >   iio:adc:stm32:Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:adc:rcar: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:adc:rockchip: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:adc:twl6030: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:adc:vf610: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:common:ssp: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:dac:vf610: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:apds9300: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:bh1780: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:cm3232: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:isl29018: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:isl29125: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:jsa1212: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:ltr501: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:stk3310: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:tcs3414: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:tcs3472: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:tsl2563: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:tsl4531: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:magn:ak8975: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:magn:mag3110: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:magn:mmc35240: Switch from CONFIG_PM_SLEEP guards to pm_ptr() /
> >     __maybe_unused
> >   iio:pressure:mpl3115: Switch from CONFIG_PM_SLEEP guards to 
> > pm_ptr() /
> >     __maybe_unused
> >   iio:pressure:bmp280: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to 
> > pm_ptr() /
> >     __maybe_unused
> >   iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() 
> > /
> >     __maybe_unused
> >   iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to 
> > pm_ptr()
> >     / __maybe_unused
> >   iio:proximity:sx9500: Switch from CONFIG_PM_SLEEP guards to 
> > pm_ptr() /
> >     __maybe_unused
> >   iio:temperature:tmp006: Switch from CONFIG_PM_SLEEP guards to 
> > pm_ptr()
> >     / __maybe_unused
> >   iio:temperature:tmp007: Switch from CONFIG_PM_SLEEP guards to 
> > pm_ptr()
> >     / __maybe_unused
> >   iio:gyro:mpu3050: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> >   iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() /
> >     __maybe_unused
> > 
> >  drivers/iio/accel/da280.c                        |  6 ++----
> >  drivers/iio/accel/da311.c                        |  8 +++-----
> >  drivers/iio/accel/dmard06.c                      | 12 ++++--------
> >  drivers/iio/accel/dmard10.c                      |  9 ++++-----
> >  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                       |  8 +++-----
> >  drivers/iio/accel/mma7660.c                      | 12 +++---------
> >  drivers/iio/accel/mma9551.c                      | 16 
> > ++++++----------
> >  drivers/iio/accel/mma9553.c                      | 16 
> > ++++++----------
> >  drivers/iio/accel/stk8ba50.c                     | 12 +++---------
> >  drivers/iio/adc/ab8500-gpadc.c                   | 10 ++++------
> >  drivers/iio/adc/ad7606.c                         |  8 ++------
> >  drivers/iio/adc/ad7606.h                         |  5 -----
> >  drivers/iio/adc/ad7606_par.c                     |  2 +-
> >  drivers/iio/adc/ad7606_spi.c                     |  2 +-
> >  drivers/iio/adc/at91_adc.c                       |  8 +++-----
> >  drivers/iio/adc/exynos_adc.c                     |  8 +++-----
> >  drivers/iio/adc/palmas_gpadc.c                   | 14 ++++++--------
> >  drivers/iio/adc/rcar-gyroadc.c                   | 10 ++++------
> >  drivers/iio/adc/rockchip_saradc.c                |  8 +++-----
> >  drivers/iio/adc/stm32-adc-core.c                 | 12 +++++-------
> >  drivers/iio/adc/stm32-adc.c                      | 16 
> > ++++++----------
> >  drivers/iio/adc/twl6030-gpadc.c                  |  8 +++-----
> >  drivers/iio/adc/vf610_adc.c                      |  8 +++-----
> >  drivers/iio/chemical/atlas-sensor.c              | 10 ++++------
> >  drivers/iio/common/ssp_sensors/ssp_dev.c         | 12 ++++--------
> >  drivers/iio/dac/vf610_dac.c                      |  8 +++-----
> >  drivers/iio/gyro/mpu3050-core.c                  |  8 +++-----
> >  drivers/iio/gyro/mpu3050-i2c.c                   |  2 +-
> >  drivers/iio/light/apds9300.c                     | 11 +++--------
> >  drivers/iio/light/bh1780.c                       | 10 ++++------
> >  drivers/iio/light/cm3232.c                       | 13 ++++---------
> >  drivers/iio/light/isl29018.c                     | 11 +++--------
> >  drivers/iio/light/isl29125.c                     |  8 +++-----
> >  drivers/iio/light/jsa1212.c                      | 12 +++---------
> >  drivers/iio/light/ltr501.c                       |  8 +++-----
> >  drivers/iio/light/stk3310.c                      | 12 +++---------
> >  drivers/iio/light/tcs3414.c                      |  8 +++-----
> >  drivers/iio/light/tcs3472.c                      |  8 +++-----
> >  drivers/iio/light/tsl2563.c                      | 11 +++--------
> >  drivers/iio/light/tsl4531.c                      | 11 +++--------
> >  drivers/iio/light/us5182d.c                      | 10 ++++------
> >  drivers/iio/magnetometer/ak8975.c                | 10 ++++------
> >  drivers/iio/magnetometer/hmc5843.h               |  5 -----
> >  drivers/iio/magnetometer/hmc5843_i2c.c           |  2 +-
> >  drivers/iio/magnetometer/hmc5843_spi.c           |  2 +-
> >  drivers/iio/magnetometer/mag3110.c               | 11 +++--------
> >  drivers/iio/magnetometer/mmc35240.c              | 12 ++++--------
> >  drivers/iio/pressure/bmp280-core.c               |  6 ++----
> >  drivers/iio/pressure/bmp280-i2c.c                |  2 +-
> >  drivers/iio/pressure/bmp280-spi.c                |  2 +-
> >  drivers/iio/pressure/mpl3115.c                   | 11 +++--------
> >  drivers/iio/proximity/as3935.c                   | 12 +++---------
> >  .../iio/proximity/pulsedlight-lidar-lite-v2.c    | 10 ++++------
> >  drivers/iio/proximity/rfd77402.c                 |  8 +++-----
> >  drivers/iio/proximity/sx9500.c                   | 12 ++++--------
> >  drivers/iio/temperature/tmp006.c                 |  8 +++-----
> >  drivers/iio/temperature/tmp007.c                 |  8 +++-----
> >  60 files changed, 180 insertions(+), 344 deletions(-)
> > 
> > --
> > 2.34.0
> >   
> 
> 


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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-24 15:10         ` Paul Cercueil
@ 2021-11-27 18:09           ` Jonathan Cameron
  2021-11-28  9:17             ` Arnd Bergmann
  0 siblings, 1 reply; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-27 18:09 UTC (permalink / raw)
  To: Paul Cercueil
  Cc: Arnd Bergmann, Jonathan Cameron, linux-iio, Lars-Peter Clausen,
	Alexandre Belloni, Anson Huang, Brian Masney, 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, Olivier Moysan, Stefan-Gabriel Mirea,
	Vaishnav M A

On Wed, 24 Nov 2021 15:10:06 +0000
Paul Cercueil <paul@crapouillou.net> wrote:

> Le mer., nov. 24 2021 at 13:23:47 +0100, Arnd Bergmann <arnd@arndb.de> 
> a écrit :
> > On Wed, Nov 24, 2021 at 11:11 AM Jonathan Cameron
> > <Jonathan.Cameron@huawei.com> wrote:  
> >>  On Wed, 24 Nov 2021 08:29:40 +0100 Arnd Bergmann <arnd@arndb.de> 
> >> wrote:  
> >>  >  
> >>  > > The problem then is that the SET_*_PM_OPS macros are defined
> >>  > > differently according to CONFIG_PM, so their definition would   
> >> need to  
> >>  > > be changed to use the (redefined) pm_ptr() macro and a   
> >> corresponding  
> >>  > > pm_sleep_ptr() macro. Unfortunately since the SET_*_PM_OPS   
> >> macros are  
> >>  > > used everywhere with code wrapped around #ifdef CONFIG_PM   
> >> guards, it  
> >>  > > wouldn't be easy to change them, and it would just be easier to
> >>  > > introduce new macros.  
> >>  >
> >>  > Right, this is what we've discussed multiple times, and I think   
> >> everyone  
> >>  > agreed we should do this, but so far we could not come up with a   
> >> name  
> >>  > for the new macro, and changing the macro in place is not   
> >> practical unless  
> >>  > we change hundreds of drivers in the same way as the iio series   
> >> first.
> >> 
> >>  Nasty indeed and I'm not sure how scriptable either as lots of 
> >> subtle variants
> >>  unfortunately.  
> > 
> > The minor variants (late, noirq) are actually the easy part, for the 
> > macros that
> > have fewer users, we can just have one patch per macro that changes 
> > it treewide.
> > For SET_SYSTEM_SLEEP_PM_OPS/SET_RUNTIME_PM_OPS and their
> > DEV_PM_OPS variants, this would be a lot harder:
> > 
> > $ for i in SET_SYSTEM_SLEEP_PM_OPS SET_LATE_SYSTEM_SLEEP_PM_OPS
> > SET_NOIRQ_SYSTEM_SLEEP_PM_OPS SET_RUNTIME_PM_OPS SIMPLE_DEV_PM_OPS
> > UNIVERSAL_DEV_PM_OPS ; do echo `git grep -wl $i | wc  -l` $i ; done
> > 
> > 459 SET_SYSTEM_SLEEP_PM_OPS
> > 51 SET_LATE_SYSTEM_SLEEP_PM_OPS
> > 59 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS
> > 497 SET_RUNTIME_PM_OPS
> > 797 SIMPLE_DEV_PM_OPS
> > 20 UNIVERSAL_DEV_PM_OPS
> > 
> > About half of those actually use an #ifdef, while the other half does
> > not:
> > 
> > $ git grep -wl 
> > 'SET_SYSTEM_SLEEP_PM_OPS\|SET_RUNTIME_PM_OPS\|SIMPLE_DEV_PM_OPS\|UNIVERSAL_DEV_PM_OPS'
> >  | xargs grep -l CONFIG_PM | wc -l
> > 712
> > $ git grep -wl 
> > 'SET_SYSTEM_SLEEP_PM_OPS\|SET_RUNTIME_PM_OPS\|SIMPLE_DEV_PM_OPS\|UNIVERSAL_DEV_PM_OPS'
> >  | xargs grep -L CONFIG_PM | wc -l
> > 745
> > 
> > If we rename the macros in the first half of this using a script, 
> > then we should
> > be able to change the behavior of the normal macros to use the new 
> > pm_ptr().  
> 
> So you want to rename the current macros (to e.g. *_PM_OPS_LEGACY) 
> everywhere so that new ones can be defined?
> 
> What about we introduce new macros, and just deprecate the old ones 
> (with e.g. a checkpatch warning)? That would be way less work.

Sounds like a sensible approach to me. If Arnd is happy with that we
can move forwards and get the bikshedding on the naming started.

As ever the true discussion won't start before there is a patch.

I'm happy to hold this series for a bit on the basis it'll be simpler
without all those __maybe_unused additions, but I don't want to be
sitting on it for multiple cycles if it turns out this will take
a while to move forwards.

Thanks,

Jonathan

> 
> -Paul
> 
> 


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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-27 18:09           ` Jonathan Cameron
@ 2021-11-28  9:17             ` Arnd Bergmann
  2021-11-28 12:44               ` Paul Cercueil
  0 siblings, 1 reply; 83+ messages in thread
From: Arnd Bergmann @ 2021-11-28  9:17 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Paul Cercueil, Arnd Bergmann, Jonathan Cameron, linux-iio,
	Lars-Peter Clausen, Alexandre Belloni, Anson Huang, Brian Masney,
	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, Olivier Moysan,
	Stefan-Gabriel Mirea, Vaishnav M A

On Sat, Nov 27, 2021 at 7:09 PM Jonathan Cameron <jic23@kernel.org> wrote:
> On Wed, 24 Nov 2021 15:10:06 +0000 Paul Cercueil <paul@crapouillou.net> wrote:
> > Le mer., nov. 24 2021 at 13:23:47 +0100, Arnd Bergmann <arnd@arndb.de>
> >
> > So you want to rename the current macros (to e.g. *_PM_OPS_LEGACY)
> > everywhere so that new ones can be defined?
> >
> > What about we introduce new macros, and just deprecate the old ones
> > (with e.g. a checkpatch warning)? That would be way less work.
>
> Sounds like a sensible approach to me. If Arnd is happy with that we
> can move forwards and get the bikshedding on the naming started.

I suggested renaming the current macros as a way to avoid having to
come up with new names. If you have an idea for a new name that makes
sense in the long run, please just go ahead with that.

       Arnd

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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-27 18:02   ` Jonathan Cameron
@ 2021-11-28  9:26     ` Arnd Bergmann
  2021-11-28 12:30       ` Paul Cercueil
  0 siblings, 1 reply; 83+ messages in thread
From: Arnd Bergmann @ 2021-11-28  9:26 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Paul Cercueil, linux-iio, Lars-Peter Clausen, Jonathan Cameron,
	Alexandre Belloni, Anson Huang, Brian Masney, 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, Olivier Moysan, Stefan-Gabriel Mirea,
	Vaishnav M A, Arnd Bergmann

On Sat, Nov 27, 2021 at 7:02 PM Jonathan Cameron <jic23@kernel.org> wrote:
> On Tue, 23 Nov 2021 22:11:08 +0000 Paul Cercueil <paul@crapouillou.net> wrote:
?
> > The problem then is that the SET_*_PM_OPS macros are defined
> > differently according to CONFIG_PM, so their definition would need to
> > be changed to use the (redefined) pm_ptr() macro and a corresponding
> > pm_sleep_ptr() macro.
>
> Small question here.  Why would these macros need to use pm_ptr() macro at all?
>
> Why not just stop them being conditional on CONFIG_PM at all and let dead
> code removal kill them off for us?  You might want to do something different
> for the CONFIG_PM_SLEEP ones though if we care about having it that fine
> grained.

Agreed, there is no need to use pm_ptr() inside of the new macros, it would just
be convenient to define them this way.

The only requirement is to use a construct with the ?: operator that gets
evaluated at compile time based on CONFIG_PM and CONFIG_PM_SLEEP
so that DCE can do its magic.

        Arnd

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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-28  9:26     ` Arnd Bergmann
@ 2021-11-28 12:30       ` Paul Cercueil
  0 siblings, 0 replies; 83+ messages in thread
From: Paul Cercueil @ 2021-11-28 12:30 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jonathan Cameron, linux-iio, Lars-Peter Clausen,
	Jonathan Cameron, Alexandre Belloni, Anson Huang, Brian Masney,
	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, Olivier Moysan,
	Stefan-Gabriel Mirea, Vaishnav M A

Hi,

Le dim., nov. 28 2021 at 10:26:40 +0100, Arnd Bergmann <arnd@arndb.de> 
a écrit :
> On Sat, Nov 27, 2021 at 7:02 PM Jonathan Cameron <jic23@kernel.org> 
> wrote:
>>  On Tue, 23 Nov 2021 22:11:08 +0000 Paul Cercueil 
>> <paul@crapouillou.net> wrote:
> ?
>>  > The problem then is that the SET_*_PM_OPS macros are defined
>>  > differently according to CONFIG_PM, so their definition would 
>> need to
>>  > be changed to use the (redefined) pm_ptr() macro and a 
>> corresponding
>>  > pm_sleep_ptr() macro.
>> 
>>  Small question here.  Why would these macros need to use pm_ptr() 
>> macro at all?
>> 
>>  Why not just stop them being conditional on CONFIG_PM at all and 
>> let dead
>>  code removal kill them off for us?  You might want to do something 
>> different
>>  for the CONFIG_PM_SLEEP ones though if we care about having it that 
>> fine
>>  grained.
> 
> Agreed, there is no need to use pm_ptr() inside of the new macros, it 
> would just
> be convenient to define them this way.

In that case all the callbacks of a dev_pm_ops will be compiled even 
though .suspend/.resume are only for CONFIG_PM_SLEEP.

The driver could do:
.dev.pm = pm_sleep_ptr(&my_pm_sleep_ops),

But that means the driver's dev needs to be aware that pm_sleep_ptr() 
is for simple PM, and pm_ptr() if runtime PM is used.

The alternative I suggested was to use pm_sleep_ptr() inside the 
SET_*_PM_OPS macros (and not pm_ptr() which wouldn't make much sense, I 
agree) so that the callbacks would be included only when 
CONFIG_PM_SLEEP is set; and the drivers would only ever use pm_ptr() 
for their .dev.pm.

I'm slightly in favor of the first solution, just because it would make 
the kernel smaller if !CONFIG_PM_SLEEP as you wouldn't have an empty 
dev_pm_ops struct.

Cheers,
-Paul



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

* Re: [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc.
  2021-11-28  9:17             ` Arnd Bergmann
@ 2021-11-28 12:44               ` Paul Cercueil
  0 siblings, 0 replies; 83+ messages in thread
From: Paul Cercueil @ 2021-11-28 12:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jonathan Cameron, Jonathan Cameron, linux-iio,
	Lars-Peter Clausen, Alexandre Belloni, Anson Huang, Brian Masney,
	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, Olivier Moysan,
	Stefan-Gabriel Mirea, Vaishnav M A

Hi Arnd, Jonathan,

Le dim., nov. 28 2021 at 10:17:55 +0100, Arnd Bergmann <arnd@arndb.de> 
a écrit :
> On Sat, Nov 27, 2021 at 7:09 PM Jonathan Cameron <jic23@kernel.org> 
> wrote:
>>  On Wed, 24 Nov 2021 15:10:06 +0000 Paul Cercueil 
>> <paul@crapouillou.net> wrote:
>>  > Le mer., nov. 24 2021 at 13:23:47 +0100, Arnd Bergmann 
>> <arnd@arndb.de>
>>  >
>>  > So you want to rename the current macros (to e.g. *_PM_OPS_LEGACY)
>>  > everywhere so that new ones can be defined?
>>  >
>>  > What about we introduce new macros, and just deprecate the old 
>> ones
>>  > (with e.g. a checkpatch warning)? That would be way less work.
>> 
>>  Sounds like a sensible approach to me. If Arnd is happy with that we
>>  can move forwards and get the bikshedding on the naming started.
> 
> I suggested renaming the current macros as a way to avoid having to
> come up with new names. If you have an idea for a new name that makes
> sense in the long run, please just go ahead with that.

Yes, I totally understand that. But renaming such a widespread macro 
sounds like a huge undertaking...

What about:

#define SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)    \
    .suspend = pm_sleep_ptr(suspend_fn),              \
    .resume = pm_sleep_ptr(resume_fn),                \
...

#ifndef CONFIG_PM_SLEEP
#define SET_SYSTEM_SLEEP_PM_OPS(a, b) SYSTEM_SLEEP_PM_OPS(a, b)
#else
#define SET_SYSTEM_SLEEP_PM_OPS(a, b)
#endif


#define DEFINE_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
static const struct dev_pm_ops name = {                       \
    SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn),               \
}


SET_SYSTEM_SLEEP_PM_OPS -> SYSTEM_SLEEP_PM_OPS, with the old one now 
defined from the new one;
SIMPLE_DEV_PM_OPS -> DEFINE_SIMPLE_DEV_PM_OPS.

Thoughts?

Cheers,
-Paul



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

* Re: [PATCH 43/49] iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 22:22   ` Matt Ranostay
@ 2021-11-28 16:44     ` Jonathan Cameron
  0 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2021-11-28 16:44 UTC (permalink / raw)
  To: Matt Ranostay
  Cc: open list:IIO SUBSYSTEM AND DRIVERS, Lars-Peter Clausen,
	Paul Cercueil, Jonathan Cameron

On Tue, 23 Nov 2021 14:22:46 -0800
Matt Ranostay <matt.ranostay@konsulko.com> wrote:

> On Tue, Nov 23, 2021 at 1:07 PM 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>
> > Cc: Matt Ranostay <matt.ranostay@konsulko.com>  
> 
> Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
A clang build (without this patch) noted that lidar_write_power() is only used
in these functions (so I got an unused function warning). 

I'll add a maybe_unused to that as well if needed (subject to the
other discussion on how to do this better).

Thanks,

Jonathan

> 
> > ---
> >  drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 10 ++++------
> >  1 file changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
> > index 27026c060ab9..6adc2a0c27cb 100644
> > --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
> > +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
> > @@ -338,8 +338,7 @@ 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)
> > +static __maybe_unused int lidar_pm_runtime_suspend(struct device *dev)
> >  {
> >         struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> >         struct lidar_data *data = iio_priv(indio_dev);
> > @@ -347,7 +346,7 @@ static int lidar_pm_runtime_suspend(struct device *dev)
> >         return lidar_write_power(data, 0x0f);
> >  }
> >
> > -static int lidar_pm_runtime_resume(struct device *dev)
> > +static __maybe_unused int lidar_pm_runtime_resume(struct device *dev)
> >  {
> >         struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> >         struct lidar_data *data = iio_priv(indio_dev);
> > @@ -358,9 +357,8 @@ static int lidar_pm_runtime_resume(struct device *dev)
> >
> >         return ret;
> >  }
> > -#endif
> >
> > -static const struct dev_pm_ops lidar_pm_ops = {
> > +static __maybe_unused const struct dev_pm_ops lidar_pm_ops = {
> >         SET_RUNTIME_PM_OPS(lidar_pm_runtime_suspend,
> >                            lidar_pm_runtime_resume, NULL)
> >  };
> > @@ -369,7 +367,7 @@ 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.0
> >  


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

* Re: [PATCH 12/49] iio:adc:ad7606: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 ` [PATCH 12/49] iio:adc:ad7606: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2022-01-01 16:27   ` Jonathan Cameron
  0 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2022-01-01 16:27 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron

On Tue, 23 Nov 2021 21:09:42 +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.
> 
> The pm_ptr() macro only removes the reference if CONFIG_PM is not
> set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> will not always remove the pm_ops structure.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
I'll comment here as this patch won't exist in v2.

Given the structure is exported from one module to others, the
compiler can't remove it automatically.  Hence this one really does
need the CONFIG_PM_SLEEP guards.

Not sure what I was thinking when I wrote this!

Jonathan

> ---
>  drivers/iio/adc/ad7606.c     | 8 ++------
>  drivers/iio/adc/ad7606.h     | 5 -----
>  drivers/iio/adc/ad7606_par.c | 2 +-
>  drivers/iio/adc/ad7606_spi.c | 2 +-
>  4 files changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index 0a60ecc69d38..16a013aad20f 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -695,9 +695,7 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
>  }
>  EXPORT_SYMBOL_GPL(ad7606_probe);
>  
> -#ifdef CONFIG_PM_SLEEP
> -
> -static int ad7606_suspend(struct device *dev)
> +static __maybe_unused int ad7606_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct ad7606_state *st = iio_priv(indio_dev);
> @@ -710,7 +708,7 @@ static int ad7606_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int ad7606_resume(struct device *dev)
> +static __maybe_unused int ad7606_resume(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct ad7606_state *st = iio_priv(indio_dev);
> @@ -727,8 +725,6 @@ static int ad7606_resume(struct device *dev)
>  SIMPLE_DEV_PM_OPS(ad7606_pm_ops, ad7606_suspend, ad7606_resume);
>  EXPORT_SYMBOL_GPL(ad7606_pm_ops);
>  
> -#endif
> -
>  MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
>  MODULE_DESCRIPTION("Analog Devices AD7606 ADC");
>  MODULE_LICENSE("GPL v2");
> diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
> index 9350ef1f63b5..fd545836790e 100644
> --- a/drivers/iio/adc/ad7606.h
> +++ b/drivers/iio/adc/ad7606.h
> @@ -162,11 +162,6 @@ enum ad7606_supported_device_ids {
>  	ID_AD7616,
>  };
>  
> -#ifdef CONFIG_PM_SLEEP
>  extern const struct dev_pm_ops ad7606_pm_ops;
> -#define AD7606_PM_OPS (&ad7606_pm_ops)
> -#else
> -#define AD7606_PM_OPS NULL
> -#endif
>  
>  #endif /* IIO_ADC_AD7606_H_ */
> diff --git a/drivers/iio/adc/ad7606_par.c b/drivers/iio/adc/ad7606_par.c
> index f732b3ac7878..60be3fb4ae39 100644
> --- a/drivers/iio/adc/ad7606_par.c
> +++ b/drivers/iio/adc/ad7606_par.c
> @@ -92,7 +92,7 @@ static struct platform_driver ad7606_driver = {
>  	.id_table = ad7606_driver_ids,
>  	.driver = {
>  		.name = "ad7606",
> -		.pm = AD7606_PM_OPS,
> +		.pm = pm_ptr(&ad7606_pm_ops),
>  		.of_match_table = ad7606_of_match,
>  	},
>  };
> diff --git a/drivers/iio/adc/ad7606_spi.c b/drivers/iio/adc/ad7606_spi.c
> index 29945ad07dca..8cc525b4b960 100644
> --- a/drivers/iio/adc/ad7606_spi.c
> +++ b/drivers/iio/adc/ad7606_spi.c
> @@ -352,7 +352,7 @@ static struct spi_driver ad7606_driver = {
>  	.driver = {
>  		.name = "ad7606",
>  		.of_match_table = ad7606_of_match,
> -		.pm = AD7606_PM_OPS,
> +		.pm = pm_ptr(&ad7606_pm_ops),
>  	},
>  	.probe = ad7606_spi_probe,
>  	.id_table = ad7606_id_table,


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

* Re: [PATCH 15/49] iio:adc:palmas_gpadc: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:09 ` [PATCH 15/49] iio:adc:palmas_gpadc: " Jonathan Cameron
@ 2022-01-01 16:38   ` Jonathan Cameron
  0 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2022-01-01 16:38 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron

On Tue, 23 Nov 2021 21:09:45 +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.
> 
> The pm_ptr() macro only removes the reference if CONFIG_PM is not
> set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> will not always remove the pm_ops structure.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
>  drivers/iio/adc/palmas_gpadc.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c
> index f9c8385c72d3..98d7764e0662 100644
> --- a/drivers/iio/adc/palmas_gpadc.c
> +++ b/drivers/iio/adc/palmas_gpadc.c
> @@ -653,8 +653,7 @@ 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)
> +static __maybe_unused int palmas_adc_wakeup_configure(struct palmas_gpadc *adc)
>  {
>  	int adc_period, conv;
>  	int i;
> @@ -759,7 +758,7 @@ static int palmas_adc_wakeup_configure(struct palmas_gpadc *adc)
>  	return ret;
>  }
>  
> -static int palmas_adc_wakeup_reset(struct palmas_gpadc *adc)
> +static __maybe_unused int palmas_adc_wakeup_reset(struct palmas_gpadc *adc)
>  {
>  	int ret;
>  
> @@ -777,7 +776,7 @@ static int palmas_adc_wakeup_reset(struct palmas_gpadc *adc)
>  	return ret;
>  }
>  
> -static int palmas_gpadc_suspend(struct device *dev)
> +static __maybe_unused int palmas_gpadc_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct palmas_gpadc *adc = iio_priv(indio_dev);
> @@ -800,7 +799,7 @@ static int palmas_gpadc_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int palmas_gpadc_resume(struct device *dev)
> +static __maybe_unused int palmas_gpadc_resume(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct palmas_gpadc *adc = iio_priv(indio_dev);
> @@ -822,9 +821,8 @@ static int palmas_gpadc_resume(struct device *dev)
>  
>  	return 0;
>  };
> -#endif
>  
> -static const struct dev_pm_ops palmas_pm_ops = {
> +static __maybe_unused const struct dev_pm_ops palmas_pm_ops = {
>  	SET_SYSTEM_SLEEP_PM_OPS(palmas_gpadc_suspend,
>  				palmas_gpadc_resume)
>  };
I missed that this could have been SIMPLE_DEV_PM_OPS - in v2 that
will be the new DEFINE_SIMPLE_DEV_PM_OPS()

> @@ -840,7 +838,7 @@ static struct platform_driver palmas_gpadc_driver = {
>  	.remove = palmas_gpadc_remove,
>  	.driver = {
>  		.name = MOD_NAME,
> -		.pm = &palmas_pm_ops,
> +		.pm = pm_ptr(&palmas_pm_ops),
>  		.of_match_table = of_palmas_gpadc_match_tbl,
>  	},
>  };


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

* Re: [PATCH 37/49] iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused
  2021-11-23 21:10 ` [PATCH 37/49] iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
@ 2022-01-01 17:40   ` Jonathan Cameron
  0 siblings, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2022-01-01 17:40 UTC (permalink / raw)
  To: linux-iio; +Cc: Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron

On Tue, 23 Nov 2021 21:10:07 +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.
> 
> The pm_ptr() macro only removes the reference if CONFIG_PM is not
> set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> will not always remove the pm_ops structure.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This one needs some more thought before any conversion to the new
pm_sleep_ptr() etc as use of
DEFINE_SIMPLE_DEV_PM_OPS() leads to an unused warning for the _core.c
module - which explains the original __maybe_unused under the ifdef.

I'll drop it for now.

Jonathan


> ---
>  drivers/iio/magnetometer/hmc5843.h     | 5 -----
>  drivers/iio/magnetometer/hmc5843_i2c.c | 2 +-
>  drivers/iio/magnetometer/hmc5843_spi.c | 2 +-
>  3 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/magnetometer/hmc5843.h b/drivers/iio/magnetometer/hmc5843.h
> index 9120c8bbf3dd..c3444f3ab1dc 100644
> --- a/drivers/iio/magnetometer/hmc5843.h
> +++ b/drivers/iio/magnetometer/hmc5843.h
> @@ -55,13 +55,8 @@ void hmc5843_common_remove(struct device *dev);
>  int hmc5843_common_suspend(struct device *dev);
>  int hmc5843_common_resume(struct device *dev);
>  
> -#ifdef CONFIG_PM_SLEEP
>  static __maybe_unused SIMPLE_DEV_PM_OPS(hmc5843_pm_ops,
>  					hmc5843_common_suspend,
>  					hmc5843_common_resume);
> -#define HMC5843_PM_OPS (&hmc5843_pm_ops)
> -#else
> -#define HMC5843_PM_OPS NULL
> -#endif
>  
>  #endif /* HMC5843_CORE_H */
> diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c b/drivers/iio/magnetometer/hmc5843_i2c.c
> index bc6e12f1d521..a7359f439f10 100644
> --- a/drivers/iio/magnetometer/hmc5843_i2c.c
> +++ b/drivers/iio/magnetometer/hmc5843_i2c.c
> @@ -93,7 +93,7 @@ MODULE_DEVICE_TABLE(of, hmc5843_of_match);
>  static struct i2c_driver hmc5843_driver = {
>  	.driver = {
>  		.name	= "hmc5843",
> -		.pm	= HMC5843_PM_OPS,
> +		.pm	= pm_ptr(&hmc5843_pm_ops),
>  		.of_match_table = hmc5843_of_match,
>  	},
>  	.id_table	= hmc5843_id,
> diff --git a/drivers/iio/magnetometer/hmc5843_spi.c b/drivers/iio/magnetometer/hmc5843_spi.c
> index 89cf59a62c28..c1bd2ff3c64a 100644
> --- a/drivers/iio/magnetometer/hmc5843_spi.c
> +++ b/drivers/iio/magnetometer/hmc5843_spi.c
> @@ -90,7 +90,7 @@ MODULE_DEVICE_TABLE(spi, hmc5843_id);
>  static struct spi_driver hmc5843_driver = {
>  		.driver = {
>  				.name = "hmc5843",
> -				.pm = HMC5843_PM_OPS,
> +				.pm = pm_ptr(&hmc5843_pm_ops),
>  		},
>  		.id_table = hmc5843_id,
>  		.probe = hmc5843_spi_probe,


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

* Re: [PATCH 41/49] iio:pressure:bmp280: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:10 ` [PATCH 41/49] iio:pressure:bmp280: Switch from CONFIG_PM " Jonathan Cameron
  2021-11-25 16:56   ` Linus Walleij
@ 2022-01-01 17:50   ` Jonathan Cameron
  1 sibling, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2022-01-01 17:50 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron, Linus Walleij

On Tue, 23 Nov 2021 21:10:11 +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>
> Cc: Linus Walleij <linus.walleij@linaro.org>
Dropping this one for now because it has the same complexity around
EXPORT_SYMBOL() and multiple modules so the compiler can't remove the
functions automatically.

Will rethink if there is a way to handle these multi module cases
at a later date.

Thanks,

Jonathan

> ---
>  drivers/iio/pressure/bmp280-core.c | 6 ++----
>  drivers/iio/pressure/bmp280-i2c.c  | 2 +-
>  drivers/iio/pressure/bmp280-spi.c  | 2 +-
>  3 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
> index 6b7da40f99c8..0653e1ea88da 100644
> --- a/drivers/iio/pressure/bmp280-core.c
> +++ b/drivers/iio/pressure/bmp280-core.c
> @@ -1138,8 +1138,7 @@ int bmp280_common_probe(struct device *dev,
>  }
>  EXPORT_SYMBOL(bmp280_common_probe);
>  
> -#ifdef CONFIG_PM
> -static int bmp280_runtime_suspend(struct device *dev)
> +static __maybe_unused int bmp280_runtime_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct bmp280_data *data = iio_priv(indio_dev);
> @@ -1147,7 +1146,7 @@ static int bmp280_runtime_suspend(struct device *dev)
>  	return regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies);
>  }
>  
> -static int bmp280_runtime_resume(struct device *dev)
> +static __maybe_unused int bmp280_runtime_resume(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct bmp280_data *data = iio_priv(indio_dev);
> @@ -1159,7 +1158,6 @@ static int bmp280_runtime_resume(struct device *dev)
>  	usleep_range(data->start_up_time, data->start_up_time + 100);
>  	return data->chip_info->chip_config(data);
>  }
> -#endif /* CONFIG_PM */
>  
>  const struct dev_pm_ops bmp280_dev_pm_ops = {
>  	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c
> index 8b03ea15c0d0..35045bd92846 100644
> --- a/drivers/iio/pressure/bmp280-i2c.c
> +++ b/drivers/iio/pressure/bmp280-i2c.c
> @@ -58,7 +58,7 @@ static struct i2c_driver bmp280_i2c_driver = {
>  	.driver = {
>  		.name	= "bmp280",
>  		.of_match_table = bmp280_of_i2c_match,
> -		.pm = &bmp280_dev_pm_ops,
> +		.pm = pm_ptr(&bmp280_dev_pm_ops),
>  	},
>  	.probe		= bmp280_i2c_probe,
>  	.id_table	= bmp280_i2c_id,
> diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c
> index 625b86878ad8..41f6cc56d229 100644
> --- a/drivers/iio/pressure/bmp280-spi.c
> +++ b/drivers/iio/pressure/bmp280-spi.c
> @@ -109,7 +109,7 @@ static struct spi_driver bmp280_spi_driver = {
>  	.driver = {
>  		.name = "bmp280",
>  		.of_match_table = bmp280_of_spi_match,
> -		.pm = &bmp280_dev_pm_ops,
> +		.pm = pm_ptr(&bmp280_dev_pm_ops),
>  	},
>  	.id_table = bmp280_spi_id,
>  	.probe = bmp280_spi_probe,


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

* Re: [PATCH 48/49] iio:gyro:mpu3050: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused
  2021-11-23 21:10 ` [PATCH 48/49] iio:gyro:mpu3050: Switch from CONFIG_PM " Jonathan Cameron
  2021-11-25 16:56   ` Linus Walleij
@ 2022-01-01 18:00   ` Jonathan Cameron
  1 sibling, 0 replies; 83+ messages in thread
From: Jonathan Cameron @ 2022-01-01 18:00 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Paul Cercueil, Jonathan Cameron, Linus Walleij

On Tue, 23 Nov 2021 21:10:18 +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>
> Cc: Linus Walleij <linus.walleij@linaro.org>
Another one I'm going to drop for now because the multiple module
nature of it means the compiler can't tell what it can remove.

Needs more thought.

Thanks,

Jonathan

> ---
>  drivers/iio/gyro/mpu3050-core.c | 8 +++-----
>  drivers/iio/gyro/mpu3050-i2c.c  | 2 +-
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c
> index ea387efab62d..4ec107b9e779 100644
> --- a/drivers/iio/gyro/mpu3050-core.c
> +++ b/drivers/iio/gyro/mpu3050-core.c
> @@ -1281,19 +1281,17 @@ int mpu3050_common_remove(struct device *dev)
>  }
>  EXPORT_SYMBOL(mpu3050_common_remove);
>  
> -#ifdef CONFIG_PM
> -static int mpu3050_runtime_suspend(struct device *dev)
> +static __maybe_unused int mpu3050_runtime_suspend(struct device *dev)
>  {
>  	return mpu3050_power_down(iio_priv(dev_get_drvdata(dev)));
>  }
>  
> -static int mpu3050_runtime_resume(struct device *dev)
> +static __maybe_unused int mpu3050_runtime_resume(struct device *dev)
>  {
>  	return mpu3050_power_up(iio_priv(dev_get_drvdata(dev)));
>  }
> -#endif /* CONFIG_PM */
>  
> -const struct dev_pm_ops mpu3050_dev_pm_ops = {
> +const __maybe_unused struct dev_pm_ops mpu3050_dev_pm_ops = {
>  	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
>  				pm_runtime_force_resume)
>  	SET_RUNTIME_PM_OPS(mpu3050_runtime_suspend,
> diff --git a/drivers/iio/gyro/mpu3050-i2c.c b/drivers/iio/gyro/mpu3050-i2c.c
> index ef5bcbc4b45b..820133cad601 100644
> --- a/drivers/iio/gyro/mpu3050-i2c.c
> +++ b/drivers/iio/gyro/mpu3050-i2c.c
> @@ -114,7 +114,7 @@ static struct i2c_driver mpu3050_i2c_driver = {
>  	.driver = {
>  		.of_match_table = mpu3050_i2c_of_match,
>  		.name = "mpu3050-i2c",
> -		.pm = &mpu3050_dev_pm_ops,
> +		.pm = pm_ptr(&mpu3050_dev_pm_ops),
>  	},
>  };
>  module_i2c_driver(mpu3050_i2c_driver);


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

end of thread, other threads:[~2022-01-01 17:55 UTC | newest]

Thread overview: 83+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 21:09 [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Jonathan Cameron
2021-11-23 21:09 ` [PATCH 01/49] iio:accel:da311: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused Jonathan Cameron
2021-11-23 21:09 ` [PATCH 02/49] iio:accel:da280: " Jonathan Cameron
2021-11-23 22:17   ` Paul Cercueil
2021-11-24  9:48     ` Jonathan Cameron
2021-11-23 21:09 ` [PATCH 03/49] iio:accel:dmard06: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 04/49] iio:accel:dmard10: Switch from CONFIG_PM " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 05/49] iio:accel:mc3230: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
2021-11-23 21:37   ` Hans de Goede
2021-11-23 21:09 ` [PATCH 06/49] iio:accel:mma7660: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 07/49] iio:accel:mma9551: Switch from CONFIG_PM " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 08/49] iio:accel:mma9553: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 09/49] iio:accel:stk8ba50: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 10/49] iio:accel:kxsd9: Switch from CONFIG_PM " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 11/49] iio:adc:ab8500: " Jonathan Cameron
2021-11-25 16:55   ` Linus Walleij
2021-11-23 21:09 ` [PATCH 12/49] iio:adc:ad7606: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
2022-01-01 16:27   ` Jonathan Cameron
2021-11-23 21:09 ` [PATCH 13/49] iio:adc:at91-adc: " Jonathan Cameron
2021-11-24  9:16   ` Alexandre Belloni
2021-11-23 21:09 ` [PATCH 14/49] iio:adc:exynos_adc: " Jonathan Cameron
2021-11-25  8:50   ` Krzysztof Kozlowski
2021-11-23 21:09 ` [PATCH 15/49] iio:adc:palmas_gpadc: " Jonathan Cameron
2022-01-01 16:38   ` Jonathan Cameron
2021-11-23 21:09 ` [PATCH 16/49] iio:adc:stm32:Switch from CONFIG_PM " Jonathan Cameron
2021-11-24  9:33   ` Fabrice Gasnier
2021-11-23 21:09 ` [PATCH 17/49] iio:adc:rcar: Switch " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 18/49] iio:adc:rockchip: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 19/49] iio:adc:twl6030: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 20/49] iio:adc:vf610: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 21/49] iio:common:ssp: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 22/49] iio:dac:vf610: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 23/49] iio:light:apds9300: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 24/49] iio:light:bh1780: Switch from CONFIG_PM " Jonathan Cameron
2021-11-25 16:56   ` Linus Walleij
2021-11-23 21:09 ` [PATCH 25/49] iio:light:cm3232: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 26/49] iio:light:isl29018: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 27/49] iio:light:isl29125: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 28/49] iio:light:jsa1212: " Jonathan Cameron
2021-11-23 21:09 ` [PATCH 29/49] iio:light:ltr501: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 30/49] iio:light:stk3310: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 31/49] iio:light:tcs3414: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 32/49] iio:light:tcs3472: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 33/49] iio:light:tsl2563: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 34/49] iio:light:tsl4531: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 35/49] iio:light:us5182: Switch from CONFIG_PM " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 36/49] iio:magn:ak8975: " Jonathan Cameron
2021-11-23 22:24   ` Matt Ranostay
2021-11-23 21:10 ` [PATCH 37/49] iio:magn:hmc5843: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
2022-01-01 17:40   ` Jonathan Cameron
2021-11-23 21:10 ` [PATCH 38/49] iio:magn:mag3110: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 39/49] iio:magn:mmc35240: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 40/49] iio:pressure:mpl3115: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 41/49] iio:pressure:bmp280: Switch from CONFIG_PM " Jonathan Cameron
2021-11-25 16:56   ` Linus Walleij
2022-01-01 17:50   ` Jonathan Cameron
2021-11-23 21:10 ` [PATCH 42/49] iio:proximity:as3935: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
2021-11-23 22:23   ` Matt Ranostay
2021-11-23 21:10 ` [PATCH 43/49] iio:proximity:pulsedlight: Switch from CONFIG_PM " Jonathan Cameron
2021-11-23 22:22   ` Matt Ranostay
2021-11-28 16:44     ` Jonathan Cameron
2021-11-23 21:10 ` [PATCH 44/49] iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 45/49] iio:proximity:sx9500: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 46/49] iio:temperature:tmp006: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 47/49] iio:temperature:tmp007: " Jonathan Cameron
2021-11-23 21:10 ` [PATCH 48/49] iio:gyro:mpu3050: Switch from CONFIG_PM " Jonathan Cameron
2021-11-25 16:56   ` Linus Walleij
2022-01-01 18:00   ` Jonathan Cameron
2021-11-23 21:10 ` [PATCH 49/49] iio:chemical:atlas: " Jonathan Cameron
2021-11-23 22:22   ` Matt Ranostay
2021-11-23 22:11 ` [PATCH 00/49] iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc Paul Cercueil
2021-11-24  7:29   ` Arnd Bergmann
2021-11-24 10:11     ` Jonathan Cameron
2021-11-24 10:58       ` Paul Cercueil
2021-11-24 12:23       ` Arnd Bergmann
2021-11-24 15:10         ` Paul Cercueil
2021-11-27 18:09           ` Jonathan Cameron
2021-11-28  9:17             ` Arnd Bergmann
2021-11-28 12:44               ` Paul Cercueil
2021-11-27 18:02   ` Jonathan Cameron
2021-11-28  9:26     ` Arnd Bergmann
2021-11-28 12:30       ` Paul Cercueil
2021-11-24  0:58 ` Brian Masney

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.