Commit 2f2207a6 authored by Jonathan Cameron's avatar Jonathan Cameron

iio:light:apds9300: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etc

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: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: default avatarPaul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20220130193147.279148-19-jic23@kernel.org
parent 90b8c2c8
...@@ -466,7 +466,6 @@ static int apds9300_remove(struct i2c_client *client) ...@@ -466,7 +466,6 @@ static int apds9300_remove(struct i2c_client *client)
return 0; return 0;
} }
#ifdef CONFIG_PM_SLEEP
static int apds9300_suspend(struct device *dev) static int apds9300_suspend(struct device *dev)
{ {
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
...@@ -493,11 +492,8 @@ static int apds9300_resume(struct device *dev) ...@@ -493,11 +492,8 @@ static int apds9300_resume(struct device *dev)
return ret; return ret;
} }
static SIMPLE_DEV_PM_OPS(apds9300_pm_ops, apds9300_suspend, apds9300_resume); static DEFINE_SIMPLE_DEV_PM_OPS(apds9300_pm_ops, apds9300_suspend,
#define APDS9300_PM_OPS (&apds9300_pm_ops) apds9300_resume);
#else
#define APDS9300_PM_OPS NULL
#endif
static const struct i2c_device_id apds9300_id[] = { static const struct i2c_device_id apds9300_id[] = {
{ APDS9300_DRV_NAME, 0 }, { APDS9300_DRV_NAME, 0 },
...@@ -509,7 +505,7 @@ MODULE_DEVICE_TABLE(i2c, apds9300_id); ...@@ -509,7 +505,7 @@ MODULE_DEVICE_TABLE(i2c, apds9300_id);
static struct i2c_driver apds9300_driver = { static struct i2c_driver apds9300_driver = {
.driver = { .driver = {
.name = APDS9300_DRV_NAME, .name = APDS9300_DRV_NAME,
.pm = APDS9300_PM_OPS, .pm = pm_sleep_ptr(&apds9300_pm_ops),
}, },
.probe = apds9300_probe, .probe = apds9300_probe,
.remove = apds9300_remove, .remove = apds9300_remove,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment