[PATCH 48/70] drm/atmel-hlcdc: Convert to atomic_create_state

Maxime Ripard <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel
Message-ID <[email protected]>
The atmel-hlcdc 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: Alexandre Belloni <[email protected]>
Cc: Claudiu Beznea <[email protected]>
Cc: Dharma Balasubiramani <[email protected]>
Cc: Manikandan Muralidharan <[email protected]>
Cc: Nicolas Ferre <[email protected]>
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 9dbac2def333..c2c4c9c3086b 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -527,24 +527,21 @@ void atmel_hlcdc_crtc_irq(struct drm_crtc *c)
 {
 	drm_crtc_handle_vblank(c);
 	atmel_hlcdc_crtc_finish_page_flip(drm_crtc_to_atmel_hlcdc_crtc(c));
 }
 
-static void atmel_hlcdc_crtc_reset(struct drm_crtc *crtc)
+static struct drm_crtc_state *atmel_hlcdc_crtc_create_state(struct drm_crtc *crtc)
 {
 	struct atmel_hlcdc_crtc_state *state;
 
-	if (crtc->state) {
-		__drm_atomic_helper_crtc_destroy_state(crtc->state);
-		state = drm_crtc_state_to_atmel_hlcdc_crtc_state(crtc->state);
-		kfree(state);
-		crtc->state = NULL;
-	}
-
 	state = kzalloc_obj(*state);
-	if (state)
-		__drm_atomic_helper_crtc_reset(crtc, &state->base);
+	if (!state)
+		return ERR_PTR(-ENOMEM);
+
+	__drm_atomic_helper_crtc_state_init(&state->base, crtc);
+
+	return &state->base;
 }
 
 static struct drm_crtc_state *
 atmel_hlcdc_crtc_duplicate_state(struct drm_crtc *crtc)
 {
@@ -597,11 +594,11 @@ static void atmel_hlcdc_crtc_disable_vblank(struct drm_crtc *c)
 }
 
 static const struct drm_crtc_funcs atmel_hlcdc_crtc_funcs = {
 	.page_flip = drm_atomic_helper_page_flip,
 	.set_config = drm_atomic_helper_set_config,
-	.reset = atmel_hlcdc_crtc_reset,
+	.atomic_create_state = atmel_hlcdc_crtc_create_state,
 	.atomic_duplicate_state =  atmel_hlcdc_crtc_duplicate_state,
 	.atomic_destroy_state = atmel_hlcdc_crtc_destroy_state,
 	.enable_vblank = atmel_hlcdc_crtc_enable_vblank,
 	.disable_vblank = atmel_hlcdc_crtc_disable_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.