Skip to contentSkip to conversation

input: keyboard: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

PATCH In review Triet Hoang 3 participants 3 messages Aug 21 – Oct 27

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: keyboard: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Convert deprecated SIMPLE_DEV_PM_OPS
to DEFINE_SIMPLE_DEV_PM_OPS and pm_sleep_ptr().

This lets us drop the __maybe_unused annotations
from the resume callbacks and reduces kernel size
when CONFIG_PM or CONFIG_PM_SLEEP is disabled.

---
 drivers/input/keyboard/imx-sm-bbm-key.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/input/keyboard/imx-sm-bbm-key.c +4 -4
index 96486bd23d60..7fbbd44878be 100644
@@ -187,7 +187,7 @@ static int scmi_imx_bbm_key_probe(struct scmi_device *sdev)
 	return ret;
 }
 
-static int __maybe_unused scmi_imx_bbm_key_suspend(struct device *dev)
+static int scmi_imx_bbm_key_suspend(struct device *dev)
 {
 	struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev);
 
@@ -196,12 +196,12 @@ static int __maybe_unused scmi_imx_bbm_key_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused scmi_imx_bbm_key_resume(struct device *dev)
+static int scmi_imx_bbm_key_resume(struct device *dev)
 {
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(scmi_imx_bbm_pm_key_ops, scmi_imx_bbm_key_suspend,
+static DEFINE_SIMPLE_DEV_PM_OPS(scmi_imx_bbm_pm_key_ops, scmi_imx_bbm_key_suspend,
 			 scmi_imx_bbm_key_resume);
 
 static const struct scmi_device_id scmi_id_table[] = {
@@ -212,7 +212,7 @@ MODULE_DEVICE_TABLE(scmi, scmi_id_table);
 
 static struct scmi_driver scmi_imx_bbm_key_driver = {
 	.driver = {
-		.pm = &scmi_imx_bbm_pm_key_ops,
+		.pm = pm_sleep_ptr(&scmi_imx_bbm_pm_key_ops),
 	},
 	.name = "scmi-imx-bbm-key",
 	.probe = scmi_imx_bbm_key_probe,
Signature · 1 line
2.53.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing error handling on devm_event_notifier_register allows probe to succeed with a non-functional device. --

--- Patch [1]: [PATCH] input: keyboard: Convert to DEFINE_SIMPLE_DEV_PM_OPS() --- commit 88eacffae6d3079bb9f5aa0b29b554341484a82a
Author: Triet Hoang <[email protected]>

input: keyboard: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Convert deprecated SIMPLE_DEV_PM_OPS to DEFINE_SIMPLE_DEV_PM_OPS and pm_sleep_ptr(). This lets us drop the __maybe_unused annotations from the resume callbacks and reduces kernel size when CONFIG_PM or CONFIG_PM_SLEEP is disabled.

drivers/input/keyboard/imx-sm-bbm-key.c static int scmi_imx_bbm_key_probe(struct scmi_device *sdev) · line 188

Quoted 7 lines
drivers/input/keyboard/imx-sm-bbm-key.c +0 -0
index 96486bd23d609..7fbbd44878be3 100644
@@ -187,7 +187,7 @@ static int scmi_imx_bbm_key_probe(struct scmi_device *sdev)
 	return ret;
 }

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing the probe path I noticed an issue in scmi_imx_bbm_pwrkey_init().

When devm_event_notifier_register() fails, the error code in ret is printed but then immediately overwritten:

drivers/input/keyboard/imx-sm-bbm-key.c:scmi_imx_bbm_pwrkey_init() {
	...
	ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_BBM,
							       SCMI_EVENT_IMX_BBM_BUTTON,
							       NULL, &bbnsm->nb);

	if (ret)
		dev_err(dev, "Failed to register BBM Button Events %d:", ret);

	ret = input_register_device(input);
	...
}

Does this allow the probe to incorrectly succeed with a non-functional device if the notifier registration fails? Should it return the error instead of continuing to input_register_device()?

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Triet Hoang
Quoted 9 lines · Triet Hoang

Convert deprecated SIMPLE_DEV_PM_OPS
to DEFINE_SIMPLE_DEV_PM_OPS and pm_sleep_ptr().

This lets us drop the __maybe_unused annotations
from the resume callbacks and reduces kernel size
when CONFIG_PM or CONFIG_PM_SLEEP is disabled.

---

Quoted 43 lines
 drivers/input/keyboard/imx-sm-bbm-key.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/input/keyboard/imx-sm-bbm-key.c +4 -5
index 96486bd23d60..7fbbd44878be 100644
@@ -187,7 +187,7 @@ static int scmi_imx_bbm_key_probe(struct scmi_device *sdev)
 	return ret;
 }
 
-static int __maybe_unused scmi_imx_bbm_key_suspend(struct device *dev)
+static int scmi_imx_bbm_key_suspend(struct device *dev)
 {
 	struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev);
 
@@ -196,12 +196,12 @@ static int __maybe_unused scmi_imx_bbm_key_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused scmi_imx_bbm_key_resume(struct device *dev)
+static int scmi_imx_bbm_key_resume(struct device *dev)
 {
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(scmi_imx_bbm_pm_key_ops, scmi_imx_bbm_key_suspend,
+static DEFINE_SIMPLE_DEV_PM_OPS(scmi_imx_bbm_pm_key_ops, scmi_imx_bbm_key_suspend,
 			 scmi_imx_bbm_key_resume);
 
 static const struct scmi_device_id scmi_id_table[] = {
@@ -212,7 +212,7 @@ MODULE_DEVICE_TABLE(scmi, scmi_id_table);
 
 static struct scmi_driver scmi_imx_bbm_key_driver = {
 	.driver = {
-		.pm = &scmi_imx_bbm_pm_key_ops,
+		.pm = pm_sleep_ptr(&scmi_imx_bbm_pm_key_ops),
 	},
 	.name = "scmi-imx-bbm-key",
 	.probe = scmi_imx_bbm_key_probe,
--

2.53.0