The ast crtc implementation provides a custom reset hook. However,
this hook only allocates the state, initializes it with
__drm_atomic_helper_crtc_reset(), and frees the previous state. It
does not perform any hardware reset.

Since this is exactly what the atomic_create_state hook is meant to
do, minus the old state cleanup which the caller handles, convert the
implementation to use atomic_create_state with
__drm_atomic_helper_crtc_state_init() instead.

Signed-off-by: Maxime Ripard <[email protected]>
---
Cc: Dave Airlie <[email protected]>
Cc: Jocelyn Falempe <[email protected]>
---
 drivers/gpu/drm/ast/ast_mode.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index d5ed8c5c7925..ea0ef8096aa9 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -886,21 +886,21 @@ static const struct drm_crtc_helper_funcs 
ast_crtc_helper_funcs = {
        .atomic_flush = ast_crtc_helper_atomic_flush,
        .atomic_enable = ast_crtc_helper_atomic_enable,
        .atomic_disable = ast_crtc_helper_atomic_disable,
 };
 
-static void ast_crtc_reset(struct drm_crtc *crtc)
+static struct drm_crtc_state *ast_crtc_create_state(struct drm_crtc *crtc)
 {
-       struct ast_crtc_state *ast_state = kzalloc_obj(*ast_state);
+       struct ast_crtc_state *ast_state;
 
-       if (crtc->state)
-               crtc->funcs->atomic_destroy_state(crtc, crtc->state);
+       ast_state = kzalloc_obj(*ast_state);
+       if (!ast_state)
+               return ERR_PTR(-ENOMEM);
 
-       if (ast_state)
-               __drm_atomic_helper_crtc_reset(crtc, &ast_state->base);
-       else
-               __drm_atomic_helper_crtc_reset(crtc, NULL);
+       __drm_atomic_helper_crtc_state_init(&ast_state->base, crtc);
+
+       return &ast_state->base;
 }
 
 static struct drm_crtc_state *
 ast_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
 {
@@ -932,11 +932,11 @@ static void ast_crtc_atomic_destroy_state(struct drm_crtc 
*crtc,
        __drm_atomic_helper_crtc_destroy_state(&ast_state->base);
        kfree(ast_state);
 }
 
 static const struct drm_crtc_funcs ast_crtc_funcs = {
-       .reset = ast_crtc_reset,
+       .atomic_create_state = ast_crtc_create_state,
        .destroy = drm_crtc_cleanup,
        .set_config = drm_atomic_helper_set_config,
        .page_flip = drm_atomic_helper_page_flip,
        .atomic_duplicate_state = ast_crtc_atomic_duplicate_state,
        .atomic_destroy_state = ast_crtc_atomic_destroy_state,

-- 
2.55.0

Reply via email to