diff mbox series

[v2,34/51] iio:light:us5182: Switch from CONFIG_PM guards to pm_ptr() etc

Message ID 20220102125617.1259804-35-jic23@kernel.org (mailing list archive)
State Changes Requested
Headers show
Series iio: Tree wide switch from CONFIG_PM* to pm_[sleep]_ptr etc. | expand

Commit Message

Jonathan Cameron Jan. 2, 2022, 12:56 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>
---
 drivers/iio/light/us5182d.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Jonathan Cameron Jan. 30, 2022, 7:12 p.m. UTC | #1
On Sun,  2 Jan 2022 12:56:00 +0000
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.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Dropping this (for now) from v3 as need to take a closer look at
what we should be doing for the interaction of sleep and runtime
pm ops.  Probably wants to use the force runtime macros but needs
more care than I'm going to give it today!

Jonathan

> ---
>  drivers/iio/light/us5182d.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c
> index 96e4a66ddf28..fdabf601d15e 100644
> --- a/drivers/iio/light/us5182d.c
> +++ b/drivers/iio/light/us5182d.c
> @@ -916,7 +916,6 @@ static int us5182d_remove(struct i2c_client *client)
>  	return us5182d_shutdown_en(data, US5182D_CFG0_SHUTDOWN_EN);
>  }
>  
> -#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM)
>  static int us5182d_suspend(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> @@ -939,11 +938,10 @@ static int us5182d_resume(struct device *dev)
>  
>  	return 0;
>  }
> -#endif
>  
>  static const struct dev_pm_ops us5182d_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(us5182d_suspend, us5182d_resume)
> -	SET_RUNTIME_PM_OPS(us5182d_suspend, us5182d_resume, NULL)
> +	SYSTEM_SLEEP_PM_OPS(us5182d_suspend, us5182d_resume)
> +	RUNTIME_PM_OPS(us5182d_suspend, us5182d_resume, NULL)
>  };
>  
>  static const struct acpi_device_id us5182d_acpi_match[] = {
> @@ -969,7 +967,7 @@ MODULE_DEVICE_TABLE(of, us5182d_of_match);
>  static struct i2c_driver us5182d_driver = {
>  	.driver = {
>  		.name = US5182D_DRV_NAME,
> -		.pm = &us5182d_pm_ops,
> +		.pm = pm_ptr(&us5182d_pm_ops),
>  		.of_match_table = us5182d_of_match,
>  		.acpi_match_table = ACPI_PTR(us5182d_acpi_match),
>  	},
diff mbox series

Patch

diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c
index 96e4a66ddf28..fdabf601d15e 100644
--- a/drivers/iio/light/us5182d.c
+++ b/drivers/iio/light/us5182d.c
@@ -916,7 +916,6 @@  static int us5182d_remove(struct i2c_client *client)
 	return us5182d_shutdown_en(data, US5182D_CFG0_SHUTDOWN_EN);
 }
 
-#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM)
 static int us5182d_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -939,11 +938,10 @@  static int us5182d_resume(struct device *dev)
 
 	return 0;
 }
-#endif
 
 static const struct dev_pm_ops us5182d_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(us5182d_suspend, us5182d_resume)
-	SET_RUNTIME_PM_OPS(us5182d_suspend, us5182d_resume, NULL)
+	SYSTEM_SLEEP_PM_OPS(us5182d_suspend, us5182d_resume)
+	RUNTIME_PM_OPS(us5182d_suspend, us5182d_resume, NULL)
 };
 
 static const struct acpi_device_id us5182d_acpi_match[] = {
@@ -969,7 +967,7 @@  MODULE_DEVICE_TABLE(of, us5182d_of_match);
 static struct i2c_driver us5182d_driver = {
 	.driver = {
 		.name = US5182D_DRV_NAME,
-		.pm = &us5182d_pm_ops,
+		.pm = pm_ptr(&us5182d_pm_ops),
 		.of_match_table = us5182d_of_match,
 		.acpi_match_table = ACPI_PTR(us5182d_acpi_match),
 	},