* [PATCH 1/5] PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own.
2022-08-07 19:20 [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO Jonathan Cameron
@ 2022-08-07 19:20 ` Jonathan Cameron
2022-08-08 11:22 ` Paul Cercueil
2022-08-07 19:20 ` [PATCH 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Jonathan Cameron @ 2022-08-07 19:20 UTC (permalink / raw)
To: linux-iio, Rafael J . Wysocki, linux-pm
Cc: Paul Cercueil, Sean Nyekjaer, Rui Miguel Silva,
Jean-Baptiste Maneyrol, Linus Walleij, Jonathan Cameron,
Rafael J . Wysocki
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
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.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
include/linux/pm.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 871c9c49ec9d..18856e0d23ac 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -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 = { \
--
2.37.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/5] PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own.
2022-08-07 19:20 ` [PATCH 1/5] PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own Jonathan Cameron
@ 2022-08-08 11:22 ` Paul Cercueil
2022-08-13 16:14 ` Jonathan Cameron
0 siblings, 1 reply; 14+ messages in thread
From: Paul Cercueil @ 2022-08-08 11:22 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Rafael J . Wysocki, linux-pm, Sean Nyekjaer,
Rui Miguel Silva, Jean-Baptiste Maneyrol, Linus Walleij,
Jonathan Cameron, Rafael J . Wysocki
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
Le dim., août 7 2022 at 20:20:34 +0100, Jonathan Cameron
<jic23@kernel.org> a écrit :
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> 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.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Paul Cercueil <paul@crapouillou.net>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> include/linux/pm.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/include/linux/pm.h b/include/linux/pm.h
> index 871c9c49ec9d..18856e0d23ac 100644
> --- a/include/linux/pm.h
> +++ b/include/linux/pm.h
> @@ -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 = { \
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/5] PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own.
2022-08-08 11:22 ` Paul Cercueil
@ 2022-08-13 16:14 ` Jonathan Cameron
0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2022-08-13 16:14 UTC (permalink / raw)
To: Paul Cercueil
Cc: linux-iio, Rafael J . Wysocki, linux-pm, Sean Nyekjaer,
Rui Miguel Silva, Jean-Baptiste Maneyrol, Linus Walleij,
Jonathan Cameron, Rafael J . Wysocki
On Mon, 08 Aug 2022 13:22:37 +0200
Paul Cercueil <paul@crapouillou.net> 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
>
> Cheers,
> -Paul
>
>
> Le dim., ao_t 7 2022 at 20:20:34 +0100, Jonathan Cameron
> <jic23@kernel.org> a _crit :
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > 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.
> >
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Paul Cercueil <paul@crapouillou.net>
> > Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> > include/linux/pm.h | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/include/linux/pm.h b/include/linux/pm.h
> > index 871c9c49ec9d..18856e0d23ac 100644
> > --- a/include/linux/pm.h
> > +++ b/include/linux/pm.h
> > @@ -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 = { \
> > --
> > 2.37.1
> >
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS()
2022-08-07 19:20 [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO Jonathan Cameron
2022-08-07 19:20 ` [PATCH 1/5] PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own Jonathan Cameron
@ 2022-08-07 19:20 ` Jonathan Cameron
2022-08-08 11:37 ` Sean Nyekjaer
2022-08-07 19:20 ` [PATCH 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace Jonathan Cameron
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Jonathan Cameron @ 2022-08-07 19:20 UTC (permalink / raw)
To: linux-iio, Rafael J . Wysocki, linux-pm
Cc: Paul Cercueil, Sean Nyekjaer, Rui Miguel Silva,
Jean-Baptiste Maneyrol, Linus Walleij, 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>
---
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(-)
diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
index 8874d6d61725..6c7dde4a1af9 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,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 <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.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS()
2022-08-07 19:20 ` [PATCH 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
@ 2022-08-08 11:37 ` Sean Nyekjaer
0 siblings, 0 replies; 14+ messages in thread
From: Sean Nyekjaer @ 2022-08-08 11:37 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Rafael J . Wysocki, linux-pm, Paul Cercueil,
Rui Miguel Silva, Jean-Baptiste Maneyrol, Linus Walleij,
Jonathan Cameron
On Sun, Aug 07, 2022 at 08:20:35PM +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>
/Sean
> ---
> 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(-)
>
> diff --git a/drivers/iio/accel/fxls8962af-core.c b/drivers/iio/accel/fxls8962af-core.c
> index 8874d6d61725..6c7dde4a1af9 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,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 <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.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace.
2022-08-07 19:20 [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO Jonathan Cameron
2022-08-07 19:20 ` [PATCH 1/5] PM: core: Add EXPORT_NS_GPL_DEV_PM_OPS to avoid drivers rolling own Jonathan Cameron
2022-08-07 19:20 ` [PATCH 2/5] iio: accel: fxls8962af: Use new EXPORT_NS_GPL_DEV_PM_OPS() Jonathan Cameron
@ 2022-08-07 19:20 ` Jonathan Cameron
2022-08-08 11:00 ` Rui Miguel Silva
2022-08-07 19:20 ` [PATCH 4/5] iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace Jonathan Cameron
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Jonathan Cameron @ 2022-08-07 19:20 UTC (permalink / raw)
To: linux-iio, Rafael J . Wysocki, linux-pm
Cc: Paul Cercueil, Sean Nyekjaer, Rui Miguel Silva,
Jean-Baptiste Maneyrol, Linus Walleij, 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>
---
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(-)
diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c
index a36d71d9e3ea..9aee9096363f 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,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 <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.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace.
2022-08-07 19:20 ` [PATCH 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace Jonathan Cameron
@ 2022-08-08 11:00 ` Rui Miguel Silva
0 siblings, 0 replies; 14+ messages in thread
From: Rui Miguel Silva @ 2022-08-08 11:00 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Rafael J . Wysocki, linux-pm, Paul Cercueil,
Sean Nyekjaer, Jean-Baptiste Maneyrol, Linus Walleij,
Jonathan Cameron
Hey Jonathan,
On Sun, Aug 07, 2022 at 08:20:36PM +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>
This looks a sane and good improvement, thanks.
Acked-by: Rui Miguel Silva <rui.silva@linaro.org>
Cheers,
Rui
> ---
> 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(-)
>
> diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c
> index a36d71d9e3ea..9aee9096363f 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,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 <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.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/5] iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace
2022-08-07 19:20 [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO Jonathan Cameron
` (2 preceding siblings ...)
2022-08-07 19:20 ` [PATCH 3/5] iio: gyro: fxas210002c: Move exports to IIO_FXAS210002C namespace Jonathan Cameron
@ 2022-08-07 19:20 ` Jonathan Cameron
2022-08-07 19:20 ` [PATCH 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace Jonathan Cameron
` (2 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2022-08-07 19:20 UTC (permalink / raw)
To: linux-iio, Rafael J . Wysocki, linux-pm
Cc: Paul Cercueil, Sean Nyekjaer, Rui Miguel Silva,
Jean-Baptiste Maneyrol, Linus Walleij, 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>
---
.../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(-)
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
index ca85fccc9839..2dce708e6272 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,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");
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.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace
2022-08-07 19:20 [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO Jonathan Cameron
` (3 preceding siblings ...)
2022-08-07 19:20 ` [PATCH 4/5] iio: imu: inv_icm42600: Move exports to IIO_ICM42600 namespace Jonathan Cameron
@ 2022-08-07 19:20 ` Jonathan Cameron
2022-08-22 8:59 ` Linus Walleij
2022-08-08 9:36 ` [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO Andy Shevchenko
2022-08-22 9:04 ` Linus Walleij
6 siblings, 1 reply; 14+ messages in thread
From: Jonathan Cameron @ 2022-08-07 19:20 UTC (permalink / raw)
To: linux-iio, Rafael J . Wysocki, linux-pm
Cc: Paul Cercueil, Sean Nyekjaer, Rui Miguel Silva,
Jean-Baptiste Maneyrol, Linus Walleij, 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>
---
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(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 86fbbe904050..27cbc07d6369 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,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");
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.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace
2022-08-07 19:20 ` [PATCH 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace Jonathan Cameron
@ 2022-08-22 8:59 ` Linus Walleij
0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2022-08-22 8:59 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Rafael J . Wysocki, linux-pm, Paul Cercueil,
Sean Nyekjaer, Rui Miguel Silva, Jean-Baptiste Maneyrol,
Jonathan Cameron
On Sun, Aug 7, 2022 at 9:10 PM Jonathan Cameron <jic23@kernel.org> wrote:
> 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>
Looks good!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO.
2022-08-07 19:20 [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO Jonathan Cameron
` (4 preceding siblings ...)
2022-08-07 19:20 ` [PATCH 5/5] iio: imu: inv_mpu: Move exports to IIO_MPU6050 namespace Jonathan Cameron
@ 2022-08-08 9:36 ` Andy Shevchenko
2022-08-22 9:04 ` Linus Walleij
6 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2022-08-08 9:36 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Rafael J . Wysocki, Linux PM, Paul Cercueil,
Sean Nyekjaer, Rui Miguel Silva, Jean-Baptiste Maneyrol,
Linus Walleij, Jonathan Cameron
On Sun, Aug 7, 2022 at 9:13 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> 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.
Pretty straightforward and looks useful to me, thanks!
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> 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(-)
>
> --
> 2.37.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO.
2022-08-07 19:20 [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO Jonathan Cameron
` (5 preceding siblings ...)
2022-08-08 9:36 ` [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO Andy Shevchenko
@ 2022-08-22 9:04 ` Linus Walleij
2022-08-22 18:59 ` Jonathan Cameron
6 siblings, 1 reply; 14+ messages in thread
From: Linus Walleij @ 2022-08-22 9:04 UTC (permalink / raw)
To: Jonathan Cameron
Cc: linux-iio, Rafael J . Wysocki, linux-pm, Paul Cercueil,
Sean Nyekjaer, Rui Miguel Silva, Jean-Baptiste Maneyrol,
Jonathan Cameron
On Sun, Aug 7, 2022 at 9:10 PM Jonathan Cameron <jic23@kernel.org> wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> 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
I like what you done here.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/5] PM: Introduce EXPORT_NS_GPL_DEV_PM_OPS() and use cases in IIO.
2022-08-22 9:04 ` Linus Walleij
@ 2022-08-22 18:59 ` Jonathan Cameron
0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2022-08-22 18:59 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-iio, Rafael J . Wysocki, linux-pm, Paul Cercueil,
Sean Nyekjaer, Rui Miguel Silva, Jean-Baptiste Maneyrol,
Jonathan Cameron
On Mon, 22 Aug 2022 11:04:18 +0200
Linus Walleij <linus.walleij@linaro.org> wrote:
> On Sun, Aug 7, 2022 at 9:10 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > 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
>
> I like what you done here.
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
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/20220808174107.38676-2-paul@crapouillou.net/
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
>
> Yours,
> Linus Walleij
^ permalink raw reply [flat|nested] 14+ messages in thread