iio:pressure:mpl3115: 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: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20220130193147.279148-33-jic23@kernel.org
This commit is contained in:
Jonathan Cameron 2022-01-30 19:31:29 +00:00
parent c9f384b87b
commit 902b291fc6

View file

@ -301,7 +301,6 @@ static int mpl3115_remove(struct i2c_client *client)
return 0; return 0;
} }
#ifdef CONFIG_PM_SLEEP
static int mpl3115_suspend(struct device *dev) static int mpl3115_suspend(struct device *dev)
{ {
return mpl3115_standby(iio_priv(i2c_get_clientdata( return mpl3115_standby(iio_priv(i2c_get_clientdata(
@ -317,11 +316,8 @@ static int mpl3115_resume(struct device *dev)
data->ctrl_reg1); data->ctrl_reg1);
} }
static SIMPLE_DEV_PM_OPS(mpl3115_pm_ops, mpl3115_suspend, mpl3115_resume); static DEFINE_SIMPLE_DEV_PM_OPS(mpl3115_pm_ops, mpl3115_suspend,
#define MPL3115_PM_OPS (&mpl3115_pm_ops) mpl3115_resume);
#else
#define MPL3115_PM_OPS NULL
#endif
static const struct i2c_device_id mpl3115_id[] = { static const struct i2c_device_id mpl3115_id[] = {
{ "mpl3115", 0 }, { "mpl3115", 0 },
@ -339,7 +335,7 @@ static struct i2c_driver mpl3115_driver = {
.driver = { .driver = {
.name = "mpl3115", .name = "mpl3115",
.of_match_table = mpl3115_of_match, .of_match_table = mpl3115_of_match,
.pm = MPL3115_PM_OPS, .pm = pm_sleep_ptr(&mpl3115_pm_ops),
}, },
.probe = mpl3115_probe, .probe = mpl3115_probe,
.remove = mpl3115_remove, .remove = mpl3115_remove,