[PATCH 60/70] drm/rzg2l-du: Convert to atomic_create_state

Maxime Ripard <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel,org.kernel.vger.linux-renesas-soc
Message-ID <[email protected]>
The rzg2l-du 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: Biju Das <[email protected]>
Cc: [email protected]
---
 drivers/gpu/drm/renesas/rz-du/rzg2l_du_crtc.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_crtc.c b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_crtc.c
index d0f01aa642a7..ab2f24cc7683 100644
--- a/drivers/gpu/drm/renesas/rz-du/rzg2l_du_crtc.c
+++ b/drivers/gpu/drm/renesas/rz-du/rzg2l_du_crtc.c
@@ -330,24 +330,21 @@ static void rzg2l_du_crtc_atomic_destroy_state(struct drm_crtc *crtc,
 {
 	__drm_atomic_helper_crtc_destroy_state(state);
 	kfree(to_rzg2l_crtc_state(state));
 }
 
-static void rzg2l_du_crtc_reset(struct drm_crtc *crtc)
+static struct drm_crtc_state *rzg2l_du_crtc_create_state(struct drm_crtc *crtc)
 {
 	struct rzg2l_du_crtc_state *state;
 
-	if (crtc->state) {
-		rzg2l_du_crtc_atomic_destroy_state(crtc, crtc->state);
-		crtc->state = NULL;
-	}
-
 	state = kzalloc_obj(*state);
 	if (!state)
-		return;
+		return ERR_PTR(-ENOMEM);
 
-	__drm_atomic_helper_crtc_reset(crtc, &state->state);
+	__drm_atomic_helper_crtc_state_init(&state->state, crtc);
+
+	return &state->state;
 }
 
 static int rzg2l_du_crtc_enable_vblank(struct drm_crtc *crtc)
 {
 	struct rzg2l_du_crtc *rcrtc = to_rzg2l_crtc(crtc);
@@ -363,11 +360,11 @@ static void rzg2l_du_crtc_disable_vblank(struct drm_crtc *crtc)
 
 	rcrtc->vblank_enable = false;
 }
 
 static const struct drm_crtc_funcs crtc_funcs_rz = {
-	.reset = rzg2l_du_crtc_reset,
+	.atomic_create_state = rzg2l_du_crtc_create_state,
 	.set_config = drm_atomic_helper_set_config,
 	.page_flip = drm_atomic_helper_page_flip,
 	.atomic_duplicate_state = rzg2l_du_crtc_atomic_duplicate_state,
 	.atomic_destroy_state = rzg2l_du_crtc_atomic_destroy_state,
 	.enable_vblank = rzg2l_du_crtc_enable_vblank,

-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.