linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS()
@ 2022-09-25 15:57 Jonathan Cameron
  2022-09-25 15:57 ` [PATCH v2 1/5] pm: Improve EXPORT_*_DEV_PM_OPS macros Jonathan Cameron
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Jonathan Cameron @ 2022-09-25 15:57 UTC (permalink / raw)
  To: linux-iio
  Cc: Rafael J . Wysocki, Paul Cercueil, Linus Walleij, Sean Nyekjaer,
	Rui Miguel Silva, Jean-Baptiste Maneyrol, Jonathan Cameron

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

I've included Paul Cercueil's patch from
https://lore.kernel.org/all/20220813154902.32f86ee2@jic23-huawei/
but my assumption is that will go via a different tree.
It's just included here to provide everything needed to build these
against current IIO tree / linux-next

V2: Switch to Paul's more flexible implementation.
I've dropped all tags given as the form of the patches is somewhat different
from in v1.

The aim is the same as v1 - moving the remaining IIO drivers over
to the new PM macros that remove the need to mess around with
__maybe_unused or ifdef magic.  They do this by ensuring the compiler can
see all the code, and then drop it as unused if that is relevant.

Jonathan Cameron (4):
  iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS()
  iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace.
  iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace
  iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace

Paul Cercueil (1):
  pm: Improve EXPORT_*_DEV_PM_OPS macros

 drivers/iio/accel/fxls8962af-core.c           | 16 ++++----
 drivers/iio/accel/fxls8962af-i2c.c            |  2 +-
 drivers/iio/accel/fxls8962af-spi.c            |  2 +-
 drivers/iio/gyro/fxas21002c_core.c            | 21 +++++------
 drivers/iio/gyro/fxas21002c_i2c.c             |  3 +-
 drivers/iio/gyro/fxas21002c_spi.c             |  3 +-
 .../iio/imu/inv_icm42600/inv_icm42600_core.c  | 21 +++++------
 .../iio/imu/inv_icm42600/inv_icm42600_i2c.c   |  3 +-
 .../iio/imu/inv_icm42600/inv_icm42600_spi.c   |  3 +-
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c    | 17 ++++-----
 drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c     |  3 +-
 drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c     |  3 +-
 include/linux/pm.h                            | 37 ++++++++++++-------
 include/linux/pm_runtime.h                    | 20 ++++++----
 14 files changed, 84 insertions(+), 70 deletions(-)

-- 
2.37.2


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

* [PATCH v2 1/5] pm: Improve EXPORT_*_DEV_PM_OPS macros
  2022-09-25 15:57 [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
@ 2022-09-25 15:57 ` Jonathan Cameron
  2022-09-25 15:57 ` [PATCH v2 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2022-09-25 15:57 UTC (permalink / raw)
  To: linux-iio
  Cc: Rafael J . Wysocki, Paul Cercueil, Linus Walleij, Sean Nyekjaer,
	Rui Miguel Silva, Jean-Baptiste Maneyrol, Rafael J . Wysocki,
	Jonathan Cameron

From: Paul Cercueil <paul@crapouillou.net>

Update the _EXPORT_DEV_PM_OPS() internal macro. It was not used anywhere
outside pm.h and pm_runtime.h, so it is safe to update it.

Before, this macro would take a few parameters to be used as sleep and
runtime callbacks. This made it unsuitable to use with different
callbacks, for instance the "noirq" ones.

It is now semantically different: instead of creating a conditionally
exported dev_pm_ops structure, it only contains part of the definition.

This macro should however never be used directly (hence the trailing
underscore). Instead, the following four macros are provided:
- EXPORT_DEV_PM_OPS(name)
- EXPORT_GPL_DEV_PM_OPS(name)
- EXPORT_NS_DEV_PM_OPS(name, ns)
- EXPORT_NS_GPL_DEV_PM_OPS(name, ns)

For instance, it is now possible to conditionally export noirq
suspend/resume PM functions like this:

EXPORT_GPL_DEV_PM_OPS(foo_pm_ops) = {
    NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
};

The existing helper macros EXPORT_*_SIMPLE_DEV_PM_OPS() and
EXPORT_*_RUNTIME_DEV_PM_OPS() have been updated to use these new macros.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 include/linux/pm.h         | 37 +++++++++++++++++++++++--------------
 include/linux/pm_runtime.h | 20 ++++++++++++--------
 2 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/include/linux/pm.h b/include/linux/pm.h
index 871c9c49ec9d..93cd34f00822 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -375,19 +375,20 @@ const struct dev_pm_ops name = { \
 }
 
 #ifdef CONFIG_PM
-#define _EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \
-			   runtime_resume_fn, idle_fn, sec, ns)		\
-	_DEFINE_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \
-			   runtime_resume_fn, idle_fn); \
-	__EXPORT_SYMBOL(name, sec, ns)
+#define _EXPORT_DEV_PM_OPS(name, sec, ns)				\
+	const struct dev_pm_ops name;					\
+	__EXPORT_SYMBOL(name, sec, ns);					\
+	const struct dev_pm_ops name
 #else
-#define _EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \
-			   runtime_resume_fn, idle_fn, sec, ns) \
-static __maybe_unused _DEFINE_DEV_PM_OPS(__static_##name, suspend_fn, \
-					 resume_fn, runtime_suspend_fn, \
-					 runtime_resume_fn, idle_fn)
+#define _EXPORT_DEV_PM_OPS(name, sec, ns)				\
+	static __maybe_unused const struct dev_pm_ops __static_##name
 #endif
 
+#define EXPORT_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "", "")
+#define EXPORT_GPL_DEV_PM_OPS(name) _EXPORT_DEV_PM_OPS(name, "_gpl", "")
+#define EXPORT_NS_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "", #ns)
+#define EXPORT_NS_GPL_DEV_PM_OPS(name, ns) _EXPORT_DEV_PM_OPS(name, "_gpl", #ns)
+
 /*
  * Use this if you want to use the same suspend and resume callbacks for suspend
  * to RAM and hibernation.
@@ -399,13 +400,21 @@ static __maybe_unused _DEFINE_DEV_PM_OPS(__static_##name, suspend_fn, \
 	_DEFINE_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL)
 
 #define EXPORT_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
-	_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL, "", "")
+	EXPORT_DEV_PM_OPS(name) = { \
+		SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+	}
 #define EXPORT_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
-	_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL, "_gpl", "")
+	EXPORT_GPL_DEV_PM_OPS(name) = { \
+		SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+	}
 #define EXPORT_NS_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, ns)	\
-	_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL, "", #ns)
+	EXPORT_NS_DEV_PM_OPS(name, ns) = { \
+		SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+	}
 #define EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn, ns)	\
-	_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL, "_gpl", #ns)
+	EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
+		SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
+	}
 
 /* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */
 #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 0a41b2dcccad..9a8151a2bdea 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -40,17 +40,21 @@
 			   resume_fn, idle_fn)
 
 #define EXPORT_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
-	_EXPORT_DEV_PM_OPS(name, pm_runtime_force_suspend, pm_runtime_force_resume, \
-			   suspend_fn, resume_fn, idle_fn, "", "")
+	EXPORT_DEV_PM_OPS(name) = { \
+		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
+	}
 #define EXPORT_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
-	_EXPORT_DEV_PM_OPS(name, pm_runtime_force_suspend, pm_runtime_force_resume, \
-			   suspend_fn, resume_fn, idle_fn, "_gpl", "")
+	EXPORT_GPL_DEV_PM_OPS(name) = { \
+		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
+	}
 #define EXPORT_NS_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
-	_EXPORT_DEV_PM_OPS(name, pm_runtime_force_suspend, pm_runtime_force_resume, \
-			   suspend_fn, resume_fn, idle_fn, "", #ns)
+	EXPORT_NS_DEV_PM_OPS(name, ns) = { \
+		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
+	}
 #define EXPORT_NS_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
-	_EXPORT_DEV_PM_OPS(name, pm_runtime_force_suspend, pm_runtime_force_resume, \
-			   suspend_fn, resume_fn, idle_fn, "_gpl", #ns)
+	EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
+		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
+	}
 
 #ifdef CONFIG_PM
 extern struct workqueue_struct *pm_wq;
-- 
2.37.2


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

* [PATCH v2 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS()
  2022-09-25 15:57 [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
  2022-09-25 15:57 ` [PATCH v2 1/5] pm: Improve EXPORT_*_DEV_PM_OPS macros Jonathan Cameron
