diff mbox series

[49/49] iio:chemical:atlas: Switch from CONFIG_PM guards to pm_ptr() / __maybe_unused

Message ID 20211123211019.2271440-50-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 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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
---
 drivers/iio/chemical/atlas-sensor.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Matt Ranostay Nov. 23, 2021, 10:22 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 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.
>

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


> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Matt Ranostay <matt.ranostay@konsulko.com>
> ---
>  drivers/iio/chemical/atlas-sensor.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
> index 04b44a327614..7bacd0bd6f19 100644
> --- a/drivers/iio/chemical/atlas-sensor.c
> +++ b/drivers/iio/chemical/atlas-sensor.c
> @@ -737,8 +737,7 @@ static int atlas_remove(struct i2c_client *client)
>         return atlas_set_powermode(data, 0);
>  }
>
> -#ifdef CONFIG_PM
> -static int atlas_runtime_suspend(struct device *dev)
> +static __maybe_unused int atlas_runtime_suspend(struct device *dev)
>  {
>         struct atlas_data *data =
>                      iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
> @@ -746,16 +745,15 @@ static int atlas_runtime_suspend(struct device *dev)
>         return atlas_set_powermode(data, 0);
>  }
>
> -static int atlas_runtime_resume(struct device *dev)
> +static __maybe_unused int atlas_runtime_resume(struct device *dev)
>  {
>         struct atlas_data *data =
>                      iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
>
>         return atlas_set_powermode(data, 1);
>  }
> -#endif
>
> -static const struct dev_pm_ops atlas_pm_ops = {
> +static __maybe_unused const struct dev_pm_ops atlas_pm_ops = {
>         SET_RUNTIME_PM_OPS(atlas_runtime_suspend,
>                            atlas_runtime_resume, NULL)
>  };
> @@ -764,7 +762,7 @@ static struct i2c_driver atlas_driver = {
>         .driver = {
>                 .name   = ATLAS_DRV_NAME,
>                 .of_match_table = atlas_dt_ids,
> -               .pm     = &atlas_pm_ops,
> +               .pm     = pm_ptr(&atlas_pm_ops),
>         },
>         .probe          = atlas_probe,
>         .remove         = atlas_remove,
> --
> 2.34.0
>
diff mbox series

Patch

diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
index 04b44a327614..7bacd0bd6f19 100644
--- a/drivers/iio/chemical/atlas-sensor.c
+++ b/drivers/iio/chemical/atlas-sensor.c
@@ -737,8 +737,7 @@  static int atlas_remove(struct i2c_client *client)
 	return atlas_set_powermode(data, 0);
 }
 
-#ifdef CONFIG_PM
-static int atlas_runtime_suspend(struct device *dev)
+static __maybe_unused int atlas_runtime_suspend(struct device *dev)
 {
 	struct atlas_data *data =
 		     iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
@@ -746,16 +745,15 @@  static int atlas_runtime_suspend(struct device *dev)
 	return atlas_set_powermode(data, 0);
 }
 
-static int atlas_runtime_resume(struct device *dev)
+static __maybe_unused int atlas_runtime_resume(struct device *dev)
 {
 	struct atlas_data *data =
 		     iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
 
 	return atlas_set_powermode(data, 1);
 }
-#endif
 
-static const struct dev_pm_ops atlas_pm_ops = {
+static __maybe_unused const struct dev_pm_ops atlas_pm_ops = {
 	SET_RUNTIME_PM_OPS(atlas_runtime_suspend,
 			   atlas_runtime_resume, NULL)
 };
@@ -764,7 +762,7 @@  static struct i2c_driver atlas_driver = {
 	.driver = {
 		.name	= ATLAS_DRV_NAME,
 		.of_match_table	= atlas_dt_ids,
-		.pm	= &atlas_pm_ops,
+		.pm	= pm_ptr(&atlas_pm_ops),
 	},
 	.probe		= atlas_probe,
 	.remove		= atlas_remove,