diff mbox

[4/4] drm: Simplify the setplane/pageflip old_fb handling further

Message ID 20180713155035.3866-4-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjälä July 13, 2018, 3:50 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Instead of doing the things in a convoluted way with the failure and
success paths mixed up let's just clear old_fb when we encounter an
error and bail out immediately.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_plane.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index e3f2ddf7deae..406f11281d61 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -655,12 +655,13 @@  static int __setplane_internal(struct drm_plane *plane,
 	if (!fb) {
 		plane->old_fb = plane->fb;
 		ret = plane->funcs->disable_plane(plane, ctx);
-		if (!ret) {
-			plane->crtc = NULL;
-			plane->fb = NULL;
-		} else {
+		if (ret) {
 			plane->old_fb = NULL;
+			return ret;
 		}
+
+		plane->crtc = NULL;
+		plane->fb = NULL;
 		goto out;
 	}
 
@@ -668,20 +669,22 @@  static int __setplane_internal(struct drm_plane *plane,
 			       crtc_x, crtc_y, crtc_w, crtc_h,
 			       src_x, src_y, src_w, src_h);
 	if (ret)
-		goto out;
+		return ret;
 
 	plane->old_fb = plane->fb;
+
 	ret = plane->funcs->update_plane(plane, crtc, fb,
 					 crtc_x, crtc_y, crtc_w, crtc_h,
 					 src_x, src_y, src_w, src_h, ctx);
-	if (!ret) {
-		plane->crtc = crtc;
-		plane->fb = fb;
-		drm_framebuffer_get(plane->fb);
-	} else {
+	if (ret) {
 		plane->old_fb = NULL;
+		return ret;
 	}
 
+	plane->crtc = crtc;
+	plane->fb = fb;
+	drm_framebuffer_get(plane->fb);
+
 out:
 	if (plane->old_fb)
 		drm_framebuffer_put(plane->old_fb);
@@ -1049,15 +1052,14 @@  static int page_flip_internal(struct drm_crtc *crtc,
 						    target_vblank, ctx);
 	else
 		ret = crtc->funcs->page_flip(crtc, fb, e, flags, ctx);
-
 	if (ret) {
-		/* Keep the old fb, don't unref it. */
 		plane->old_fb = NULL;
-	} else {
-		plane->fb = fb;
-		drm_framebuffer_get(plane->fb);
+		return ret;
 	}
 
+	plane->fb = fb;
+	drm_framebuffer_get(plane->fb);
+
 	if (plane->old_fb)
 		drm_framebuffer_put(plane->old_fb);
 	plane->old_fb = NULL;