@ 2022-09-25 15:57 ` Jonathan Cameron
  2022-10-03  9:44   ` Sean Nyekjaer
  2022-09-25 15:57 ` [PATCH v2 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace Jonathan Cameron
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Jonathan Cameron @ 2022-09-25 15:57 UTC (permalink / raw)
  To: linux-iio
  Cc: Rafael J . Wysocki, Paul Cercueil, Linus Walleij, Sean Nyekjaer,
	Rui Miguel Silva, Jean-Baptiste Maneyrol, Jonathan Cameron

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

Using this macro allows the compiler to remove unused
structures and callbacks if we are not building with
CONFIG_PM* without needing __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Sean Nyekjaer <sean@geanix.com>

--
Switched to Paul Cercueil's more flexible implementation fo the macro.
Dropped Sean's Ack given new form of macro being used.
---
 drivers/iio/accel/fxls8962af-core.c | 16 +++++++---------
 drivers/iio/accel/fxls8962af-i2c.c  |  2 +-
 drivers/iio/accel/fxls8962af-spi.c  |  2 +-
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
index 8874d6d61725..bf259db281f5 100644
--- a/drivers/iio/accel/fxls8962af-core.c
+++ b/drivers/iio/accel/fxls8962af-core.c
@@ -1241,7 +1241,7 @@ int fxls8962af_core_probe(struct device *dev, struct regmap *regmap, int irq)
 }
 EXPORT_SYMBOL_NS_GPL(fxls8962af_core_probe, IIO_FXLS8962AF);
 
-static int __maybe_unused fxls8962af_runtime_suspend(struct device *dev)
+static int fxls8962af_runtime_suspend(struct device *dev)
 {
 	struct fxls8962af_data *data = iio_priv(dev_get_drvdata(dev));
 	int ret;
@@ -1255,14 +1255,14 @@ static int __maybe_unused fxls8962af_runtime_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused fxls8962af_runtime_resume(struct device *dev)
+static int fxls8962af_runtime_resume(struct device *dev)
 {
 	struct fxls8962af_data *data = iio_priv(dev_get_drvdata(dev));
 
 	return fxls8962af_active(data);
 }
 
-static int __maybe_unused fxls8962af_suspend(struct device *dev)
+static int fxls8962af_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct fxls8962af_data *data = iio_priv(indio_dev);
@@ -1283,7 +1283,7 @@ static int __maybe_unused fxls8962af_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused fxls8962af_resume(struct device *dev)
+static int fxls8962af_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct fxls8962af_data *data = iio_priv(indio_dev);
@@ -1300,12 +1300,10 @@ static int __maybe_unused fxls8962af_resume(struct device *dev)
 	return 0;
 }
 
-const struct dev_pm_ops fxls8962af_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(fxls8962af_suspend, fxls8962af_resume)
-	SET_RUNTIME_PM_OPS(fxls8962af_runtime_suspend,
-			   fxls8962af_runtime_resume, NULL)
+EXPORT_NS_GPL_DEV_PM_OPS(fxls8962af_pm_ops, IIO_FXLS8962AF) = {
+	SYSTEM_SLEEP_PM_OPS(fxls8962af_suspend, fxls8962af_resume)
+	RUNTIME_PM_OPS(fxls8962af_runtime_suspend, fxls8962af_runtime_resume, NULL)
 };
-EXPORT_SYMBOL_NS_GPL(fxls8962af_pm_ops, IIO_FXLS8962AF);
 
 MODULE_AUTHOR("Sean Nyekjaer <sean@geanix.com>");
 MODULE_DESCRIPTION("NXP FXLS8962AF/FXLS8964AF accelerometer driver");
diff --git a/drivers/iio/accel/fxls8962af-i2c.c b/drivers/iio/accel/fxls8962af-i2c.c
index 8fbadfea1620..22640eaebac7 100644
--- a/drivers/iio/accel/fxls8962af-i2c.c
+++ b/drivers/iio/accel/fxls8962af-i2c.c
@@ -45,7 +45,7 @@ static struct i2c_driver fxls8962af_driver = {
 	.driver = {
 		   .name = "fxls8962af_i2c",
 		   .of_match_table = fxls8962af_of_match,
-		   .pm = &fxls8962af_pm_ops,
+		   .pm = pm_ptr(&fxls8962af_pm_ops),
 		   },
 	.probe_new = fxls8962af_probe,
 	.id_table = fxls8962af_id,
diff --git a/drivers/iio/accel/fxls8962af-spi.c b/drivers/iio/accel/fxls8962af-spi.c
index 885b3ab7fcb5..a0d192211839 100644
--- a/drivers/iio/accel/fxls8962af-spi.c
+++ b/drivers/iio/accel/fxls8962af-spi.c
@@ -44,7 +44,7 @@ MODULE_DEVICE_TABLE(spi, fxls8962af_spi_id_table);
 static struct spi_driver fxls8962af_driver = {
 	.driver = {
 		   .name = "fxls8962af_spi",
-		   .pm = &fxls8962af_pm_ops,
+		   .pm = pm_ptr(&fxls8962af_pm_ops),
 		   .of_match_table = fxls8962af_spi_of_match,
 		   },
 	.probe = fxls8962af_probe,
-- 
2.37.2


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

* [PATCH v2 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace.
  2022-09-25 15:57 [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
  2022-09-25 15:57 ` [PATCH v2 1/5] pm: Improve EXPORT_*_DEV_PM_OPS macros Jonathan Cameron
  2022-09-25 15:57 ` [PATCH v2 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
@ 2022-09-25 15:57 ` Jonathan Cameron
  2022-09-26 13:14   ` Rui Miguel Silva
  2022-09-25 15:57 ` [PATCH v2 4/5] iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace Jonathan Cameron
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Jonathan Cameron @ 2022-09-25 15:57 UTC (permalink / raw)
  To: linux-iio
  Cc: Rafael J . Wysocki, Paul Cercueil, Linus Walleij, Sean Nyekjaer,
	Rui Miguel Silva, Jean-Baptiste Maneyrol, Jonathan Cameron

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

Includes using EXPORT_NS_GPL_DEV_PM_OPS() and the simplifications that
brings by allowing the compiler to remove unused struct dev_pm_ops
and callbacks without needing explicit __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

--
v2: Switch to Paul's more flexible approach to EXPORT_NS_GPL_DEV_PM_OPS()
Dropped Rui's tag on basis this is rather different from v1 due to
the different macro implementation.
---
 drivers/iio/gyro/fxas21002c_core.c | 21 ++++++++++-----------
 drivers/iio/gyro/fxas21002c_i2c.c  |  3 ++-
 drivers/iio/gyro/fxas21002c_spi.c  |  3 ++-
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c
index a36d71d9e3ea..3ea1d4613080 100644
--- a/drivers/iio/gyro/fxas21002c_core.c
+++ b/drivers/iio/gyro/fxas21002c_core.c
@@ -998,7 +998,7 @@ int fxas21002c_core_probe(struct device *dev, struct regmap *regmap, int irq,
 
 	return ret;
 }
