diff mbox series

[v2,42/51] iio:proximity:sx9500: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc

Message ID 20220102125617.1259804-43-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_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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/proximity/sx9500.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Gwendal Grignou Jan. 3, 2022, 6:58 p.m. UTC | #1
On Sun, Jan 2, 2022 at 4:52 AM 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.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
>  drivers/iio/proximity/sx9500.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index 3e4ddb2e8c2b..01bfd748d820 100644
> --- a/drivers/iio/proximity/sx9500.c
> +++ b/drivers/iio/proximity/sx9500.c
> @@ -993,7 +993,6 @@ static int sx9500_remove(struct i2c_client *client)
>         return 0;
>  }
>
> -#ifdef CONFIG_PM_SLEEP
>  static int sx9500_suspend(struct device *dev)
>  {
>         struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
> @@ -1030,11 +1029,8 @@ static int sx9500_resume(struct device *dev)
>
>         return ret;
>  }
> -#endif /* CONFIG_PM_SLEEP */
>
> -static const struct dev_pm_ops sx9500_pm_ops = {
> -       SET_SYSTEM_SLEEP_PM_OPS(sx9500_suspend, sx9500_resume)
> -};
> +DEFINE_SIMPLE_DEV_PM_OPS(sx9500_pm_ops, sx9500_suspend, sx9500_resume);
>
>  static const struct acpi_device_id sx9500_acpi_match[] = {
>         {"SSX9500", 0},
> @@ -1060,7 +1056,7 @@ static struct i2c_driver sx9500_driver = {
>                 .name   = SX9500_DRIVER_NAME,
>                 .acpi_match_table = ACPI_PTR(sx9500_acpi_match),
>                 .of_match_table = of_match_ptr(sx9500_of_match),
> -               .pm = &sx9500_pm_ops,
> +               .pm = pm_sleep_ptr(&sx9500_pm_ops),
>         },
>         .probe          = sx9500_probe,
>         .remove         = sx9500_remove,
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 3e4ddb2e8c2b..01bfd748d820 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -993,7 +993,6 @@  static int sx9500_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int sx9500_suspend(struct device *dev)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
@@ -1030,11 +1029,8 @@  static int sx9500_resume(struct device *dev)
 
 	return ret;
 }
-#endif /* CONFIG_PM_SLEEP */
 
-static const struct dev_pm_ops sx9500_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(sx9500_suspend, sx9500_resume)
-};
+DEFINE_SIMPLE_DEV_PM_OPS(sx9500_pm_ops, sx9500_suspend, sx9500_resume);
 
 static const struct acpi_device_id sx9500_acpi_match[] = {
 	{"SSX9500", 0},
@@ -1060,7 +1056,7 @@  static struct i2c_driver sx9500_driver = {
 		.name	= SX9500_DRIVER_NAME,
 		.acpi_match_table = ACPI_PTR(sx9500_acpi_match),
 		.of_match_table = of_match_ptr(sx9500_of_match),
-		.pm = &sx9500_pm_ops,
+		.pm = pm_sleep_ptr(&sx9500_pm_ops),
 	},
 	.probe		= sx9500_probe,
 	.remove		= sx9500_remove,