Thread (19 messages) 19 messages, 3 authors, 2023-01-27

Lifecycle

  1. Posted Jonathan Cameron <jic23@kernel.org>
  2. Landed on mainline (Linus) commit 47e79d310928

[PATCH 16/16] Input: wistron_btns - use pm_sleep_ptr() to allow removal of ifdef CONFIG_PM guards

From: Jonathan Cameron <jic23@kernel.org>
Date: 2023-01-14 17:03:18
Subsystem: input (keyboard, mouse, joystick, touchscreen) drivers, the rest, wistron laptop button driver · Maintainers: Dmitry Torokhov, Linus Torvalds, Miloslav Trmac

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

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.
---
 drivers/input/misc/wistron_btns.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 80dfd72a02d3..111cb70cde46 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -1295,7 +1295,6 @@ static int wistron_remove(struct platform_device *dev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
 static int wistron_suspend(struct device *dev)
 {
 	if (have_wifi)
@@ -1330,14 +1329,11 @@ static const struct dev_pm_ops wistron_pm_ops = {
 	.poweroff	= wistron_suspend,
 	.restore	= wistron_resume,
 };
-#endif
 
 static struct platform_driver wistron_driver = {
 	.driver		= {
 		.name	= "wistron-bios",
-#ifdef CONFIG_PM
-		.pm	= &wistron_pm_ops,
-#endif
+		.pm	= pm_sleep_ptr(&wistron_pm_ops),
 	},
 	.probe		= wistron_probe,
 	.remove		= wistron_remove,
-- 
2.39.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help