Commit 0c74ef35 authored by Jonathan Cameron's avatar Jonathan Cameron

iio:accel:stk8ba50: 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-10-jic23@kernel.org
parent abbdba86
...@@ -504,7 +504,6 @@ static int stk8ba50_remove(struct i2c_client *client) ...@@ -504,7 +504,6 @@ static int stk8ba50_remove(struct i2c_client *client)
return stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND); return stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
} }
#ifdef CONFIG_PM_SLEEP
static int stk8ba50_suspend(struct device *dev) static int stk8ba50_suspend(struct device *dev)
{ {
struct stk8ba50_data *data; struct stk8ba50_data *data;
...@@ -523,12 +522,8 @@ static int stk8ba50_resume(struct device *dev) ...@@ -523,12 +522,8 @@ static int stk8ba50_resume(struct device *dev)
return stk8ba50_set_power(data, STK8BA50_MODE_NORMAL); return stk8ba50_set_power(data, STK8BA50_MODE_NORMAL);
} }
static SIMPLE_DEV_PM_OPS(stk8ba50_pm_ops, stk8ba50_suspend, stk8ba50_resume); static DEFINE_SIMPLE_DEV_PM_OPS(stk8ba50_pm_ops, stk8ba50_suspend,
stk8ba50_resume);
#define STK8BA50_PM_OPS (&stk8ba50_pm_ops)
#else
#define STK8BA50_PM_OPS NULL
#endif
static const struct i2c_device_id stk8ba50_i2c_id[] = { static const struct i2c_device_id stk8ba50_i2c_id[] = {
{"stk8ba50", 0}, {"stk8ba50", 0},
...@@ -546,7 +541,7 @@ MODULE_DEVICE_TABLE(acpi, stk8ba50_acpi_id); ...@@ -546,7 +541,7 @@ MODULE_DEVICE_TABLE(acpi, stk8ba50_acpi_id);
static struct i2c_driver stk8ba50_driver = { static struct i2c_driver stk8ba50_driver = {
.driver = { .driver = {
.name = "stk8ba50", .name = "stk8ba50",
.pm = STK8BA50_PM_OPS, .pm = pm_sleep_ptr(&stk8ba50_pm_ops),
.acpi_match_table = ACPI_PTR(stk8ba50_acpi_id), .acpi_match_table = ACPI_PTR(stk8ba50_acpi_id),
}, },
.probe = stk8ba50_probe, .probe = stk8ba50_probe,
......
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