-EXPORT_SYMBOL_GPL(fxas21002c_core_probe);
+EXPORT_SYMBOL_NS_GPL(fxas21002c_core_probe, IIO_FXAS21002C);
 
 void fxas21002c_core_remove(struct device *dev)
 {
@@ -1009,9 +1009,9 @@ void fxas21002c_core_remove(struct device *dev)
 	pm_runtime_disable(dev);
 	pm_runtime_set_suspended(dev);
 }
-EXPORT_SYMBOL_GPL(fxas21002c_core_remove);
+EXPORT_SYMBOL_NS_GPL(fxas21002c_core_remove, IIO_FXAS21002C);
 
-static int __maybe_unused fxas21002c_suspend(struct device *dev)
+static int fxas21002c_suspend(struct device *dev)
 {
 	struct fxas21002c_data *data = iio_priv(dev_get_drvdata(dev));
 
@@ -1021,7 +1021,7 @@ static int __maybe_unused fxas21002c_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused fxas21002c_resume(struct device *dev)
+static int fxas21002c_resume(struct device *dev)
 {
 	struct fxas21002c_data *data = iio_priv(dev_get_drvdata(dev));
 	int ret;
@@ -1033,26 +1033,25 @@ static int __maybe_unused fxas21002c_resume(struct device *dev)
 	return fxas21002c_mode_set(data, data->prev_mode);
 }
 
-static int __maybe_unused fxas21002c_runtime_suspend(struct device *dev)
+static int fxas21002c_runtime_suspend(struct device *dev)
 {
 	struct fxas21002c_data *data = iio_priv(dev_get_drvdata(dev));
 
 	return fxas21002c_mode_set(data, FXAS21002C_MODE_READY);
 }
 
-static int __maybe_unused fxas21002c_runtime_resume(struct device *dev)
+static int fxas21002c_runtime_resume(struct device *dev)
 {
 	struct fxas21002c_data *data = iio_priv(dev_get_drvdata(dev));
 
 	return fxas21002c_mode_set(data, FXAS21002C_MODE_ACTIVE);
 }
 
-const struct dev_pm_ops fxas21002c_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(fxas21002c_suspend, fxas21002c_resume)
-	SET_RUNTIME_PM_OPS(fxas21002c_runtime_suspend,
-			   fxas21002c_runtime_resume, NULL)
+EXPORT_NS_GPL_DEV_PM_OPS(fxas21002c_pm_ops, IIO_FXAS21002C) = {
+	SYSTEM_SLEEP_PM_OPS(fxas21002c_suspend, fxas21002c_resume)
+	RUNTIME_PM_OPS(fxas21002c_runtime_suspend, fxas21002c_runtime_resume,
+		       NULL)
 };
-EXPORT_SYMBOL_GPL(fxas21002c_pm_ops);
 
 MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/gyro/fxas21002c_i2c.c b/drivers/iio/gyro/fxas21002c_i2c.c
index a7807fd97483..241401a9dfea 100644
--- a/drivers/iio/gyro/fxas21002c_i2c.c
+++ b/drivers/iio/gyro/fxas21002c_i2c.c
@@ -55,7 +55,7 @@ MODULE_DEVICE_TABLE(of, fxas21002c_i2c_of_match);
 static struct i2c_driver fxas21002c_i2c_driver = {
 	.driver = {
 		.name = "fxas21002c_i2c",
-		.pm = &fxas21002c_pm_ops,
+		.pm = pm_ptr(&fxas21002c_pm_ops),
 		.of_match_table = fxas21002c_i2c_of_match,
 	},
 	.probe_new	= fxas21002c_i2c_probe,
@@ -67,3 +67,4 @@ module_i2c_driver(fxas21002c_i2c_driver);
 MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("FXAS21002C I2C Gyro driver");
+MODULE_IMPORT_NS(IIO_FXAS21002C);
diff --git a/drivers/iio/gyro/fxas21002c_spi.c b/drivers/iio/gyro/fxas21002c_spi.c
index c3ac169facf9..4f633826547c 100644
--- a/drivers/iio/gyro/fxas21002c_spi.c
+++ b/drivers/iio/gyro/fxas21002c_spi.c
@@ -54,7 +54,7 @@ MODULE_DEVICE_TABLE(of, fxas21002c_spi_of_match);
 static struct spi_driver fxas21002c_spi_driver = {
 	.driver = {
 		.name = "fxas21002c_spi",
-		.pm = &fxas21002c_pm_ops,
+		.pm = pm_ptr(&fxas21002c_pm_ops),
 		.of_match_table = fxas21002c_spi_of_match,
 	},
 	.probe		= fxas21002c_spi_probe,
@@ -66,3 +66,4 @@ module_spi_driver(fxas21002c_spi_driver);
 MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("FXAS21002C SPI Gyro driver");
+MODULE_IMPORT_NS(IIO_FXAS21002C);
-- 
2.37.2


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

* [PATCH v2 4/5] iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace
  2022-09-25 15:57 [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
                   ` (2 preceding siblings ...)
  2022-09-25 15:57 ` [PATCH v2 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace Jonathan Cameron
@ 2022-09-25 15:57 ` Jonathan Cameron
  2022-10-03  8:27   ` Jean-Baptiste Maneyrol
  2022-09-25 15:57 ` [PATCH v2 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace Jonathan Cameron
  2022-10-15 16:47 ` [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
  5 siblings, 1 reply; 11+ messages in thread
From: Jonathan Cameron @ 2022-09-25 15:57 UTC (permalink / raw)
  To: linux-iio
  Cc: Rafael J . Wysocki, Paul Cercueil, Linus Walleij, Sean Nyekjaer,
	Rui Miguel Silva, Jean-Baptiste Maneyrol, Jonathan Cameron

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

As these exports are only relevant to core module and users in the
bus specific modules, move them out of the main kernel namespace.

Includes using EXPORT_NS_GPL_DEV_PM_OPS() and the simplifications that
brings by allowing the compiler to remove unused struct dev_pm_ops
and callbacks without needing explicit __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

--
v2: Switch to Paul's more flexible version of the
EXPORT_NS_GPL_DEV_PM_OPS()
---
 .../iio/imu/inv_icm42600/inv_icm42600_core.c  | 21 +++++++++----------
 .../iio/imu/inv_icm42600/inv_icm42600_i2c.c   |  3 ++-
 .../iio/imu/inv_icm42600/inv_icm42600_spi.c   |  3 ++-
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
index ca85fccc9839..b63c5dab1a56 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
@@ -41,7 +41,7 @@ const struct regmap_config inv_icm42600_regmap_config = {
 	.ranges = inv_icm42600_regmap_ranges,
 	.num_ranges = ARRAY_SIZE(inv_icm42600_regmap_ranges),
 };
-EXPORT_SYMBOL_GPL(inv_icm42600_regmap_config);
+EXPORT_SYMBOL_NS_GPL(inv_icm42600_regmap_config, IIO_ICM42600);
 
 struct inv_icm42600_hw {
 	uint8_t whoami;
@@ -660,13 +660,13 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip, int irq,
 
 	return devm_add_action_or_reset(dev, inv_icm42600_disable_pm, dev);
 }
-EXPORT_SYMBOL_GPL(inv_icm42600_core_probe);
+EXPORT_SYMBOL_NS_GPL(inv_icm42600_core_probe, IIO_ICM42600);
 
 /*
  * Suspend saves sensors state and turns everything off.
  * Check first if runtime suspend has not already done the job.
  */
-static int __maybe_unused inv_icm42600_suspend(struct device *dev)
+static int inv_icm42600_suspend(struct device *dev)
 {
 	struct inv_icm42600_state *st = dev_get_drvdata(dev);
 	int ret;
@@ -706,7 +706,7 @@ static int __maybe_unused inv_icm42600_suspend(struct device *dev)
  * System resume gets the system back on and restores the sensors state.
  * Manually put runtime power management in system active state.
  */
-static int __maybe_unused inv_icm42600_resume(struct device *dev)
+static int inv_icm42600_resume(struct device *dev)
 {
 	struct inv_icm42600_state *st = dev_get_drvdata(dev);
 	int ret;
@@ -739,7 +739,7 @@ static int __maybe_unused inv_icm42600_resume(struct device *dev)
 }
 
 /* Runtime suspend will turn off sensors that are enabled by iio devices. */
-static int __maybe_unused inv_icm42600_runtime_suspend(struct device *dev)
+static int inv_icm42600_runtime_suspend(struct device *dev)
 {
 	struct inv_icm42600_state *st = dev_get_drvdata(dev);
 	int ret;
@@ -761,7 +761,7 @@ static int __maybe_unused inv_icm42600_runtime_suspend(struct device *dev)
 }
 
 /* Sensors are enabled by iio devices, no need to turn them back on here. */
-static int __maybe_unused inv_icm42600_runtime_resume(struct device *dev)
+static int inv_icm42600_runtime_resume(struct device *dev)
 {
 	struct inv_icm42600_state *st = dev_get_drvdata(dev);
 	int ret;
@@ -774,12 +774,11 @@ static int __maybe_unused inv_icm42600_runtime_resume(struct device *dev)
 	return ret;
 }
 
-const struct dev_pm_ops inv_icm42600_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(inv_icm42600_suspend, inv_icm42600_resume)
-	SET_RUNTIME_PM_OPS(inv_icm42600_runtime_suspend,
-			   inv_icm42600_runtime_resume, NULL)
+EXPORT_NS_GPL_DEV_PM_OPS(inv_icm42600_pm_ops, IIO_ICM42600) = {
+	SYSTEM_SLEEP_PM_OPS(inv_icm42600_suspend, inv_icm42600_resume)
+	RUNTIME_PM_OPS(inv_icm42600_runtime_suspend,
+		       inv_icm42600_runtime_resume, NULL)
 };
-EXPORT_SYMBOL_GPL(inv_icm42600_pm_ops);
 
 MODULE_AUTHOR("InvenSense, Inc.");
 MODULE_DESCRIPTION("InvenSense ICM-426xx device driver");
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c
index d4a692b838d0..4f96989ddf4a 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c
@@ -93,7 +93,7 @@ static struct i2c_driver inv_icm42600_driver = {
 	.driver = {
 		.name = "inv-icm42600-i2c",
 		.of_match_table = inv_icm42600_of_matches,
-		.pm = &inv_icm42600_pm_ops,
+		.pm = pm_ptr(&inv_icm42600_pm_ops),
 	},
 	.probe_new = inv_icm42600_probe,
 };
@@ -102,3 +102,4 @@ module_i2c_driver(inv_icm42600_driver);
 MODULE_AUTHOR("InvenSense, Inc.");
 MODULE_DESCRIPTION("InvenSense ICM-426xx I2C driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(IIO_ICM42600);
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c
index e6305e5fa975..486b46e53113 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c
@@ -89,7 +89,7 @@ static struct spi_driver inv_icm42600_driver = {
 	.driver = {
 		.name = "inv-icm42600-spi",
 		.of_match_table = inv_icm42600_of_matches,
-		.pm = &inv_icm42600_pm_ops,
+		.pm = pm_ptr(&inv_icm42600_pm_ops),
 	},
 	.probe = inv_icm42600_probe,
 };
@@ -98,3 +98,4 @@ module_spi_driver(inv_icm42600_driver);
 MODULE_AUTHOR("InvenSense, Inc.");
 MODULE_DESCRIPTION("InvenSense ICM-426xx SPI driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(IIO_ICM42600);
-- 
2.37.2


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

* [PATCH v2 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace
  2022-09-25 15:57 [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
                   ` (3 preceding siblings ...)
  2022-09-25 15:57 ` [PATCH v2 4/5] iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace Jonathan Cameron
@ 2022-09-25 15:57 ` Jonathan Cameron
  2022-10-03  8:26   ` Jean-Baptiste Maneyrol
  2022-10-15 16:47 ` [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
  5 siblings, 1 reply; 11+ messages in thread
From: Jonathan Cameron @ 2022-09-25 15:57 UTC (permalink / raw)
  To: linux-iio
  Cc: Rafael J . Wysocki, Paul Cercueil, Linus Walleij, Sean Nyekjaer,
	Rui Miguel Silva, Jean-Baptiste Maneyrol, Jonathan Cameron

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

As these exports are only relevant to core module and users in the
bus specific modules, move them out of the main kernel namespace.

Includes using EXPORT_NS_GPL_DEV_PM_OPS() and the simplifications that
brings by allowing the compiler to remove unused struct dev_pm_ops
and callbacks without needing explicit __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Cc: Linus Walleij <linus.walleij@linaro.org>

--
v2: Switch to more flexible version of EXPORT* macro from Paul.
Dropped Linus' tag as the new patch is significantly different.
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 17 ++++++++---------
 drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c  |  3 ++-
 drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c  |  3 ++-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 86fbbe904050..8a129120b73d 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -1653,9 +1653,9 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
 	inv_mpu6050_set_power_itg(st, false);
 	return result;
 }
-EXPORT_SYMBOL_GPL(inv_mpu_core_probe);
+EXPORT_SYMBOL_NS_GPL(inv_mpu_core_probe, IIO_MPU6050);
 
-static int __maybe_unused inv_mpu_resume(struct device *dev)
+static int inv_mpu_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct inv_mpu6050_state *st = iio_priv(indio_dev);
@@ -1687,7 +1687,7 @@ static int __maybe_unused inv_mpu_resume(struct device *dev)
 	return result;
 }
 
-static int __maybe_unused inv_mpu_suspend(struct device *dev)
+static int inv_mpu_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct inv_mpu6050_state *st = iio_priv(indio_dev);
@@ -1730,7 +1730,7 @@ static int __maybe_unused inv_mpu_suspend(struct device *dev)
 	return result;
 }
 
-static int __maybe_unused inv_mpu_runtime_suspend(struct device *dev)
+static int inv_mpu_runtime_suspend(struct device *dev)
 {
 	struct inv_mpu6050_state *st = iio_priv(dev_get_drvdata(dev));
 	unsigned int sensors;
@@ -1755,7 +1755,7 @@ static int __maybe_unused inv_mpu_runtime_suspend(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused inv_mpu_runtime_resume(struct device *dev)
+static int inv_mpu_runtime_resume(struct device *dev)
 {
 	struct inv_mpu6050_state *st = iio_priv(dev_get_drvdata(dev));
 	int ret;
@@ -1767,11 +1767,10 @@ static int __maybe_unused inv_mpu_runtime_resume(struct device *dev)
 	return inv_mpu6050_set_power_itg(st, true);
 }
 
-const struct dev_pm_ops inv_mpu_pmops = {
-	SET_SYSTEM_SLEEP_PM_OPS(inv_mpu_suspend, inv_mpu_resume)
-	SET_RUNTIME_PM_OPS(inv_mpu_runtime_suspend, inv_mpu_runtime_resume, NULL)
+EXPORT_NS_GPL_DEV_PM_OPS(inv_mpu_pmops, IIO_MPU6050) = {
+	SYSTEM_SLEEP_PM_OPS(inv_mpu_suspend, inv_mpu_resume)
+	RUNTIME_PM_OPS(inv_mpu_runtime_suspend, inv_mpu_runtime_resume, NULL)
 };
-EXPORT_SYMBOL_GPL(inv_mpu_pmops);
 
 MODULE_AUTHOR("Invensense Corporation");
 MODULE_DESCRIPTION("Invensense device MPU6050 driver");
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index 2aa647704a79..f89164fabf4b 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -269,7 +269,7 @@ static struct i2c_driver inv_mpu_driver = {
 		.of_match_table = inv_of_match,
 		.acpi_match_table = inv_acpi_match,
 		.name	=	"inv-mpu6050-i2c",
-		.pm     =       &inv_mpu_pmops,
+		.pm     =       pm_ptr(&inv_mpu_pmops),
 	},
 };
 
@@ -278,3 +278,4 @@ module_i2c_driver(inv_mpu_driver);
 MODULE_AUTHOR("Invensense Corporation");
 MODULE_DESCRIPTION("Invensense device MPU6050 driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(IIO_MPU6050);
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
index e6107b0cc38f..89f46c2f213d 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
@@ -154,7 +154,7 @@ static struct spi_driver inv_mpu_driver = {
 		.of_match_table = inv_of_match,
 		.acpi_match_table = inv_acpi_match,
 		.name	=	"inv-mpu6000-spi",
-		.pm     =       &inv_mpu_pmops,
+		.pm     =       pm_ptr(&inv_mpu_pmops),
 	},
 };
 
@@ -163,3 +163,4 @@ module_spi_driver(inv_mpu_driver);
 MODULE_AUTHOR("Adriana Reus <adriana.reus@intel.com>");
 MODULE_DESCRIPTION("Invensense device MPU6000 driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(IIO_MPU6050);
-- 
2.37.2


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

* Re: [PATCH v2 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace.
  2022-09-25 15:57 ` [PATCH v2 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace Jonathan Cameron
@ 2022-09-26 13:14   ` Rui Miguel Silva
  0 siblings, 0 replies; 11+ messages in thread
From: Rui Miguel Silva @ 2022-09-26 13:14 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Rafael J . Wysocki, Paul Cercueil, Linus Walleij,
	Sean Nyekjaer, Jean-Baptiste Maneyrol, Jonathan Cameron

Hey Jonathan,
On Sun, Sep 25, 2022 at 04:57:17PM +0100, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Includes using EXPORT_NS_GPL_DEV_PM_OPS() and the simplifications that
> brings by allowing the compiler to remove unused struct dev_pm_ops
> and callbacks without needing explicit __maybe_unused markings.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Rui Miguel Silva <rui.silva@linaro.org>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Again, many thanks for making this changes.
LGTM.

Acked-by: Rui Miguel Silva <rui.silva@linaro.org>

Cheers,
  Rui

> 
> --
> v2: Switch to Paul's more flexible approach to EXPORT_NS_GPL_DEV_PM_OPS()
> Dropped Rui's tag on basis this is rather different from v1 due to
> the different macro implementation.
> ---
>  drivers/iio/gyro/fxas21002c_core.c | 21 ++++++++++-----------
>  drivers/iio/gyro/fxas21002c_i2c.c  |  3 ++-
>  drivers/iio/gyro/fxas21002c_spi.c  |  3 ++-
>  3 files changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c
> index a36d71d9e3ea..3ea1d4613080 100644
> --- a/drivers/iio/gyro/fxas21002c_core.c
> +++ b/drivers/iio/gyro/fxas21002c_core.c
> @@ -998,7 +998,7 @@ int fxas21002c_core_probe(struct device *dev, struct regmap *regmap, int irq,
>  
>  	return ret;
>  }
> -EXPORT_SYMBOL_GPL(fxas21002c_core_probe);
> +EXPORT_SYMBOL_NS_GPL(fxas21002c_core_probe, IIO_FXAS21002C);
>  
>  void fxas21002c_core_remove(struct device *dev)
>  {
> @@ -1009,9 +1009,9 @@ void fxas21002c_core_remove(struct device *dev)
>  	pm_runtime_disable(dev);
>  	pm_runtime_set_suspended(dev);
>  }
> -EXPORT_SYMBOL_GPL(fxas21002c_core_remove);
> +EXPORT_SYMBOL_NS_GPL(fxas21002c_core_remove, IIO_FXAS21002C);
>  
> -static int __maybe_unused fxas21002c_suspend(struct device *dev)
> +static int fxas21002c_suspend(struct device *dev)
>  {
>  	struct fxas21002c_data *data = iio_priv(dev_get_drvdata(dev));
>  
> @@ -1021,7 +1021,7 @@ static int __maybe_unused fxas21002c_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int __maybe_unused fxas21002c_resume(struct device *dev)
> +static int fxas21002c_resume(struct device *dev)
>  {
>  	struct fxas21002c_data *data = iio_priv(dev_get_drvdata(dev));
>  	int ret;
> @@ -1033,26 +1033,25 @@ static int __maybe_unused fxas21002c_resume(struct device *dev)
>  	return fxas21002c_mode_set(data, data->prev_mode);
>  }
>  
> -static int __maybe_unused fxas21002c_runtime_suspend(struct device *dev)
> +static int fxas21002c_runtime_suspend(struct device *dev)
>  {
>  	struct fxas21002c_data *data = iio_priv(dev_get_drvdata(dev));
>  
>  	return fxas21002c_mode_set(data, FXAS21002C_MODE_READY);
>  }
>  
> -static int __maybe_unused fxas21002c_runtime_resume(struct device *dev)
> +static int fxas21002c_runtime_resume(struct device *dev)
>  {
>  	struct fxas21002c_data *data = iio_priv(dev_get_drvdata(dev));
>  
>  	return fxas21002c_mode_set(data, FXAS21002C_MODE_ACTIVE);
>  }
>  
> -const struct dev_pm_ops fxas21002c_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(fxas21002c_suspend, fxas21002c_resume)
> -	SET_RUNTIME_PM_OPS(fxas21002c_runtime_suspend,
> -			   fxas21002c_runtime_resume, NULL)
> +EXPORT_NS_GPL_DEV_PM_OPS(fxas21002c_pm_ops, IIO_FXAS21002C) = {
> +	SYSTEM_SLEEP_PM_OPS(fxas21002c_suspend, fxas21002c_resume)
> +	RUNTIME_PM_OPS(fxas21002c_runtime_suspend, fxas21002c_runtime_resume,
> +		       NULL)
>  };
> -EXPORT_SYMBOL_GPL(fxas21002c_pm_ops);
>  
>  MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");
>  MODULE_LICENSE("GPL v2");
> diff --git a/drivers/iio/gyro/fxas21002c_i2c.c b/drivers/iio/gyro/fxas21002c_i2c.c
> index a7807fd97483..241401a9dfea 100644
> --- a/drivers/iio/gyro/fxas21002c_i2c.c
> +++ b/drivers/iio/gyro/fxas21002c_i2c.c
> @@ -55,7 +55,7 @@ MODULE_DEVICE_TABLE(of, fxas21002c_i2c_of_match);
>  static struct i2c_driver fxas21002c_i2c_driver = {
>  	.driver = {
>  		.name = "fxas21002c_i2c",
> -		.pm = &fxas21002c_pm_ops,
> +		.pm = pm_ptr(&fxas21002c_pm_ops),
>  		.of_match_table = fxas21002c_i2c_of_match,
>  	},
>  	.probe_new	= fxas21002c_i2c_probe,
> @@ -67,3 +67,4 @@ module_i2c_driver(fxas21002c_i2c_driver);
>  MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");
>  MODULE_LICENSE("GPL v2");
>  MODULE_DESCRIPTION("FXAS21002C I2C Gyro driver");
> +MODULE_IMPORT_NS(IIO_FXAS21002C);
> diff --git a/drivers/iio/gyro/fxas21002c_spi.c b/drivers/iio/gyro/fxas21002c_spi.c
> index c3ac169facf9..4f633826547c 100644
> --- a/drivers/iio/gyro/fxas21002c_spi.c
> +++ b/drivers/iio/gyro/fxas21002c_spi.c
> @@ -54,7 +54,7 @@ MODULE_DEVICE_TABLE(of, fxas21002c_spi_of_match);
>  static struct spi_driver fxas21002c_spi_driver = {
>  	.driver = {
>  		.name = "fxas21002c_spi",
> -		.pm = &fxas21002c_pm_ops,
> +		.pm = pm_ptr(&fxas21002c_pm_ops),
>  		.of_match_table = fxas21002c_spi_of_match,
>  	},
>  	.probe		= fxas21002c_spi_probe,
> @@ -66,3 +66,4 @@ module_spi_driver(fxas21002c_spi_driver);
>  MODULE_AUTHOR("Rui Miguel Silva <rui.silva@linaro.org>");
>  MODULE_LICENSE("GPL v2");
>  MODULE_DESCRIPTION("FXAS21002C SPI Gyro driver");
> +MODULE_IMPORT_NS(IIO_FXAS21002C);
> -- 
> 2.37.2
> 

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

* Re: [PATCH v2 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace
  2022-09-25 15:57 ` [PATCH v2 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace Jonathan Cameron
@ 2022-10-03  8:26   ` Jean-Baptiste Maneyrol
  0 siblings, 0 replies; 11+ messages in thread
From: Jean-Baptiste Maneyrol @ 2022-10-03  8:26 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Rafael J . Wysocki, Paul Cercueil, Linus Walleij, Sean Nyekjaer,
	Rui Miguel Silva, Jonathan Cameron

Hello Jonathan,

looks good for me.

Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

Thanks,
JB

From: Jonathan Cameron <jic23@kernel.org>
Sent: Sunday, September 25, 2022 17:57
To: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>
Cc: Rafael J . Wysocki <rafael@kernel.org>; Paul Cercueil <paul@crapouillou.net>; Linus Walleij <linus.walleij@linaro.org>; Sean Nyekjaer <sean@geanix.com>; Rui Miguel Silva <rui.silva@linaro.org>; Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [PATCH v2 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace 
 
[CAUTION] This is EXTERNAL email. Do not click any links or open attachments unless you recognize the sender and know the content is safe.

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

As these exports are only relevant to core module and users in the
bus specific modules, move them out of the main kernel namespace.

Includes using EXPORT_NS_GPL_DEV_PM_OPS() and the simplifications that
brings by allowing the compiler to remove unused struct dev_pm_ops
and callbacks without needing explicit __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Cc: Linus Walleij <linus.walleij@linaro.org>

--
v2: Switch to more flexible version of EXPORT* macro from Paul.
Dropped Linus' tag as the new patch is significantly different.
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 17 ++++++++---------
 drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c  |  3 ++-
 drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c  |  3 ++-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 86fbbe904050..8a129120b73d 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -1653,9 +1653,9 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
         inv_mpu6050_set_power_itg(st, false);
         return result;
 }
-EXPORT_SYMBOL_GPL(inv_mpu_core_probe);
+EXPORT_SYMBOL_NS_GPL(inv_mpu_core_probe, IIO_MPU6050);
 
-static int __maybe_unused inv_mpu_resume(struct device *dev)
+static int inv_mpu_resume(struct device *dev)
 {
         struct iio_dev *indio_dev = dev_get_drvdata(dev);
         struct inv_mpu6050_state *st = iio_priv(indio_dev);
@@ -1687,7 +1687,7 @@ static int __maybe_unused inv_mpu_resume(struct device *dev)
         return result;
 }
 
-static int __maybe_unused inv_mpu_suspend(struct device *dev)
+static int inv_mpu_suspend(struct device *dev)
 {
         struct iio_dev *indio_dev = dev_get_drvdata(dev);
         struct inv_mpu6050_state *st = iio_priv(indio_dev);
@@ -1730,7 +1730,7 @@ static int __maybe_unused inv_mpu_suspend(struct device *dev)
         return result;
 }
 
-static int __maybe_unused inv_mpu_runtime_suspend(struct device *dev)
+static int inv_mpu_runtime_suspend(struct device *dev)
 {
         struct inv_mpu6050_state *st = iio_priv(dev_get_drvdata(dev));
         unsigned int sensors;
@@ -1755,7 +1755,7 @@ static int __maybe_unused inv_mpu_runtime_suspend(struct device *dev)
         return ret;
 }
 
-static int __maybe_unused inv_mpu_runtime_resume(struct device *dev)
+static int inv_mpu_runtime_resume(struct device *dev)
 {
         struct inv_mpu6050_state *st = iio_priv(dev_get_drvdata(dev));
         int ret;
@@ -1767,11 +1767,10 @@ static int __maybe_unused inv_mpu_runtime_resume(struct device *dev)
         return inv_mpu6050_set_power_itg(st, true);
 }
 
-const struct dev_pm_ops inv_mpu_pmops = {
-       SET_SYSTEM_SLEEP_PM_OPS(inv_mpu_suspend, inv_mpu_resume)
-       SET_RUNTIME_PM_OPS(inv_mpu_runtime_suspend, inv_mpu_runtime_resume, NULL)
+EXPORT_NS_GPL_DEV_PM_OPS(inv_mpu_pmops, IIO_MPU6050) = {
+       SYSTEM_SLEEP_PM_OPS(inv_mpu_suspend, inv_mpu_resume)
+       RUNTIME_PM_OPS(inv_mpu_runtime_suspend, inv_mpu_runtime_resume, NULL)
 };
-EXPORT_SYMBOL_GPL(inv_mpu_pmops);
 
 MODULE_AUTHOR("Invensense Corporation");
 MODULE_DESCRIPTION("Invensense device MPU6050 driver");
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index 2aa647704a79..f89164fabf4b 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -269,7 +269,7 @@ static struct i2c_driver inv_mpu_driver = {
                 .of_match_table = inv_of_match,
                 .acpi_match_table = inv_acpi_match,
                 .name   =       "inv-mpu6050-i2c",
-               .pm     =       &inv_mpu_pmops,
+               .pm     =       pm_ptr(&inv_mpu_pmops),
         },
 };
 
@@ -278,3 +278,4 @@ module_i2c_driver(inv_mpu_driver);
 MODULE_AUTHOR("Invensense Corporation");
 MODULE_DESCRIPTION("Invensense device MPU6050 driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(IIO_MPU6050);
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
index e6107b0cc38f..89f46c2f213d 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
@@ -154,7 +154,7 @@ static struct spi_driver inv_mpu_driver = {
                 .of_match_table = inv_of_match,
                 .acpi_match_table = inv_acpi_match,
                 .name   =       "inv-mpu6000-spi",
-               .pm     =       &inv_mpu_pmops,
+               .pm     =       pm_ptr(&inv_mpu_pmops),
         },
 };
 
@@ -163,3 +163,4 @@ module_spi_driver(inv_mpu_driver);
 MODULE_AUTHOR("Adriana Reus <adriana.reus@intel.com>");
 MODULE_DESCRIPTION("Invensense device MPU6000 driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(IIO_MPU6050);
-- 
2.37.2

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

* Re: [PATCH v2 4/5] iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace
  2022-09-25 15:57 ` [PATCH v2 4/5] iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace Jonathan Cameron
@ 2022-10-03  8:27   ` Jean-Baptiste Maneyrol
  0 siblings, 0 replies; 11+ messages in thread
From: Jean-Baptiste Maneyrol @ 2022-10-03  8:27 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Rafael J . Wysocki, Paul Cercueil, Linus Walleij, Sean Nyekjaer,
	Rui Miguel Silva, Jonathan Cameron

Hello Jonathan,

looks good for me.

Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

Thanks,
JB


From: Jonathan Cameron <jic23@kernel.org>
Sent: Sunday, September 25, 2022 17:57
To: linux-iio@vger.kernel.org <linux-iio@vger.kernel.org>
Cc: Rafael J . Wysocki <rafael@kernel.org>; Paul Cercueil <paul@crapouillou.net>; Linus Walleij <linus.walleij@linaro.org>; Sean Nyekjaer <sean@geanix.com>; Rui Miguel Silva <rui.silva@linaro.org>; Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>; Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [PATCH v2 4/5] iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace 
 
[CAUTION] This is EXTERNAL email. Do not click any links or open attachments unless you recognize the sender and know the content is safe.

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

As these exports are only relevant to core module and users in the
bus specific modules, move them out of the main kernel namespace.

Includes using EXPORT_NS_GPL_DEV_PM_OPS() and the simplifications that
brings by allowing the compiler to remove unused struct dev_pm_ops
and callbacks without needing explicit __maybe_unused markings.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>

--
v2: Switch to Paul's more flexible version of the
EXPORT_NS_GPL_DEV_PM_OPS()
---
 .../iio/imu/inv_icm42600/inv_icm42600_core.c  | 21 +++++++++----------
 .../iio/imu/inv_icm42600/inv_icm42600_i2c.c   |  3 ++-
 .../iio/imu/inv_icm42600/inv_icm42600_spi.c   |  3 ++-
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
index ca85fccc9839..b63c5dab1a56 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
@@ -41,7 +41,7 @@ const struct regmap_config inv_icm42600_regmap_config = {
         .ranges = inv_icm42600_regmap_ranges,
         .num_ranges = ARRAY_SIZE(inv_icm42600_regmap_ranges),
 };
-EXPORT_SYMBOL_GPL(inv_icm42600_regmap_config);
+EXPORT_SYMBOL_NS_GPL(inv_icm42600_regmap_config, IIO_ICM42600);
 
 struct inv_icm42600_hw {
         uint8_t whoami;
@@ -660,13 +660,13 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip, int irq,
 
         return devm_add_action_or_reset(dev, inv_icm42600_disable_pm, dev);
 }
-EXPORT_SYMBOL_GPL(inv_icm42600_core_probe);
+EXPORT_SYMBOL_NS_GPL(inv_icm42600_core_probe, IIO_ICM42600);
 
 /*
  * Suspend saves sensors state and turns everything off.
  * Check first if runtime suspend has not already done the job.
  */
-static int __maybe_unused inv_icm42600_suspend(struct device *dev)
+static int inv_icm42600_suspend(struct device *dev)
 {
         struct inv_icm42600_state *st = dev_get_drvdata(dev);
         int ret;
@@ -706,7 +706,7 @@ static int __maybe_unused inv_icm42600_suspend(struct device *dev)
  * System resume gets the system back on and restores the sensors state.
  * Manually put runtime power management in system active state.
  */
-static int __maybe_unused inv_icm42600_resume(struct device *dev)
+static int inv_icm42600_resume(struct device *dev)
 {
         struct inv_icm42600_state *st = dev_get_drvdata(dev);
         int ret;
@@ -739,7 +739,7 @@ static int __maybe_unused inv_icm42600_resume(struct device *dev)
 }
 
 /* Runtime suspend will turn off sensors that are enabled by iio devices. */
-static int __maybe_unused inv_icm42600_runtime_suspend(struct device *dev)
+static int inv_icm42600_runtime_suspend(struct device *dev)
 {
         struct inv_icm42600_state *st = dev_get_drvdata(dev);
         int ret;
@@ -761,7 +761,7 @@ static int __maybe_unused inv_icm42600_runtime_suspend(struct device *dev)
 }
 
 /* Sensors are enabled by iio devices, no need to turn them back on here. */
-static int __maybe_unused inv_icm42600_runtime_resume(struct device *dev)
+static int inv_icm42600_runtime_resume(struct device *dev)
 {
         struct inv_icm42600_state *st = dev_get_drvdata(dev);
         int ret;
@@ -774,12 +774,11 @@ static int __maybe_unused inv_icm42600_runtime_resume(struct device *dev)
         return ret;
 }
 
-const struct dev_pm_ops inv_icm42600_pm_ops = {
-       SET_SYSTEM_SLEEP_PM_OPS(inv_icm42600_suspend, inv_icm42600_resume)
-       SET_RUNTIME_PM_OPS(inv_icm42600_runtime_suspend,
-                          inv_icm42600_runtime_resume, NULL)
+EXPORT_NS_GPL_DEV_PM_OPS(inv_icm42600_pm_ops, IIO_ICM42600) = {
+       SYSTEM_SLEEP_PM_OPS(inv_icm42600_suspend, inv_icm42600_resume)
+       RUNTIME_PM_OPS(inv_icm42600_runtime_suspend,
+                      inv_icm42600_runtime_resume, NULL)
 };
-EXPORT_SYMBOL_GPL(inv_icm42600_pm_ops);
 
 MODULE_AUTHOR("InvenSense, Inc.");
 MODULE_DESCRIPTION("InvenSense ICM-426xx device driver");
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c
index d4a692b838d0..4f96989ddf4a 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c
@@ -93,7 +93,7 @@ static struct i2c_driver inv_icm42600_driver = {
         .driver = {
                 .name = "inv-icm42600-i2c",
                 .of_match_table = inv_icm42600_of_matches,
-               .pm = &inv_icm42600_pm_ops,
+               .pm = pm_ptr(&inv_icm42600_pm_ops),
         },
         .probe_new = inv_icm42600_probe,
 };
@@ -102,3 +102,4 @@ module_i2c_driver(inv_icm42600_driver);
 MODULE_AUTHOR("InvenSense, Inc.");
 MODULE_DESCRIPTION("InvenSense ICM-426xx I2C driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(IIO_ICM42600);
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c
index e6305e5fa975..486b46e53113 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c
@@ -89,7 +89,7 @@ static struct spi_driver inv_icm42600_driver = {
         .driver = {
                 .name = "inv-icm42600-spi",
                 .of_match_table = inv_icm42600_of_matches,
-               .pm = &inv_icm42600_pm_ops,
+               .pm = pm_ptr(&inv_icm42600_pm_ops),
         },
         .probe = inv_icm42600_probe,
 };
@@ -98,3 +98,4 @@ module_spi_driver(inv_icm42600_driver);
 MODULE_AUTHOR("InvenSense, Inc.");
 MODULE_DESCRIPTION("InvenSense ICM-426xx SPI driver");
 MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(IIO_ICM42600);
-- 
2.37.2

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

* Re: [PATCH v2 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS()
  2022-09-25 15:57 ` [PATCH v2 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
@ 2022-10-03  9:44   ` Sean Nyekjaer
  0 siblings, 0 replies; 11+ messages in thread
From: Sean Nyekjaer @ 2022-10-03  9:44 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Rafael J . Wysocki, Paul Cercueil, Linus Walleij,
	Rui Miguel Silva, Jean-Baptiste Maneyrol, Jonathan Cameron

On Sun, Sep 25, 2022 at 04:57:16PM +0100, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Using this macro allows the compiler to remove unused
> structures and callbacks if we are not building with
> CONFIG_PM* without needing __maybe_unused markings.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Sean Nyekjaer <sean@geanix.com>
> 

Acked-by: Sean Nyekjaer <sean@geanix.com>

> --
> Switched to Paul Cercueil's more flexible implementation fo the macro.
> Dropped Sean's Ack given new form of macro being used.

Re-added my Ack :)

> ---
>  drivers/iio/accel/fxls8962af-core.c | 16 +++++++---------
>  drivers/iio/accel/fxls8962af-i2c.c  |  2 +-
>  drivers/iio/accel/fxls8962af-spi.c  |  2 +-
>  3 files changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
> index 8874d6d61725..bf259db281f5 100644
> --- a/drivers/iio/accel/fxls8962af-core.c
> +++ b/drivers/iio/accel/fxls8962af-core.c
> @@ -1241,7 +1241,7 @@ int fxls8962af_core_probe(struct device *dev, struct regmap *regmap, int irq)
>  }
>  EXPORT_SYMBOL_NS_GPL(fxls8962af_core_probe, IIO_FXLS8962AF);
>  
> -static int __maybe_unused fxls8962af_runtime_suspend(struct device *dev)
> +static int fxls8962af_runtime_suspend(struct device *dev)
>  {
>  	struct fxls8962af_data *data = iio_priv(dev_get_drvdata(dev));
>  	int ret;
> @@ -1255,14 +1255,14 @@ static int __maybe_unused fxls8962af_runtime_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int __maybe_unused fxls8962af_runtime_resume(struct device *dev)
> +static int fxls8962af_runtime_resume(struct device *dev)
>  {
>  	struct fxls8962af_data *data = iio_priv(dev_get_drvdata(dev));
>  
>  	return fxls8962af_active(data);
>  }
>  
> -static int __maybe_unused fxls8962af_suspend(struct device *dev)
> +static int fxls8962af_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct fxls8962af_data *data = iio_priv(indio_dev);
> @@ -1283,7 +1283,7 @@ static int __maybe_unused fxls8962af_suspend(struct device *dev)
>  	return 0;
>  }
>  
> -static int __maybe_unused fxls8962af_resume(struct device *dev)
> +static int fxls8962af_resume(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct fxls8962af_data *data = iio_priv(indio_dev);
> @@ -1300,12 +1300,10 @@ static int __maybe_unused fxls8962af_resume(struct device *dev)
>  	return 0;
>  }
>  
> -const struct dev_pm_ops fxls8962af_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(fxls8962af_suspend, fxls8962af_resume)
> -	SET_RUNTIME_PM_OPS(fxls8962af_runtime_suspend,
> -			   fxls8962af_runtime_resume, NULL)
> +EXPORT_NS_GPL_DEV_PM_OPS(fxls8962af_pm_ops, IIO_FXLS8962AF) = {
> +	SYSTEM_SLEEP_PM_OPS(fxls8962af_suspend, fxls8962af_resume)
> +	RUNTIME_PM_OPS(fxls8962af_runtime_suspend, fxls8962af_runtime_resume, NULL)
>  };
> -EXPORT_SYMBOL_NS_GPL(fxls8962af_pm_ops, IIO_FXLS8962AF);
>  
>  MODULE_AUTHOR("Sean Nyekjaer <sean@geanix.com>");
>  MODULE_DESCRIPTION("NXP FXLS8962AF/FXLS8964AF accelerometer driver");
> diff --git a/drivers/iio/accel/fxls8962af-i2c.c b/drivers/iio/accel/fxls8962af-i2c.c
> index 8fbadfea1620..22640eaebac7 100644
> --- a/drivers/iio/accel/fxls8962af-i2c.c
> +++ b/drivers/iio/accel/fxls8962af-i2c.c
> @@ -45,7 +45,7 @@ static struct i2c_driver fxls8962af_driver = {
>  	.driver = {
>  		   .name = "fxls8962af_i2c",
>  		   .of_match_table = fxls8962af_of_match,
> -		   .pm = &fxls8962af_pm_ops,
> +		   .pm = pm_ptr(&fxls8962af_pm_ops),
>  		   },
>  	.probe_new = fxls8962af_probe,
>  	.id_table = fxls8962af_id,
> diff --git a/drivers/iio/accel/fxls8962af-spi.c b/drivers/iio/accel/fxls8962af-spi.c
> index 885b3ab7fcb5..a0d192211839 100644
> --- a/drivers/iio/accel/fxls8962af-spi.c
> +++ b/drivers/iio/accel/fxls8962af-spi.c
> @@ -44,7 +44,7 @@ MODULE_DEVICE_TABLE(spi, fxls8962af_spi_id_table);
>  static struct spi_driver fxls8962af_driver = {
>  	.driver = {
>  		   .name = "fxls8962af_spi",
> -		   .pm = &fxls8962af_pm_ops,
> +		   .pm = pm_ptr(&fxls8962af_pm_ops),
>  		   .of_match_table = fxls8962af_spi_of_match,
>  		   },
>  	.probe = fxls8962af_probe,
> -- 
> 2.37.2
> 

-- 
Best regards
Sean Nyekjær
Embedded Linux Consultant

+45 42427326
sean@geanix.com

Geanix ApS
https://geanix.com
DK39600706

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

* Re: [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS()
  2022-09-25 15:57 [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
                   ` (4 preceding siblings ...)
  2022-09-25 15:57 ` [PATCH v2 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace Jonathan Cameron
@ 2022-10-15 16:47 ` Jonathan Cameron
  5 siblings, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2022-10-15 16:47 UTC (permalink / raw)
  To: linux-iio
  Cc: Rafael J . Wysocki, Paul Cercueil, Linus Walleij, Sean Nyekjaer,
	Rui Miguel Silva, Jean-Baptiste Maneyrol, Jonathan Cameron

On Sun, 25 Sep 2022 16:57:14 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> I've included Paul Cercueil's patch from
> https://lore.kernel.org/all/20220813154902.32f86ee2@jic23-huawei/
> but my assumption is that will go via a different tree.
> It's just included here to provide everything needed to build these
> against current IIO tree / linux-next
> 
> V2: Switch to Paul's more flexible implementation.
> I've dropped all tags given as the form of the patches is somewhat different
> from in v1.
> 
> The aim is the same as v1 - moving the remaining IIO drivers over
> to the new PM macros that remove the need to mess around with
> __maybe_unused or ifdef magic.  They do this by ensuring the compiler can
> see all the code, and then drop it as unused if that is relevant.

Patch 1 is now upstream so 2-5 applied to the togreg branch of iio.git and
pushed out as testing until I can rebase that tree on rc1.

Thanks,

Jonathan

> 
> Jonathan Cameron (4):
>   iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS()
>   iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace.
>   iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace
>   iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace
> 
> Paul Cercueil (1):
>   pm: Improve EXPORT_*_DEV_PM_OPS macros
> 
>  drivers/iio/accel/fxls8962af-core.c           | 16 ++++----
>  drivers/iio/accel/fxls8962af-i2c.c            |  2 +-
>  drivers/iio/accel/fxls8962af-spi.c            |  2 +-
>  drivers/iio/gyro/fxas21002c_core.c            | 21 +++++------
>  drivers/iio/gyro/fxas21002c_i2c.c             |  3 +-
>  drivers/iio/gyro/fxas21002c_spi.c             |  3 +-
>  .../iio/imu/inv_icm42600/inv_icm42600_core.c  | 21 +++++------
>  .../iio/imu/inv_icm42600/inv_icm42600_i2c.c   |  3 +-
>  .../iio/imu/inv_icm42600/inv_icm42600_spi.c   |  3 +-
>  drivers/iio/imu/inv_mpu6050/inv_mpu_core.c    | 17 ++++-----
>  drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c     |  3 +-
>  drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c     |  3 +-
>  include/linux/pm.h                            | 37 ++++++++++++-------
>  include/linux/pm_runtime.h                    | 20 ++++++----
>  14 files changed, 84 insertions(+), 70 deletions(-)
> 


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

end of thread, other threads:[~2022-10-15 16:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-25 15:57 [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
2022-09-25 15:57 ` [PATCH v2 1/5] pm: Improve EXPORT_*_DEV_PM_OPS macros Jonathan Cameron
2022-09-25 15:57 ` [PATCH v2 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
2022-10-03  9:44   ` Sean Nyekjaer
2022-09-25 15:57 ` [PATCH v2 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace Jonathan Cameron
2022-09-26 13:14   ` Rui Miguel Silva
2022-09-25 15:57 ` [PATCH v2 4/5] iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace Jonathan Cameron
2022-10-03  8:27   ` Jean-Baptiste Maneyrol
2022-09-25 15:57 ` [PATCH v2 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace Jonathan Cameron
2022-10-03  8:26   ` Jean-Baptiste Maneyrol
2022-10-15 16:47 ` [PATCH v2 0/5] IIO: Use EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).