diff mbox series

[34/36] iio: light: veml6030: Use DEFINE_RUNTIME_DEV_PM_OPS() and pm_ptr() macros

Message ID 20220621202719.13644-35-jic23@kernel.org (mailing list archive)
State Accepted
Headers show
Series IIO: switch easy cases to new simpler PM related macros. | expand

Commit Message

Jonathan Cameron June 21, 2022, 8:27 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Using these new macros allows the compiler to remove the unused dev_pm_ops
structure and related functions if !CONFIG_PM without the need to mark
the functions __maybe_unused.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Rishi Gupta <gupt21@gmail.com>
---
 drivers/iio/light/veml6030.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Rishi Gupta June 26, 2022, 6 p.m. UTC | #1
On Tue, Jun 21, 2022 at 1:22 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Using these new macros allows the compiler to remove the unused dev_pm_ops
> structure and related functions if !CONFIG_PM without the need to mark
> the functions __maybe_unused.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Rishi Gupta <gupt21@gmail.com>
> ---
>  drivers/iio/light/veml6030.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c
> index 3c937c55a10d..9a7800cdfee2 100644
> --- a/drivers/iio/light/veml6030.c
> +++ b/drivers/iio/light/veml6030.c
> @@ -846,7 +846,7 @@ static int veml6030_probe(struct i2c_client *client,
>         return devm_iio_device_register(&client->dev, indio_dev);
>  }
>
> -static int __maybe_unused veml6030_runtime_suspend(struct device *dev)
> +static int veml6030_runtime_suspend(struct device *dev)
>  {
>         int ret;
>         struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> @@ -859,7 +859,7 @@ static int __maybe_unused veml6030_runtime_suspend(struct device *dev)
>         return ret;
>  }
>
> -static int __maybe_unused veml6030_runtime_resume(struct device *dev)
> +static int veml6030_runtime_resume(struct device *dev)
>  {
>         int ret;
>         struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> @@ -872,12 +872,8 @@ static int __maybe_unused veml6030_runtime_resume(struct device *dev)
>         return ret;
>  }
>
> -static const struct dev_pm_ops veml6030_pm_ops = {
> -       SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
> -                               pm_runtime_force_resume)
> -       SET_RUNTIME_PM_OPS(veml6030_runtime_suspend,
> -                               veml6030_runtime_resume, NULL)
> -};
> +static DEFINE_RUNTIME_DEV_PM_OPS(veml6030_pm_ops, veml6030_runtime_suspend,
> +                                veml6030_runtime_resume, NULL);
>
>  static const struct of_device_id veml6030_of_match[] = {
>         { .compatible = "vishay,veml6030" },
> @@ -895,7 +891,7 @@ static struct i2c_driver veml6030_driver = {
>         .driver = {
>                 .name = "veml6030",
>                 .of_match_table = veml6030_of_match,
> -               .pm = &veml6030_pm_ops,
> +               .pm = pm_ptr(&veml6030_pm_ops),
>         },
>         .probe = veml6030_probe,
>         .id_table = veml6030_id,
> --
> 2.36.1
>
Reviewed-by: Rishi Gupta <gupt21@gmail.com>
diff mbox series

Patch

diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c
index 3c937c55a10d..9a7800cdfee2 100644
--- a/drivers/iio/light/veml6030.c
+++ b/drivers/iio/light/veml6030.c
@@ -846,7 +846,7 @@  static int veml6030_probe(struct i2c_client *client,
 	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
-static int __maybe_unused veml6030_runtime_suspend(struct device *dev)
+static int veml6030_runtime_suspend(struct device *dev)
 {
 	int ret;
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -859,7 +859,7 @@  static int __maybe_unused veml6030_runtime_suspend(struct device *dev)
 	return ret;
 }
 
-static int __maybe_unused veml6030_runtime_resume(struct device *dev)
+static int veml6030_runtime_resume(struct device *dev)
 {
 	int ret;
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -872,12 +872,8 @@  static int __maybe_unused veml6030_runtime_resume(struct device *dev)
 	return ret;
 }
 
-static const struct dev_pm_ops veml6030_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-				pm_runtime_force_resume)
-	SET_RUNTIME_PM_OPS(veml6030_runtime_suspend,
-				veml6030_runtime_resume, NULL)
-};
+static DEFINE_RUNTIME_DEV_PM_OPS(veml6030_pm_ops, veml6030_runtime_suspend,
+				 veml6030_runtime_resume, NULL);
 
 static const struct of_device_id veml6030_of_match[] = {
 	{ .compatible = "vishay,veml6030" },
@@ -895,7 +891,7 @@  static struct i2c_driver veml6030_driver = {
 	.driver = {
 		.name = "veml6030",
 		.of_match_table = veml6030_of_match,
-		.pm = &veml6030_pm_ops,
+		.pm = pm_ptr(&veml6030_pm_ops),
 	},
 	.probe = veml6030_probe,
 	.id_table = veml6030_id,