[PATCH v2 05/26] drm: tegra: Define and use generic PM ops

From: Paul Cercueil
Date: Tue Nov 29 2022 - 14:19:14 EST


Use the new DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro to create a
"struct dev_pm_ops" that can be used by this driver, instead of using
custom PM callbacks with the same behaviour.

v2: Use the DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS() macro instead of an
exported dev_pm_ops.

Signed-off-by: Paul Cercueil <paul@xxxxxxxxxxxxxxx>
---
Cc: Thierry Reding <thierry.reding@xxxxxxxxx>
Cc: Jonathan Hunter <jonathanh@xxxxxxxxxx>
Cc: linux-tegra@xxxxxxxxxxxxxxx
---
drivers/gpu/drm/tegra/drm.c | 23 +++--------------------
1 file changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index a1f909dac89a..c844444ff522 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -1329,25 +1329,6 @@ static int host1x_drm_remove(struct host1x_device *dev)
return 0;
}

-#ifdef CONFIG_PM_SLEEP
-static int host1x_drm_suspend(struct device *dev)
-{
- struct drm_device *drm = dev_get_drvdata(dev);
-
- return drm_mode_config_helper_suspend(drm);
-}
-
-static int host1x_drm_resume(struct device *dev)
-{
- struct drm_device *drm = dev_get_drvdata(dev);
-
- return drm_mode_config_helper_resume(drm);
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(host1x_drm_pm_ops, host1x_drm_suspend,
- host1x_drm_resume);
-
static const struct of_device_id host1x_drm_subdevs[] = {
{ .compatible = "nvidia,tegra20-dc", },
{ .compatible = "nvidia,tegra20-hdmi", },
@@ -1389,10 +1370,12 @@ static const struct of_device_id host1x_drm_subdevs[] = {
{ /* sentinel */ }
};

+DEFINE_DRM_MODE_CONFIG_HELPER_PM_OPS(tegra_pm_ops);
+
static struct host1x_driver host1x_drm_driver = {
.driver = {
.name = "drm",
- .pm = &host1x_drm_pm_ops,
+ .pm = pm_sleep_ptr(&tegra_pm_ops),
},
.probe = host1x_drm_probe,
.remove = host1x_drm_remove,
--
2.35.1