Commit c1d24fac authored by Jonathan Cameron's avatar Jonathan Cameron

iio:accel:stk8312: 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-39-jic23@kernel.org
parent ce83415d
...@@ -611,7 +611,6 @@ static int stk8312_remove(struct i2c_client *client) ...@@ -611,7 +611,6 @@ static int stk8312_remove(struct i2c_client *client)
return stk8312_set_mode(data, STK8312_MODE_STANDBY); return stk8312_set_mode(data, STK8312_MODE_STANDBY);
} }
#ifdef CONFIG_PM_SLEEP
static int stk8312_suspend(struct device *dev) static int stk8312_suspend(struct device *dev)
{ {
struct stk8312_data *data; struct stk8312_data *data;
...@@ -630,12 +629,8 @@ static int stk8312_resume(struct device *dev) ...@@ -630,12 +629,8 @@ static int stk8312_resume(struct device *dev)
return stk8312_set_mode(data, data->mode | STK8312_MODE_ACTIVE); return stk8312_set_mode(data, data->mode | STK8312_MODE_ACTIVE);
} }
static SIMPLE_DEV_PM_OPS(stk8312_pm_ops, stk8312_suspend, stk8312_resume); static DEFINE_SIMPLE_DEV_PM_OPS(stk8312_pm_ops, stk8312_suspend,
stk8312_resume);
#define STK8312_PM_OPS (&stk8312_pm_ops)
#else
#define STK8312_PM_OPS NULL
#endif
static const struct i2c_device_id stk8312_i2c_id[] = { static const struct i2c_device_id stk8312_i2c_id[] = {
/* Deprecated in favour of lowercase form */ /* Deprecated in favour of lowercase form */
...@@ -648,7 +643,7 @@ MODULE_DEVICE_TABLE(i2c, stk8312_i2c_id); ...@@ -648,7 +643,7 @@ MODULE_DEVICE_TABLE(i2c, stk8312_i2c_id);
static struct i2c_driver stk8312_driver = { static struct i2c_driver stk8312_driver = {
.driver = { .driver = {
.name = STK8312_DRIVER_NAME, .name = STK8312_DRIVER_NAME,
.pm = STK8312_PM_OPS, .pm = pm_sleep_ptr(&stk8312_pm_ops),
}, },
.probe = stk8312_probe, .probe = stk8312_probe,
.remove = stk8312_remove, .remove = stk8312_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