Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: wistron_btns - 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.

--
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.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/20230114171620.42891-17-jic23@kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Jonathan Cameron and committed by
Dmitry Torokhov
47e79d31 f33f61a7

+1 -5
+1 -5
drivers/input/misc/wistron_btns.c
··· 1295 1295 return 0; 1296 1296 } 1297 1297 1298 - #ifdef CONFIG_PM 1299 1298 static int wistron_suspend(struct device *dev) 1300 1299 { 1301 1300 if (have_wifi) ··· 1329 1330 .poweroff = wistron_suspend, 1330 1331 .restore = wistron_resume, 1331 1332 }; 1332 - #endif 1333 1333 1334 1334 static struct platform_driver wistron_driver = { 1335 1335 .driver = { 1336 1336 .name = "wistron-bios", 1337 - #ifdef CONFIG_PM 1338 - .pm = &wistron_pm_ops, 1339 - #endif 1337 + .pm = pm_sleep_ptr(&wistron_pm_ops), 1340 1338 }, 1341 1339 .probe = wistron_probe, 1342 1340 .remove = wistron_remove,