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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 23, 2021 at 1:07 PM Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>
> Cc: Matt Ranostay <matt.ranostay@xxxxxxxxxxxx>

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

> ---
>  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
>



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux