Skip to contentSkip to conversation

drm/mediatek: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

PATCH In review Triet Hoang 3 participants 3 messages Aug 20

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

PATCH 1/1 drm/mediatek: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

Convert the deprecated SIMPLE_DEV_PM_OPS
to DEFINE_SIMPLE_DEV_PM_OPS and pm_sleep_ptr().

This lets us drop the __maybe_unused annotations from its suspend and resume callbacks, and reduces kernel size in case CONFIG_PM or CONFIG_PM_SLEEP is disabled.

---
 drivers/gpu/drm/mediatek/mtk_hdmi_v2.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c +4 -4
index ffe456238a2b..a2acb2d9742e 100644
@@ -1412,7 +1412,7 @@ static const struct hdmi_codec_ops mtk_hdmi_v2_audio_codec_ops = {
 	.hook_plugged_cb = mtk_hdmi_v2_audio_hook_plugged_cb,
 };
 
-static __maybe_unused int mtk_hdmi_v2_suspend(struct device *dev)
+static int mtk_hdmi_v2_suspend(struct device *dev)
 {
 	struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
 
@@ -1421,14 +1421,14 @@ static __maybe_unused int mtk_hdmi_v2_suspend(struct device *dev)
 	return 0;
 }
 
-static __maybe_unused int mtk_hdmi_v2_resume(struct device *dev)
+static int mtk_hdmi_v2_resume(struct device *dev)
 {
 	struct mtk_hdmi *hdmi = dev_get_drvdata(dev);
 
 	return mtk_hdmi_v2_enable(hdmi);
 }
 
-static SIMPLE_DEV_PM_OPS(mtk_hdmi_v2_pm_ops, mtk_hdmi_v2_suspend, mtk_hdmi_v2_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(mtk_hdmi_v2_pm_ops, mtk_hdmi_v2_suspend, mtk_hdmi_v2_resume);
 
 static const struct mtk_hdmi_ver_conf mtk_hdmi_conf_v2 = {
 	.bridge_funcs = &mtk_v2_hdmi_bridge_funcs,
@@ -1511,7 +1511,7 @@ static struct platform_driver mtk_hdmi_v2_driver = {
 	.driver = {
 		.name = "mediatek-drm-hdmi-v2",
 		.of_match_table = mtk_drm_hdmi_v2_of_ids,
-		.pm = &mtk_hdmi_v2_pm_ops,
+		.pm = pm_sleep_ptr(&mtk_hdmi_v2_pm_ops),
 	},
 };
 module_platform_driver(mtk_hdmi_v2_driver);
Signature · 1 line
2.53.0
#1 lore raw

…

Quoted 1 line

This lets us drop the __maybe_unused annotations from its suspend and

…
Thus drop …?

Regards,
Markus

#2 lore raw
In reply to Triet Hoang
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The patch uses `pm_sleep_ptr()` for the `dev_pm_ops` structure pointer instead of `pm_ptr()`…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The patch uses pm_sleep_ptr() for the dev_pm_ops structure pointer instead of pm_ptr(), violating PM subsystem guidelines. --

--- Patch [1]: [PATCH] drm/mediatek: Convert to DEFINE_SIMPLE_DEV_PM_OPS() --- commit 400d629fa164bd607d4a5ca22f02d2a6a8f25fe6
Author: Triet Hoang <[email protected]>

drm/mediatek: Convert to DEFINE_SIMPLE_DEV_PM_OPS()

This commit replaces the deprecated SIMPLE_DEV_PM_OPS with DEFINE_SIMPLE_DEV_PM_OPS and pm_sleep_ptr(). It removes the __maybe_unused annotations from the suspend and resume callbacks to reduce kernel size when PM features are disabled.

Quoted 4 lines
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c +0 -0
index f0277fcf3345b..c1a12c5a0f905 100644

[ ... ]

drivers/gpu/drm/mediatek/mtk_hdmi_v2.c static struct platform_driver mtk_hdmi_v2_driver = { · line 1514

Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c +1 -1
@@ -1511,7 +1511,7 @@ static struct platform_driver mtk_hdmi_v2_driver = {
 	.driver = {
 		.name = "mediatek-drm-hdmi-v2",
 		.of_match_table = mtk_drm_hdmi_v2_of_ids,
-		.pm = &mtk_hdmi_v2_pm_ops,
+		.pm = pm_sleep_ptr(&mtk_hdmi_v2_pm_ops),

[Severity: Low]
Should this use pm_ptr() instead of pm_sleep_ptr()?

According to power management guidelines, pm_sleep_ptr() evaluates to NULL when CONFIG_PM_SLEEP is disabled. If runtime PM callbacks were ever added to the dev_pm_ops structure in the future, wouldn't using pm_sleep_ptr() here silently disable those runtime PM callbacks when system sleep is disabled but CONFIG_PM is still enabled?

The standard pattern is to use pm_sleep_ptr() for the individual sleep callbacks inside the structure definition, and pm_ptr() for the structure pointer assignment itself.

Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_hdmi_v2.c +0 -0
 	},
 };
 module_platform_driver(mtk_hdmi_v2_driver);
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1