Commit fe7b9a38 authored by Jonathan Cameron's avatar Jonathan Cameron

iio:magn:mag3110: 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-31-jic23@kernel.org
parent 6c1318f2
...@@ -573,7 +573,6 @@ static int mag3110_remove(struct i2c_client *client) ...@@ -573,7 +573,6 @@ static int mag3110_remove(struct i2c_client *client)
return 0; return 0;
} }
#ifdef CONFIG_PM_SLEEP
static int mag3110_suspend(struct device *dev) static int mag3110_suspend(struct device *dev)
{ {
struct mag3110_data *data = iio_priv(i2c_get_clientdata( struct mag3110_data *data = iio_priv(i2c_get_clientdata(
...@@ -623,11 +622,8 @@ static int mag3110_resume(struct device *dev) ...@@ -623,11 +622,8 @@ static int mag3110_resume(struct device *dev)
data->ctrl_reg1); data->ctrl_reg1);
} }
static SIMPLE_DEV_PM_OPS(mag3110_pm_ops, mag3110_suspend, mag3110_resume); static DEFINE_SIMPLE_DEV_PM_OPS(mag3110_pm_ops, mag3110_suspend,
#define MAG3110_PM_OPS (&mag3110_pm_ops) mag3110_resume);
#else
#define MAG3110_PM_OPS NULL
#endif
static const struct i2c_device_id mag3110_id[] = { static const struct i2c_device_id mag3110_id[] = {
{ "mag3110", 0 }, { "mag3110", 0 },
...@@ -645,7 +641,7 @@ static struct i2c_driver mag3110_driver = { ...@@ -645,7 +641,7 @@ static struct i2c_driver mag3110_driver = {
.driver = { .driver = {
.name = "mag3110", .name = "mag3110",
.of_match_table = mag3110_of_match, .of_match_table = mag3110_of_match,
.pm = MAG3110_PM_OPS, .pm = pm_sleep_ptr(&mag3110_pm_ops),
}, },
.probe = mag3110_probe, .probe = mag3110_probe,
.remove = mag3110_remove, .remove = mag3110_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