iio:light:ltr501: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 30 Jan 2022 19:31:20 +0000 (19:31 +0000)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Fri, 18 Feb 2022 11:45:29 +0000 (11:45 +0000)
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>
Cc: Maslov Dmitry <maslovdmitry@seeed.cc>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20220130193147.279148-24-jic23@kernel.org
drivers/iio/light/ltr501.c

index d1532ef5f08be8a09c7e677ccf286dacea2650ef..679a1e1086ae839f9a74daf03fb652bc6ef808fb 100644 (file)
@@ -1611,7 +1611,6 @@ static int ltr501_remove(struct i2c_client *client)
        return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
 static int ltr501_suspend(struct device *dev)
 {
        struct ltr501_data *data = iio_priv(i2c_get_clientdata(
@@ -1627,9 +1626,8 @@ static int ltr501_resume(struct device *dev)
        return ltr501_write_contr(data, data->als_contr,
                data->ps_contr);
 }
-#endif
 
-static SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resume);
 
 static const struct acpi_device_id ltr_acpi_match[] = {
        { "LTER0501", ltr501 },
@@ -1661,7 +1659,7 @@ static struct i2c_driver ltr501_driver = {
        .driver = {
                .name   = LTR501_DRV_NAME,
                .of_match_table = ltr501_of_match,
-               .pm     = &ltr501_pm_ops,
+               .pm     = pm_sleep_ptr(&ltr501_pm_ops),
                .acpi_match_table = ACPI_PTR(ltr_acpi_match),
        },
        .probe  = ltr501_probe,