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.lankho...@linux.intel.com>
Cc: CK Hu <ck...@mediatek.com>
Cc: Philipp Zabel <p.za...@pengutronix.de>
Cc: Matthias Brugger <matthias....@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

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to