summaryrefslogtreecommitdiff
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorJonathan Cameron <Jonathan.Cameron@huawei.com>2023-01-14 20:16:19 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2023-01-28 01:49:53 +0300
commitf33f61a75ad24b1bc14a8edf2f313f33ae54e5f2 (patch)
tree700181a610344ff77e889c15719ddc60d11c0cff /drivers/input/misc
parent345c7b741c4631fad38bb8dc8d6659ac05d92380 (diff)
downloadlinux-f33f61a75ad24b1bc14a8edf2f313f33ae54e5f2.tar.xz
Input: cma3000 - use pm_sleep_ptr() to allow removal of ifdef CONFIG_PM guards
As the guards only apply to suspend and resume, #ifdef CONFIG_PM_SLEEP would have been a tighter protection. As pm_sleep_ptr() lets the compiler see the protected ops structure and callbacks but also lets the compiler remove it as unused code if !CONFIG_PM_SLEEP this allows the #ifdef guards to be removed, slightly simplifying the resulting code. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> -- It seems likely that DEFINE_SIMPLE_DEV_PM_OPS() would work here but I'd prefer not to make that change unless someone can confirm that the extra callbacks registered will have no unwanted side effects in this driver. Link: https://lore.kernel.org/r/20230114171620.42891-16-jic23@kernel.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/cma3000_d0x_i2c.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/drivers/input/misc/cma3000_d0x_i2c.c b/drivers/input/misc/cma3000_d0x_i2c.c
index 75442c1230b1..136eb3715870 100644
--- a/drivers/input/misc/cma3000_d0x_i2c.c
+++ b/drivers/input/misc/cma3000_d0x_i2c.c
@@ -64,7 +64,6 @@ static void cma3000_i2c_remove(struct i2c_client *client)
cma3000_exit(data);
}
-#ifdef CONFIG_PM
static int cma3000_i2c_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
@@ -89,7 +88,6 @@ static const struct dev_pm_ops cma3000_i2c_pm_ops = {
.suspend = cma3000_i2c_suspend,
.resume = cma3000_i2c_resume,
};
-#endif
static const struct i2c_device_id cma3000_i2c_id[] = {
{ "cma3000_d01", 0 },
@@ -104,9 +102,7 @@ static struct i2c_driver cma3000_i2c_driver = {
.id_table = cma3000_i2c_id,
.driver = {
.name = "cma3000_i2c_accl",
-#ifdef CONFIG_PM
- .pm = &cma3000_i2c_pm_ops,
-#endif
+ .pm = pm_sleep_ptr(&cma3000_i2c_pm_ops),
},
};