diff mbox series

[v2,1/3] iio: chemical: scd30: Export dev_pm_ops instead of suspend() and resume()

Message ID 20220401140605.31871-2-Jonathan.Cameron@huawei.com
State Accepted
Commit 95d5a7214b86e64dc97db3d35f6d97533f89fb32
Headers show
Series IIO: Where dev_pm_ops rework and namespaces meet. | expand

Commit Message

Jonathan Cameron April 1, 2022, 2:06 p.m. UTC
Whilst here move to the new infrastructure using pm_sleep_ptr()
and EXPORT_DEV_PM_OPS() so as to let the compiler remove the unused
code if CONFIG_SLEEP is not defined.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Tomasz Duszynski <tomasz.duszynski@octakon.com>
---
 drivers/iio/chemical/scd30.h        | 5 +----
 drivers/iio/chemical/scd30_core.c   | 8 ++++----
 drivers/iio/chemical/scd30_i2c.c    | 2 +-
 drivers/iio/chemical/scd30_serial.c | 2 +-
 4 files changed, 7 insertions(+), 10 deletions(-)

Comments

Rafael J. Wysocki April 5, 2022, 6:19 p.m. UTC | #1
On Fri, Apr 1, 2022 at 4:06 PM Jonathan Cameron
<Jonathan.Cameron@huawei.com> wrote:
>
> Whilst here move to the new infrastructure using pm_sleep_ptr()
> and EXPORT_DEV_PM_OPS() so as to let the compiler remove the unused
> code if CONFIG_SLEEP is not defined.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Tomasz Duszynski <tomasz.duszynski@octakon.com>
> ---
>  drivers/iio/chemical/scd30.h        | 5 +----
>  drivers/iio/chemical/scd30_core.c   | 8 ++++----
>  drivers/iio/chemical/scd30_i2c.c    | 2 +-
>  drivers/iio/chemical/scd30_serial.c | 2 +-
>  4 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iio/chemical/scd30.h b/drivers/iio/chemical/scd30.h
> index f60127bfe0f4..1ac9f3f79271 100644
> --- a/drivers/iio/chemical/scd30.h
> +++ b/drivers/iio/chemical/scd30.h
> @@ -68,10 +68,7 @@ struct scd30_state {
>         scd30_command_t command;
>  };
>
> -int scd30_suspend(struct device *dev);
> -int scd30_resume(struct device *dev);
> -
> -static __maybe_unused SIMPLE_DEV_PM_OPS(scd30_pm_ops, scd30_suspend, scd30_resume);
> +extern const struct dev_pm_ops scd30_pm_ops;
>
>  int scd30_probe(struct device *dev, int irq, const char *name, void *priv, scd30_command_t command);
>
> diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c
> index 9fe6bbe9ee04..6c6c11c2772a 100644
> --- a/drivers/iio/chemical/scd30_core.c
> +++ b/drivers/iio/chemical/scd30_core.c
> @@ -517,7 +517,7 @@ static const struct iio_chan_spec scd30_channels[] = {
>         IIO_CHAN_SOFT_TIMESTAMP(3),
>  };
>
> -int __maybe_unused scd30_suspend(struct device *dev)
> +static int scd30_suspend(struct device *dev)
>  {
>         struct iio_dev *indio_dev = dev_get_drvdata(dev);
>         struct scd30_state *state  = iio_priv(indio_dev);
> @@ -529,9 +529,8 @@ int __maybe_unused scd30_suspend(struct device *dev)
>
>         return regulator_disable(state->vdd);
>  }
> -EXPORT_SYMBOL(scd30_suspend);
>
> -int __maybe_unused scd30_resume(struct device *dev)
> +static int scd30_resume(struct device *dev)
>  {
>         struct iio_dev *indio_dev = dev_get_drvdata(dev);
>         struct scd30_state *state = iio_priv(indio_dev);
> @@ -543,7 +542,8 @@ int __maybe_unused scd30_resume(struct device *dev)
>
>         return scd30_command_write(state, CMD_START_MEAS, state->pressure_comp);
>  }
> -EXPORT_SYMBOL(scd30_resume);
> +
> +EXPORT_SIMPLE_DEV_PM_OPS(scd30_pm_ops, scd30_suspend, scd30_resume);
>
>  static void scd30_stop_meas(void *data)
>  {
> diff --git a/drivers/iio/chemical/scd30_i2c.c b/drivers/iio/chemical/scd30_i2c.c
> index 875892a070ee..7c332e4e8e46 100644
> --- a/drivers/iio/chemical/scd30_i2c.c
> +++ b/drivers/iio/chemical/scd30_i2c.c
> @@ -128,7 +128,7 @@ static struct i2c_driver scd30_i2c_driver = {
>         .driver = {
>                 .name = KBUILD_MODNAME,
>                 .of_match_table = scd30_i2c_of_match,
> -               .pm = &scd30_pm_ops,
> +               .pm = pm_sleep_ptr(&scd30_pm_ops),
>         },
>         .probe_new = scd30_i2c_probe,
>  };
> diff --git a/drivers/iio/chemical/scd30_serial.c b/drivers/iio/chemical/scd30_serial.c
> index 568b34486c44..8664f3ce6b33 100644
> --- a/drivers/iio/chemical/scd30_serial.c
> +++ b/drivers/iio/chemical/scd30_serial.c
> @@ -252,7 +252,7 @@ static struct serdev_device_driver scd30_serdev_driver = {
>         .driver = {
>                 .name = KBUILD_MODNAME,
>                 .of_match_table = scd30_serdev_of_match,
> -               .pm = &scd30_pm_ops,
> +               .pm = pm_sleep_ptr(&scd30_pm_ops),
>         },
>         .probe = scd30_serdev_probe,
>  };
> --

Applied as 5.19 material along with the [2-3/3].

Please let me know if you need a non-mutable branch to pull from in
order to base other work on these commits.

Thanks!
Jonathan Cameron April 6, 2022, 1:09 p.m. UTC | #2
On Tue, 5 Apr 2022 20:19:11 +0200
"Rafael J. Wysocki" <rafael@kernel.org> wrote:

> On Fri, Apr 1, 2022 at 4:06 PM Jonathan Cameron
> <Jonathan.Cameron@huawei.com> wrote:
> >
> > Whilst here move to the new infrastructure using pm_sleep_ptr()
> > and EXPORT_DEV_PM_OPS() so as to let the compiler remove the unused
> > code if CONFIG_SLEEP is not defined.
> >
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Tomasz Duszynski <tomasz.duszynski@octakon.com>
> > ---
> >  drivers/iio/chemical/scd30.h        | 5 +----
> >  drivers/iio/chemical/scd30_core.c   | 8 ++++----
> >  drivers/iio/chemical/scd30_i2c.c    | 2 +-
> >  drivers/iio/chemical/scd30_serial.c | 2 +-
> >  4 files changed, 7 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/iio/chemical/scd30.h b/drivers/iio/chemical/scd30.h
> > index f60127bfe0f4..1ac9f3f79271 100644
> > --- a/drivers/iio/chemical/scd30.h
> > +++ b/drivers/iio/chemical/scd30.h
> > @@ -68,10 +68,7 @@ struct scd30_state {
> >         scd30_command_t command;
> >  };
> >
> > -int scd30_suspend(struct device *dev);
> > -int scd30_resume(struct device *dev);
> > -
> > -static __maybe_unused SIMPLE_DEV_PM_OPS(scd30_pm_ops, scd30_suspend, scd30_resume);
> > +extern const struct dev_pm_ops scd30_pm_ops;
> >
> >  int scd30_probe(struct device *dev, int irq, const char *name, void *priv, scd30_command_t command);
> >
> > diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c
> > index 9fe6bbe9ee04..6c6c11c2772a 100644
> > --- a/drivers/iio/chemical/scd30_core.c
> > +++ b/drivers/iio/chemical/scd30_core.c
> > @@ -517,7 +517,7 @@ static const struct iio_chan_spec scd30_channels[] = {
> >         IIO_CHAN_SOFT_TIMESTAMP(3),
> >  };
> >
> > -int __maybe_unused scd30_suspend(struct device *dev)
> > +static int scd30_suspend(struct device *dev)
> >  {
> >         struct iio_dev *indio_dev = dev_get_drvdata(dev);
> >         struct scd30_state *state  = iio_priv(indio_dev);
> > @@ -529,9 +529,8 @@ int __maybe_unused scd30_suspend(struct device *dev)
> >
> >         return regulator_disable(state->vdd);
> >  }
> > -EXPORT_SYMBOL(scd30_suspend);
> >
> > -int __maybe_unused scd30_resume(struct device *dev)
> > +static int scd30_resume(struct device *dev)
> >  {
> >         struct iio_dev *indio_dev = dev_get_drvdata(dev);
> >         struct scd30_state *state = iio_priv(indio_dev);
> > @@ -543,7 +542,8 @@ int __maybe_unused scd30_resume(struct device *dev)
> >
> >         return scd30_command_write(state, CMD_START_MEAS, state->pressure_comp);
> >  }
> > -EXPORT_SYMBOL(scd30_resume);
> > +
> > +EXPORT_SIMPLE_DEV_PM_OPS(scd30_pm_ops, scd30_suspend, scd30_resume);
> >
> >  static void scd30_stop_meas(void *data)
> >  {
> > diff --git a/drivers/iio/chemical/scd30_i2c.c b/drivers/iio/chemical/scd30_i2c.c
> > index 875892a070ee..7c332e4e8e46 100644
> > --- a/drivers/iio/chemical/scd30_i2c.c
> > +++ b/drivers/iio/chemical/scd30_i2c.c
> > @@ -128,7 +128,7 @@ static struct i2c_driver scd30_i2c_driver = {
> >         .driver = {
> >                 .name = KBUILD_MODNAME,
> >                 .of_match_table = scd30_i2c_of_match,
> > -               .pm = &scd30_pm_ops,
> > +               .pm = pm_sleep_ptr(&scd30_pm_ops),
> >         },
> >         .probe_new = scd30_i2c_probe,
> >  };
> > diff --git a/drivers/iio/chemical/scd30_serial.c b/drivers/iio/chemical/scd30_serial.c
> > index 568b34486c44..8664f3ce6b33 100644
> > --- a/drivers/iio/chemical/scd30_serial.c
> > +++ b/drivers/iio/chemical/scd30_serial.c
> > @@ -252,7 +252,7 @@ static struct serdev_device_driver scd30_serdev_driver = {
> >         .driver = {
> >                 .name = KBUILD_MODNAME,
> >                 .of_match_table = scd30_serdev_of_match,
> > -               .pm = &scd30_pm_ops,
> > +               .pm = pm_sleep_ptr(&scd30_pm_ops),
> >         },
> >         .probe = scd30_serdev_probe,
> >  };
> > --  
> 
> Applied as 5.19 material along with the [2-3/3].
> 
> Please let me know if you need a non-mutable branch to pull from in
> order to base other work on these commits.

Yes please.  A non-mutable branch would be great.

Thanks,

Jonathan

> 
> Thanks!
diff mbox series

Patch

diff --git a/drivers/iio/chemical/scd30.h b/drivers/iio/chemical/scd30.h
index f60127bfe0f4..1ac9f3f79271 100644
--- a/drivers/iio/chemical/scd30.h
+++ b/drivers/iio/chemical/scd30.h
@@ -68,10 +68,7 @@  struct scd30_state {
 	scd30_command_t command;
 };
 
-int scd30_suspend(struct device *dev);
-int scd30_resume(struct device *dev);
-
-static __maybe_unused SIMPLE_DEV_PM_OPS(scd30_pm_ops, scd30_suspend, scd30_resume);
+extern const struct dev_pm_ops scd30_pm_ops;
 
 int scd30_probe(struct device *dev, int irq, const char *name, void *priv, scd30_command_t command);
 
diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c
index 9fe6bbe9ee04..6c6c11c2772a 100644
--- a/drivers/iio/chemical/scd30_core.c
+++ b/drivers/iio/chemical/scd30_core.c
@@ -517,7 +517,7 @@  static const struct iio_chan_spec scd30_channels[] = {
 	IIO_CHAN_SOFT_TIMESTAMP(3),
 };
 
-int __maybe_unused scd30_suspend(struct device *dev)
+static int scd30_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct scd30_state *state  = iio_priv(indio_dev);
@@ -529,9 +529,8 @@  int __maybe_unused scd30_suspend(struct device *dev)
 
 	return regulator_disable(state->vdd);
 }
-EXPORT_SYMBOL(scd30_suspend);
 
-int __maybe_unused scd30_resume(struct device *dev)
+static int scd30_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct scd30_state *state = iio_priv(indio_dev);
@@ -543,7 +542,8 @@  int __maybe_unused scd30_resume(struct device *dev)
 
 	return scd30_command_write(state, CMD_START_MEAS, state->pressure_comp);
 }
