[i-g-t,6/7] kms_flip: Rework set_mode()
diff mbox series

Message ID ff2e2b0c5d4addbb921121dc230613b24bd36a7b.1551712108.git.rodrigosiqueiramelo@gmail.com
State New
Headers show
Series
  • kms_flip: cleanups
Related show

Commit Message

Rodrigo Siqueira March 4, 2019, 3:31 p.m. UTC
This patch removes the duplicate code inside the function set_mode().

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
---
 tests/kms_flip.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

Patch
diff mbox series

diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 42ae3ebc..de3ab600 100755
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -609,22 +609,24 @@  static bool is_wedged(int fd)
 
 static int set_mode(struct test_output *o, uint32_t fb, int x, int y)
 {
-	int n;
+	int n, ret;
 
 	for (n = o->count - 1; n >= 0; n--) {
+		uint32_t buffer_id = fb, x_crtc = x, y_crtc = y;
+		uint32_t *conn = &o->_connector[n];
+		int count = 1;
+		drmModeModeInfoPtr mode = &o->kmode[n];
+
 		if (fb == 0) {
-			int ret = drmModeSetCrtc(drm_fd, o->_crtc[n],
-						 0, 0, 0,
-						 0, 0, 0);
-			if (ret)
-				return ret;
-		} else {
-			int ret = drmModeSetCrtc(drm_fd, o->_crtc[n],
-						 fb, x, y,
-						 &o->_connector[n], 1, &o->kmode[n]);
-			if (ret)
-				return ret;
+			buffer_id = x_crtc = y_crtc = count = 0;
+			conn = NULL; mode = NULL;
 		}
+
+		ret = drmModeSetCrtc(drm_fd, o->_crtc[n],
+				     buffer_id, x_crtc, y_crtc,
+				     conn, count, mode);
+		if (ret)
+			return ret;
 	}
 
 	return 0;