Skip to content

Commit f33f61a

Browse files
jic23dtor
authored andcommitted
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 <[email protected]> -- 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/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 345c7b7 commit f33f61a

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

drivers/input/misc/cma3000_d0x_i2c.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ static void cma3000_i2c_remove(struct i2c_client *client)
6464
cma3000_exit(data);
6565
}
6666

67-
#ifdef CONFIG_PM
6867
static int cma3000_i2c_suspend(struct device *dev)
6968
{
7069
struct i2c_client *client = to_i2c_client(dev);
@@ -89,7 +88,6 @@ static const struct dev_pm_ops cma3000_i2c_pm_ops = {
8988
.suspend = cma3000_i2c_suspend,
9089
.resume = cma3000_i2c_resume,
9190
};
92-
#endif
9391

9492
static const struct i2c_device_id cma3000_i2c_id[] = {
9593
{ "cma3000_d01", 0 },
@@ -104,9 +102,7 @@ static struct i2c_driver cma3000_i2c_driver = {
104102
.id_table = cma3000_i2c_id,
105103
.driver = {
106104
.name = "cma3000_i2c_accl",
107-
#ifdef CONFIG_PM
108-
.pm = &cma3000_i2c_pm_ops,
109-
#endif
105+
.pm = pm_sleep_ptr(&cma3000_i2c_pm_ops),
110106
},
111107
};
112108

0 commit comments

Comments
 (0)