-EXPORT_SYMBOL(scd30_resume);
+
+EXPORT_SIMPLE_DEV_PM_OPS(scd30_pm_ops, scd30_suspend, scd30_resume);
 
 static void scd30_stop_meas(void *data)
 {
diff --git a/drivers/iio/chemical/scd30_i2c.c b/drivers/iio/chemical/scd30_i2c.c
index 875892a070ee..7c332e4e8e46 100644
--- a/drivers/iio/chemical/scd30_i2c.c
+++ b/drivers/iio/chemical/scd30_i2c.c
@@ -128,7 +128,7 @@  static struct i2c_driver scd30_i2c_driver = {
 	.driver = {
 		.name = KBUILD_MODNAME,
 		.of_match_table = scd30_i2c_of_match,
-		.pm = &scd30_pm_ops,
+		.pm = pm_sleep_ptr(&scd30_pm_ops),
 	},
 	.probe_new = scd30_i2c_probe,
 };
diff --git a/drivers/iio/chemical/scd30_serial.c b/drivers/iio/chemical/scd30_serial.c
index 568b34486c44..8664f3ce6b33 100644
--- a/drivers/iio/chemical/scd30_serial.c
+++ b/drivers/iio/chemical/scd30_serial.c
@@ -252,7 +252,7 @@  static struct serdev_device_driver scd30_serdev_driver = {
 	.driver = {
 		.name = KBUILD_MODNAME,
 		.of_match_table = scd30_serdev_of_match,
-		.pm = &scd30_pm_ops,
+		.pm = pm_sleep_ptr(&scd30_pm_ops),
 	},
 	.probe = scd30_serdev_probe,
 };