[PATCH 09/17] drm/mediatek: Convert to using __drm_atomic_helper_crtc_reset() for reset.

Maarten Lankhorst maarten.lankhorst at linux.intel.com
Fri Mar 1 12:56:19 UTC 2019


Convert mediatek to using __drm_atomic_helper_crtc_reset(), instead of
writing its own version. Instead of open coding
destroy_state(), call it directly for freeing the old state.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Cc: CK Hu <ck.hu at mediatek.com>
Cc: Philipp Zabel <p.zabel at pengutronix.de>
Cc: Matthias Brugger <matthias.bgg at gmail.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 29 +++++++++----------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index acad088173da..3b18bbadd415 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -108,25 +108,6 @@ static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)
 	drm_crtc_cleanup(crtc);
 }
 
-static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
-{
-	struct mtk_crtc_state *state;
-
-	if (crtc->state) {
-		__drm_atomic_helper_crtc_destroy_state(crtc->state);
-
-		state = to_mtk_crtc_state(crtc->state);
-		memset(state, 0, sizeof(*state));
-	} else {
-		state = kzalloc(sizeof(*state), GFP_KERNEL);
-		if (!state)
-			return;
-		crtc->state = &state->base;
-	}
-
-	state->base.crtc = crtc;
-}
-
 static struct drm_crtc_state *mtk_drm_crtc_duplicate_state(struct drm_crtc *crtc)
 {
 	struct mtk_crtc_state *state;
@@ -150,6 +131,16 @@ static void mtk_drm_crtc_destroy_state(struct drm_crtc *crtc,
 	kfree(to_mtk_crtc_state(state));
 }
 
+static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
+{
+	struct mtk_crtc_state *state = kzalloc(sizeof(*state), GFP_KERNEL);
+
+	if (crtc->state)
+		mtk_drm_crtc_destroy_state(crtc, &state->base);
+
+	__drm_atomic_helper_crtc_reset(crtc, &state->base);
+}
+
 static bool mtk_drm_crtc_mode_fixup(struct drm_crtc *crtc,
 				    const struct drm_display_mode *mode,
 				    struct drm_display_mode *adjusted_mode)
-- 
2.20.1



More information about the dri-devel mailing list