[Intel-gfx] [PATCH 4/7] drm: Simplify the setplane old_fb handling further

Ville Syrjala ville.syrjala at linux.intel.com
Fri Nov 15 19:42:01 UTC 2019


From: Ville Syrjälä <ville.syrjala at 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. We already did this for the pageflip
path.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 drivers/gpu/drm/drm_plane.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 6052475a20a5..ef0cc33b43ce 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -688,12 +688,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;
 	}
 
@@ -701,26 +702,27 @@ 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);
 	plane->old_fb = NULL;
 
-	return ret;
+	return 0;
 }
 
 static int __setplane_atomic(struct drm_plane *plane,
-- 
2.23.0



More information about the Intel-gfx mailing list