The tidss crtc driver implements its own state, with its own
implementation of reset and duplicate_state, but uses the default
destroy_state helper.

This somewhat works for now because the drm_crtc_state field in
tidss_crtc_state is the first field so the offset is 0, but it's pretty
fragile and it should really have its own destroy_state implementation.

Signed-off-by: Maxime Ripard <mrip...@kernel.org>
---
 drivers/gpu/drm/tidss/tidss_crtc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tidss/tidss_crtc.c 
b/drivers/gpu/drm/tidss/tidss_crtc.c
index 
db7c5e4225e6247047087a35a2e6422950fc0111..eb431a238b11d22349d61f0e17f05994f50d5f2f
 100644
--- a/drivers/gpu/drm/tidss/tidss_crtc.c
+++ b/drivers/gpu/drm/tidss/tidss_crtc.c
@@ -341,10 +341,19 @@ static void tidss_crtc_disable_vblank(struct drm_crtc 
*crtc)
        tidss_irq_disable_vblank(crtc);
 
        tidss_runtime_put(tidss);
 }
 
+static void tidss_crtc_destroy_state(struct drm_crtc *crtc,
+                                    struct drm_crtc_state *state)
+{
+       struct tidss_crtc_state *tstate = to_tidss_crtc_state(state);
+
+       __drm_atomic_helper_crtc_destroy_state(&tstate->base);
+       kfree(tstate);
+}
+
 static void tidss_crtc_reset(struct drm_crtc *crtc)
 {
        struct tidss_crtc_state *tstate;
 
        if (crtc->state)
@@ -396,11 +405,11 @@ static const struct drm_crtc_funcs tidss_crtc_funcs = {
        .reset = tidss_crtc_reset,
        .destroy = tidss_crtc_destroy,
        .set_config = drm_atomic_helper_set_config,
        .page_flip = drm_atomic_helper_page_flip,
        .atomic_duplicate_state = tidss_crtc_duplicate_state,
-       .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+       .atomic_destroy_state = tidss_crtc_destroy_state,
        .enable_vblank = tidss_crtc_enable_vblank,
        .disable_vblank = tidss_crtc_disable_vblank,
 };
 
 struct tidss_crtc *tidss_crtc_create(struct tidss_device *tidss,

-- 
2.50.1

Reply via email to