drm: rcar-du: Use the drm atomic state duplication helpers for planes
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Wed, 27 May 2015 13:36:29 +0000 (16:36 +0300)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tue, 16 Jun 2015 11:25:55 +0000 (14:25 +0300)
Ensure that the duplicate and destroy plane state operations will always
be in sync with the DRM core implementation of the plane state by using
the __drm_atomic_helper_plane_duplicate_state() and
__drm_atomic_helper_plane_destroy_state() functions designed especially
for this purpose.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
drivers/gpu/drm/rcar-du/rcar_du_plane.c

index d90dc428e3fd9913988d873936f049e6bd42b470..c66986414bb4fca0881b59f5b3796fc984124972 100644 (file)
@@ -302,13 +302,15 @@ rcar_du_plane_atomic_duplicate_state(struct drm_plane *plane)
        struct rcar_du_plane_state *state;
        struct rcar_du_plane_state *copy;
 
+       if (WARN_ON(!plane->state))
+               return NULL;
+
        state = to_rcar_plane_state(plane->state);
        copy = kmemdup(state, sizeof(*state), GFP_KERNEL);
        if (copy == NULL)
                return NULL;
 
-       if (copy->state.fb)
-               drm_framebuffer_reference(copy->state.fb);
+       __drm_atomic_helper_plane_duplicate_state(plane, &copy->state);
 
        return &copy->state;
 }
@@ -316,9 +318,7 @@ rcar_du_plane_atomic_duplicate_state(struct drm_plane *plane)
 static void rcar_du_plane_atomic_destroy_state(struct drm_plane *plane,
                                               struct drm_plane_state *state)
 {
-       if (state->fb)
-               drm_framebuffer_unreference(state->fb);
-
+       __drm_atomic_helper_plane_destroy_state(plane, state);
        kfree(to_rcar_plane_state(state));
 }