diff mbox series

[42/49] iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to pm_ptr() / __maybe_unused

Message ID 20211123211019.2271440-43-jic23@kernel.org (mailing list archive)
State Superseded
Headers show
Series iio: Tree wide switch from CONFIG_PM* to __maybe_unused etc. | expand

Commit Message

Jonathan Cameron Nov. 23, 2021, 9:10 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Letting the compiler remove these functions when the kernel is built
without CONFIG_PM_SLEEP support is simpler and less error prone than the
use of #ifdef based config guards.

Removing instances of this approach from IIO also stops them being
copied into new drivers.

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

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

Comments

Matt Ranostay Nov. 23, 2021, 10:23 p.m. UTC | #1
On Tue, Nov 23, 2021 at 1:07 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Letting the compiler remove these functions when the kernel is built
> without CONFIG_PM_SLEEP support is simpler and less error prone than the
> use of #ifdef based config guards.
>
> Removing instances of this approach from IIO also stops them being
> copied into new drivers.
>
> The pm_ptr() macro only removes the reference if CONFIG_PM is not
> set. It is possible for CONFIG_PM=y without CONFIG_SLEEP, so this
> will not always remove the pm_ops structure.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Matt Ranostay <matt.ranostay@konsulko.com>

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

> ---
>  drivers/iio/proximity/as3935.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
> index d62766b6b39e..605c6095d704 100644
> --- a/drivers/iio/proximity/as3935.c
> +++ b/drivers/iio/proximity/as3935.c
> @@ -295,8 +295,7 @@ static void calibrate_as3935(struct as3935_state *st)
>         as3935_write(st, AS3935_NFLWDTH, st->nflwdth_reg);
>  }
>
> -#ifdef CONFIG_PM_SLEEP
> -static int as3935_suspend(struct device *dev)
> +static __maybe_unused int as3935_suspend(struct device *dev)
>  {
>         struct iio_dev *indio_dev = dev_get_drvdata(dev);
>         struct as3935_state *st = iio_priv(indio_dev);
> @@ -316,7 +315,7 @@ static int as3935_suspend(struct device *dev)
>         return ret;
>  }
>
> -static int as3935_resume(struct device *dev)
> +static __maybe_unused int as3935_resume(struct device *dev)
>  {
>         struct iio_dev *indio_dev = dev_get_drvdata(dev);
>         struct as3935_state *st = iio_priv(indio_dev);
> @@ -338,11 +337,6 @@ static int as3935_resume(struct device *dev)
>  }
>
>  static SIMPLE_DEV_PM_OPS(as3935_pm_ops, as3935_suspend, as3935_resume);
> -#define AS3935_PM_OPS (&as3935_pm_ops)
> -
> -#else
> -#define AS3935_PM_OPS NULL
> -#endif
>
>  static void as3935_stop_work(void *data)
>  {
> @@ -472,7 +466,7 @@ static struct spi_driver as3935_driver = {
>         .driver = {
>                 .name   = "as3935",
>                 .of_match_table = as3935_of_match,
> -               .pm     = AS3935_PM_OPS,
> +               .pm     = pm_ptr(&as3935_pm_ops),
>         },
>         .probe          = as3935_probe,
>         .id_table       = as3935_id,
> --
> 2.34.0
>
diff mbox series

Patch

diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
index d62766b6b39e..605c6095d704 100644
--- a/drivers/iio/proximity/as3935.c
+++ b/drivers/iio/proximity/as3935.c
@@ -295,8 +295,7 @@  static void calibrate_as3935(struct as3935_state *st)
 	as3935_write(st, AS3935_NFLWDTH, st->nflwdth_reg);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int as3935_suspend(struct device *dev)
+static __maybe_unused int as3935_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct as3935_state *st = iio_priv(indio_dev);
@@ -316,7 +315,7 @@  static int as3935_suspend(struct device *dev)
 	return ret;
 }
 
-static int as3935_resume(struct device *dev)
+static __maybe_unused int as3935_resume(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct as3935_state *st = iio_priv(indio_dev);
@@ -338,11 +337,6 @@  static int as3935_resume(struct device *dev)
 }
 
 static SIMPLE_DEV_PM_OPS(as3935_pm_ops, as3935_suspend, as3935_resume);
-#define AS3935_PM_OPS (&as3935_pm_ops)
-
-#else
-#define AS3935_PM_OPS NULL
-#endif
 
 static void as3935_stop_work(void *data)
 {
@@ -472,7 +466,7 @@  static struct spi_driver as3935_driver = {
 	.driver = {
 		.name	= "as3935",
 		.of_match_table = as3935_of_match,
-		.pm	= AS3935_PM_OPS,
+		.pm	= pm_ptr(&as3935_pm_ops),
 	},
 	.probe		= as3935_probe,
 	.id_table	= as3935_id,