PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO.
Subsystems (7)
Jonathan Cameron
maintainercover PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO.
From: Jonathan Cameron <[email protected]>
Perhaps the most complex case we can have is a core driver module (usually with accompanying per bus modules) that exports, in a namespace, a struct dev_pm_ops. The driver has different handling for runtime and sleep suspend / resume so (almost) all callbacks are provided. The pm.h helper macro _EXPORT_DEV_PM_OPS() could be used here but the handling of the last two parameters is unusual and very different from the macros intended for driver usage. First parameter needs to be "_gpl" and second needs to be the namespace specified as a string. Other NS macros take it without quotes.
As such, this series proposes introducing a suitable macro and then provides a number of IIO driver conversions. Where relevant the exports from the driver are moved into the new namespace.
If accepted we can either take the whole lot through the PM tree and hope there is nothing much else overlapping with this driver code in this cycle, or ideally we could use an immutable branch and pull this into both the IIO and PM trees.
Jonathan Cameron (5):
PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own.
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
drivers/iio/accel/fxls8962af-core.c | 17 +++++++-------- 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 | 18 +++++++--------- drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 3 ++- drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 3 ++- include/linux/pm.h | 5 +++++ 13 files changed, 52 insertions(+), 52 deletions(-)
Signature · 1 line
2.37.1
Jonathan Cameron
maintainerPATCH 1/5 PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own.
From: Jonathan Cameron <[email protected]>
A driver wishing to export a struct dev_pm_ops with both suspend and runtime ops provided could use _EXPORT_DEV_PM_OPS() directly but that macro is not intended for use in drivers and requires non intuitive aspect such as passing "_gpl" as one parameter and the namespace as a string. As such just provide a macro to cover the GPL and NS case in a fashion that is in line with similar macros.
--- include/linux/pm.h | 5 +++++ 1 file changed, 5 insertions(+)
include/linux/pm.h +5 -0
@@ -407,6 +407,11 @@ static __maybe_unused _DEFINE_DEV_PM_OPS(__static_##name, suspend_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) +#define EXPORT_NS_GPL_DEV_PM_OPS (name, suspend_fn, resume_fn, runtime_suspend_fn, \ + runtime_resume_fn, idle_fn, ns) \ + _EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \ + runtime_resume_fn, idle_fn, "_gpl", #ns) +/* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */ #define SIMPLE_DEV_PM_OPS (name, suspend_fn, resume_fn) \ const struct dev_pm_ops __maybe_unused name = { \
Signature · 1 line
2.37.1
Re: [PATCH 1/5] PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own.
Hi Jonathan,
If you can wait a day or two - I would like to submit my own version of EXPORT_NS_GPL_DEV_PM_OPS, which should be more versatile than your version.
Cheers,
-Paul
Quoted 40 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
A driver wishing to export a struct
dev_pm_opswith both suspend and runtime ops provided could use_EXPORT_DEV_PM_OPS()directly but that macro is not intended for use in drivers and requires non intuitive aspect such as passing "_gpl" as one parameter and the namespace as a string. As such just provide a macro to cover the GPL and NS case in a fashion that is in line with similar macros.Signed-off-by Jonathan Cameron <[email protected]>Cc Paul Cercueil <[email protected]>Cc Rafael J. Wysocki <[email protected]>--- include/linux/pm.h | 5 +++++ 1 file changed, 5 insertions(+)include/linux/pm.h +1
-0@@ -407,6 +407,11 @@ static __maybe_unused _DEFINE_DEV_PM_OPS(__static_##name, suspend_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) +#define EXPORT_NS_GPL_DEV_PM_OPS(name, suspend_fn, resume_fn,
runtime_suspend_fn, \include/linux/pm.h +2
-0+ runtime_resume_fn, idle_fn, ns) \ + _EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn,\
include/linux/pm.h +2
-1+ runtime_resume_fn, idle_fn, "_gpl", #ns) +/* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */ #define SIMPLE_DEV_PM_OPS (name, suspend_fn, resume_fn) \ const struct dev_pm_ops __maybe_unused name = { \ --2.37.1
Jonathan Cameron
maintainerRe: [PATCH 1/5] PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own.
Quoted 5 lines · On Mon, 08 Aug 2022 13:22:37 +0200 Paul Cercueil <[email protected]> wrote:
Hi Jonathan,
If you can wait a day or two - I would like to submit my own version of
EXPORT_NS_GPL_DEV_PM_OPS, which should be more versatile than your version.
Thanks. Yours approach is indeed preferable, I'll respin this on top of your patch.
Its a bit enough change I'll probably not take any of the existing tags forwards to v2.
Jonathan
Quoted 49 lines
Cheers,
-PaulLe dim.,
ao_t7 2022 at 20:20:34 +0100, Jonathan Cameron <[email protected]> a_crit:Quoted 40 lines
From: Jonathan Cameron <[email protected]>
A driver wishing to export a struct
dev_pm_opswith both suspend and runtime ops provided could use_EXPORT_DEV_PM_OPS()directly but that macro is not intended for use in drivers and requires non intuitive aspect such as passing "_gpl" as one parameter and the namespace as a string. As such just provide a macro to cover the GPL and NS case in a fashion that is in line with similar macros.Signed-off-by Jonathan Cameron <[email protected]>Cc Paul Cercueil <[email protected]>Cc Rafael J. Wysocki <[email protected]>--- include/linux/pm.h | 5 +++++ 1 file changed, 5 insertions(+)include/linux/pm.h +1
-0@@ -407,6 +407,11 @@ static __maybe_unused _DEFINE_DEV_PM_OPS(__static_##name, suspend_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) +#define EXPORT_NS_GPL_DEV_PM_OPS(name, suspend_fn, resume_fn,
runtime_suspend_fn, \include/linux/pm.h +2
-0+ runtime_resume_fn, idle_fn, ns) \ + _EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn,\
include/linux/pm.h +2
-1+ runtime_resume_fn, idle_fn, "_gpl", #ns) +/* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */ #define SIMPLE_DEV_PM_OPS (name, suspend_fn, resume_fn) \ const struct dev_pm_ops __maybe_unused name = { \ --2.37.1
Jonathan Cameron
maintainerPATCH 2/5 iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS()
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/accel/fxls8962af-core.c | 17 +++++++---------- drivers/iio/accel/fxls8962af-i2c.c | 2 +- drivers/iio/accel/fxls8962af-spi.c | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-)
drivers/iio/accel/fxls8962af-core.c +7 -10
@@ -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,9 @@ 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_SYMBOL_NS_GPL (fxls8962af_pm_ops,IIO_FXLS8962AF ); +EXPORT_NS_GPL_DEV_PM_OPS (fxls8962af_pm_ops, fxls8962af_suspend, fxls8962af_resume, + fxls8962af_runtime_suspend, fxls8962af_runtime_resume,NULL , +IIO_FXLS8962AF );MODULE_AUTHOR ("Sean Nyekjaer <[email protected]>" );MODULE_DESCRIPTION ("NXP FXLS8962AF/FXLS8964AF accelerometer driver" );
drivers/iio/accel/fxls8962af-i2c.c +1 -1
@@ -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,
drivers/iio/accel/fxls8962af-spi.c +1 -1
@@ -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,
Signature · 1 line
2.37.1
Re: [PATCH 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS()
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Using this macro allows the compiler to remove unused structures and callbacks if we are not building with CONFIG_PM* without needing
__maybe_unusedmarkings.Signed-off-by Jonathan Cameron <[email protected]>Cc Sean Nyekjaer <[email protected]>
/Sean
Quoted 90 lines
--- drivers/iio/accel/fxls8962af-core.c | 17 +++++++---------- drivers/iio/accel/fxls8962af-i2c.c | 2 +- drivers/iio/accel/fxls8962af-spi.c | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-)drivers/iio/accel/fxls8962af-core.c +7
-10@@ -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,9 @@ 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_SYMBOL_NS_GPL (fxls8962af_pm_ops,IIO_FXLS8962AF ); +EXPORT_NS_GPL_DEV_PM_OPS (fxls8962af_pm_ops, fxls8962af_suspend, fxls8962af_resume, + fxls8962af_runtime_suspend, fxls8962af_runtime_resume,NULL , +IIO_FXLS8962AF );MODULE_AUTHOR ("Sean Nyekjaer <[email protected]>" );MODULE_DESCRIPTION ("NXP FXLS8962AF/FXLS8964AF accelerometer driver" );drivers/iio/accel/fxls8962af-i2c.c +1
-1@@ -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,drivers/iio/accel/fxls8962af-spi.c +1
-1@@ -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,Signature · 1 line
2.37.1
Jonathan Cameron
maintainerPATCH 3/5 iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/gyro/fxas21002c_core.c | 21 +++++++++------------ drivers/iio/gyro/fxas21002c_i2c.c | 3 ++- drivers/iio/gyro/fxas21002c_spi.c | 3 ++- 3 files changed, 13 insertions(+), 14 deletions(-)
drivers/iio/gyro/fxas21002c_core.c +9 -12
@@ -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,23 @@ 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_SYMBOL_GPL (fxas21002c_pm_ops); +EXPORT_NS_GPL_DEV_PM_OPS (fxas21002c_pm_ops, fxas21002c_suspend, + fxas21002c_resume, fxas21002c_runtime_suspend, + fxas21002c_runtime_resume,NULL ,IIO_FXAS21002C );MODULE_AUTHOR ("Rui Miguel Silva <[email protected]>" );MODULE_LICENSE ("GPL v2" );
drivers/iio/gyro/fxas21002c_i2c.c +2 -1
@@ -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 <[email protected]>" );MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("FXAS21002C I2C Gyro driver" ); +MODULE_IMPORT_NS (IIO_FXAS21002C );
drivers/iio/gyro/fxas21002c_spi.c +2 -1
@@ -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 <[email protected]>" );MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("FXAS21002C SPI Gyro driver" ); +MODULE_IMPORT_NS (IIO_FXAS21002C );
Signature · 1 line
2.37.1
Re: [PATCH 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace.
Hey Jonathan,
Quoted 8 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Includes using
EXPORT_NS_GPL_DEV_PM_OPS()and the simplifications that brings by allowing the compiler to remove unused structdev_pm_opsand callbacks without needing explicit__maybe_unusedmarkings.Signed-off-by Jonathan Cameron <[email protected]>Cc Rui Miguel Silva <[email protected]>
This looks a sane and good improvement, thanks.
Cheers,
Rui
Quoted 111 lines
--- drivers/iio/gyro/fxas21002c_core.c | 21 +++++++++------------ drivers/iio/gyro/fxas21002c_i2c.c | 3 ++- drivers/iio/gyro/fxas21002c_spi.c | 3 ++- 3 files changed, 13 insertions(+), 14 deletions(-)drivers/iio/gyro/fxas21002c_core.c +9
-12@@ -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,23 @@ 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_SYMBOL_GPL (fxas21002c_pm_ops); +EXPORT_NS_GPL_DEV_PM_OPS (fxas21002c_pm_ops, fxas21002c_suspend, + fxas21002c_resume, fxas21002c_runtime_suspend, + fxas21002c_runtime_resume,NULL ,IIO_FXAS21002C );MODULE_AUTHOR ("Rui Miguel Silva <[email protected]>" );MODULE_LICENSE ("GPL v2" );drivers/iio/gyro/fxas21002c_i2c.c +2
-1@@ -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 <[email protected]>" );MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("FXAS21002C I2C Gyro driver" ); +MODULE_IMPORT_NS (IIO_FXAS21002C );drivers/iio/gyro/fxas21002c_spi.c +2
-1@@ -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 <[email protected]>" );MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("FXAS21002C SPI Gyro driver" ); +MODULE_IMPORT_NS (IIO_FXAS21002C );Signature · 1 line
2.37.1
Jonathan Cameron
maintainerPATCH 4/5 iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- .../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, 13 insertions(+), 14 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c +9 -12
@@ -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,9 @@ 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_SYMBOL_GPL (inv_icm42600_pm_ops); +EXPORT_NS_GPL_DEV_PM_OPS (inv_icm42600_pm_ops, inv_icm42600_suspend, + inv_icm42600_resume, inv_icm42600_runtime_suspend, + inv_icm42600_runtime_resume,NULL ,IIO_ICM42600 );MODULE_AUTHOR ("InvenSense, Inc." );MODULE_DESCRIPTION ("InvenSense ICM-426xx device driver" );
drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c +2 -1
@@ -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 );
drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c +2 -1
@@ -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 );
Signature · 1 line
2.37.1
Jonathan Cameron
maintainerPATCH 5/5 iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
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.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 18 ++++++++---------- 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(+), 12 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +8 -10
@@ -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,9 @@ 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_SYMBOL_GPL (inv_mpu_pmops); +EXPORT_NS_GPL_DEV_PM_OPS (inv_mpu_pmops, inv_mpu_suspend, inv_mpu_resume, + inv_mpu_runtime_suspend, inv_mpu_runtime_resume,NULL , +IIO_MPU6050 );MODULE_AUTHOR ("Invensense Corporation" );MODULE_DESCRIPTION ("Invensense device MPU6050 driver" );
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c +2 -1
@@ -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 );
drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c +2 -1
@@ -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 <[email protected]>" );MODULE_DESCRIPTION ("Invensense device MPU6000 driver" );MODULE_LICENSE ("GPL" ); +MODULE_IMPORT_NS (IIO_MPU6050 );
Signature · 1 line
2.37.1
Re: [PATCH 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace
Quoted 5 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
As these exports are only relevant to core module and users in the bus specific modules, move them out of the main kernel namespace.
Quoted 7 lines
Includes using
EXPORT_NS_GPL_DEV_PM_OPS()and the simplifications that brings by allowing the compiler to remove unused structdev_pm_opsand callbacks without needing explicit__maybe_unusedmarkings.Signed-off-by Jonathan Cameron <[email protected]>Cc Jean-Baptiste Maneyrol <[email protected]>Cc Linus Walleij <[email protected]>
Looks good!
Yours,
Linus Walleij
Quoted 13 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Perhaps the most complex case we can have is a core driver module (usually with accompanying per bus modules) that exports, in a namespace, a struct
dev_pm_ops. The driver has different handling for runtime and sleep suspend / resume so (almost) all callbacks are provided. Thepm.hhelper macro_EXPORT_DEV_PM_OPS()could be used here but the handling of the last two parameters is unusual and very different from the macros intended for driver usage. First parameter needs to be "_gpl" and second needs to be the namespace specified as a string. Other NS macros take it without quotes.
Quoted 8 lines
As such, this series proposes introducing a suitable macro and then provides a number of IIO driver conversions. Where relevant the exports from the driver are moved into the new namespace.
If accepted we can either take the whole lot through the PM tree and hope there is nothing much else overlapping with this driver code in this cycle, or ideally we could use an immutable branch and pull this into both the IIO and PM trees.
Pretty straightforward and looks useful to me, thanks!
Quoted 25 lines
Jonathan Cameron (5):
PM: core: AddEXPORT_NS_GPL_DEV_PM_OPSto avoid drivers rolling own.
iio: accel: fxls8962af: Use newEXPORT_NS_GPL_DEV_PM_OPS()
iio: gyro: fxas210002c: Move exports toIIO_FXAS210002Cnamespace.
iio: imu:inv_icm42600: Move exports toIIO_ICM42600namespace
iio: imu:inv_mpu: Move exports toIIO_MPU6050namespacedrivers/iio/accel/fxls8962af-core.c | 17 +++++++-------- 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 | 18 +++++++--------- drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 3 ++- drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 3 ++- include/linux/pm.h | 5 +++++ 13 files changed, 52 insertions(+), 52 deletions(-)--
2.37.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 21 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Perhaps the most complex case we can have is a core driver module (usually with accompanying per bus modules) that exports, in a namespace, a struct
dev_pm_ops. The driver has different handling for runtime and sleep suspend / resume so (almost) all callbacks are provided. Thepm.hhelper macro_EXPORT_DEV_PM_OPS()could be used here but the handling of the last two parameters is unusual and very different from the macros intended for driver usage. First parameter needs to be "_gpl" and second needs to be the namespace specified as a string. Other NS macros take it without quotes.As such, this series proposes introducing a suitable macro and then provides a number of IIO driver conversions. Where relevant the exports from the driver are moved into the new namespace.
If accepted we can either take the whole lot through the PM tree and hope there is nothing much else overlapping with this driver code in this cycle, or ideally we could use an immutable branch and pull this into both the IIO and PM trees.
Quoted 6 lines
Jonathan Cameron (5):
PM: core: AddEXPORT_NS_GPL_DEV_PM_OPSto avoid drivers rolling own.
iio: accel: fxls8962af: Use newEXPORT_NS_GPL_DEV_PM_OPS()
iio: gyro: fxas210002c: Move exports toIIO_FXAS210002Cnamespace.
iio: imu:inv_icm42600: Move exports toIIO_ICM42600namespace
iio: imu:inv_mpu: Move exports toIIO_MPU6050namespace
I like what you done here.
Yours,
Linus Walleij
Jonathan Cameron
maintainerQuoted 30 lines · On Mon, 22 Aug 2022 11:04:18 +0200 Linus Walleij <[email protected]>…
Quoted 21 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Perhaps the most complex case we can have is a core driver module (usually with accompanying per bus modules) that exports, in a namespace, a struct
dev_pm_ops. The driver has different handling for runtime and sleep suspend / resume so (almost) all callbacks are provided. Thepm.hhelper macro_EXPORT_DEV_PM_OPS()could be used here but the handling of the last two parameters is unusual and very different from the macros intended for driver usage. First parameter needs to be "_gpl" and second needs to be the namespace specified as a string. Other NS macros take it without quotes.As such, this series proposes introducing a suitable macro and then provides a number of IIO driver conversions. Where relevant the exports from the driver are moved into the new namespace.
If accepted we can either take the whole lot through the PM tree and hope there is nothing much else overlapping with this driver code in this cycle, or ideally we could use an immutable branch and pull this into both the IIO and PM trees.
Quoted 6 lines
Jonathan Cameron (5):
PM: core: AddEXPORT_NS_GPL_DEV_PM_OPSto avoid drivers rolling own.
iio: accel: fxls8962af: Use newEXPORT_NS_GPL_DEV_PM_OPS()
iio: gyro: fxas210002c: Move exports toIIO_FXAS210002Cnamespace.
iio: imu:inv_icm42600: Move exports toIIO_ICM42600namespace
iio: imu:inv_mpu: Move exports toIIO_MPU6050namespace
Quoted 2 lines
I like what you done here.
Acked-by Linus Walleij <[email protected]>
Unfortunately change of plan because the EXPORT_NS_GPL_DEV_PM_OPS isn't general enough to cover some cases elsewhere.
https://lore.kernel.org/all/[email protected]/
I'll switch this series over to being based on that which will be a large enough change that I'll probably not pick up any tags given on this version.
Thanks
Jonathan
Quoted 3 lines
Yours,
Linus Walleij