[Intel-gfx] [PATCH 09/10] lib/igt_kms: Simplify return value of kmstest_get_connector_config

Daniel Vetter daniel.vetter at ffwll.ch
Tue Aug 12 12:12:04 CEST 2014


A plain bool is enough.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 lib/igt_kms.c              | 15 ++++++++-------
 lib/igt_kms.h              |  7 +++----
 tests/kms_flip.c           | 12 ++++++------
 tests/kms_psr_sink_crc.c   | 11 ++++-------
 tests/kms_render.c         |  6 ++----
 tests/kms_sink_crc_basic.c | 10 ++++------
 tests/testdisplay.c        |  4 ++--
 7 files changed, 29 insertions(+), 36 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 9af0201abde7..258a48a9ed4d 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -414,9 +414,9 @@ bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 	return true;
 }
 
-int kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
-				 unsigned long crtc_idx_mask,
-				 struct kmstest_connector_config *config)
+bool kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
+				  unsigned long crtc_idx_mask,
+				  struct kmstest_connector_config *config)
 {
 	drmModeRes *resources;
 	drmModeConnector *connector;
@@ -493,7 +493,7 @@ found:
 
 	drmModeFreeResources(resources);
 
-	return 0;
+	return true;
 err4:
 	drmModeFreeEncoder(encoder);
 err3:
@@ -501,7 +501,7 @@ err3:
 err2:
 	drmModeFreeResources(resources);
 err1:
-	return -1;
+	return false;
 }
 
 void kmstest_free_connector_config(struct kmstest_connector_config *config)
@@ -651,7 +651,7 @@ static void igt_display_log_shift(igt_display_t *display, int shift)
 static void igt_output_refresh(igt_output_t *output)
 {
 	igt_display_t *display = output->display;
-	int ret;
+	bool ret;
 	unsigned long crtc_idx_mask;
 
 	/* we mask out the pipes already in use */
@@ -659,11 +659,12 @@ static void igt_output_refresh(igt_output_t *output)
 
 	if (output->valid)
 		kmstest_free_connector_config(&output->config);
+
 	ret = kmstest_get_connector_config(display->drm_fd,
 					   output->id,
 					   crtc_idx_mask,
 					   &output->config);
-	if (ret == 0)
+	if (ret)
 		output->valid = true;
 	else
 		output->valid = false;
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 01bbf5f53b9b..754d8568d709 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -103,7 +103,6 @@ void kmstest_dump_mode(drmModeModeInfo *mode);
 int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id);
 void kmstest_set_vt_graphics_mode(void);
 
-
 struct kmstest_connector_config {
 	drmModeCrtc *crtc;
 	drmModeConnector *connector;
@@ -154,9 +153,9 @@ void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
 
 bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 					drmModeModeInfo *mode);
-int kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
-				 unsigned long crtc_idx_mask,
-				 struct kmstest_connector_config *config);
+bool kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
+				  unsigned long crtc_idx_mask,
+				  struct kmstest_connector_config *config);
 void kmstest_free_connector_config(struct kmstest_connector_config *config);
 
 void kmstest_set_connector_dpms(int fd, drmModeConnector *connector, int mode);
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 45f1ba2fc9f4..5cd8c2f96090 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -989,8 +989,8 @@ static void connector_find_preferred_mode(uint32_t connector_id, int crtc_idx,
 {
 	struct kmstest_connector_config config;
 
-	if (kmstest_get_connector_config(drm_fd, connector_id, 1 << crtc_idx,
-					 &config) < 0) {
+	if (!kmstest_get_connector_config(drm_fd, connector_id, 1 << crtc_idx,
+					  &config)) {
 		o->mode_valid = 0;
 		return;
 	}
@@ -1032,12 +1032,12 @@ static void connector_find_compatible_mode(int crtc_idx0, int crtc_idx1,
 	drmModeModeInfo *mode[2];
 	int n, m;
 
-	if (kmstest_get_connector_config(drm_fd, o->_connector[0],
-					 1 << crtc_idx0, &config[0]) < 0)
+	if (!kmstest_get_connector_config(drm_fd, o->_connector[0],
+					  1 << crtc_idx0, &config[0]))
 		return;
 
-	if (kmstest_get_connector_config(drm_fd, o->_connector[1],
-					 1 << crtc_idx1, &config[1]) < 0) {
+	if (!kmstest_get_connector_config(drm_fd, o->_connector[1],
+					  1 << crtc_idx1, &config[1])) {
 		kmstest_free_connector_config(&config[0]);
 		return;
 	}
diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c
index 324f9b40f28a..8e8c9086b14e 100644
--- a/tests/kms_psr_sink_crc.c
+++ b/tests/kms_psr_sink_crc.c
@@ -443,13 +443,10 @@ static void test_crc(data_t *data)
 
 static bool prepare_crtc(data_t *data, uint32_t connector_id)
 {
-	int ret;
-
-	ret = kmstest_get_connector_config(data->drm_fd,
-					   connector_id,
-					   1 << data->crtc_idx,
-					   &data->config);
-	if (ret)
+	if (!kmstest_get_connector_config(data->drm_fd,
+					  connector_id,
+					  1 << data->crtc_idx,
+					  &data->config))
 		return false;
 
 	data->fb_id[0] = create_fb(data,
diff --git a/tests/kms_render.c b/tests/kms_render.c
index d8d157c41ce9..f45792981cb1 100644
--- a/tests/kms_render.c
+++ b/tests/kms_render.c
@@ -198,11 +198,9 @@ static int run_test(const char *test_name, enum test_flags flags)
 		connector_id = resources->connectors[i];
 		for (j = 0; j < resources->count_crtcs; j++) {
 			struct kmstest_connector_config cconf;
-			int ret;
 
-			ret = kmstest_get_connector_config(drm_fd, connector_id,
-							   1 << j, &cconf);
-			if (ret < 0)
+			if (!kmstest_get_connector_config(drm_fd, connector_id,
+							   1 << j, &cconf))
 				continue;
 
 			test_connector(test_name, &cconf, flags);
diff --git a/tests/kms_sink_crc_basic.c b/tests/kms_sink_crc_basic.c
index 079ec89697ed..b977dec079a3 100644
--- a/tests/kms_sink_crc_basic.c
+++ b/tests/kms_sink_crc_basic.c
@@ -111,16 +111,14 @@ connector_set_mode(data_t *data, connector_t *connector, drmModeModeInfo *mode,
 static void basic_sink_crc_check(data_t *data, uint32_t connector_id)
 {
 	connector_t connector;
-	int ret;
 	char ref_crc_white[12];
 	char ref_crc_black[12];
 	char crc_check[12];
 
-	ret = kmstest_get_connector_config(data->drm_fd,
-					   connector_id,
-					   1 << 0,
-					   &connector.config);
-	igt_require(ret == 0);
+	igt_require(kmstest_get_connector_config(data->drm_fd,
+						 connector_id,
+						 1 << 0,
+						 &connector.config));
 
 	/*Go White*/
 	connector_set_mode(data, &connector, &connector.config.default_mode, WHITE);
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index cfc629a15620..89ee11092785 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -191,8 +191,8 @@ static void connector_find_preferred_mode(uint32_t connector_id,
 {
 	struct kmstest_connector_config config;
 
-	if (kmstest_get_connector_config(drm_fd, connector_id, crtc_idx_mask,
-					 &config) < 0) {
+	if (!kmstest_get_connector_config(drm_fd, connector_id, crtc_idx_mask,
+					  &config)) {
 		c->mode_valid = 0;
 		return;
 	}
-- 
2.0.1




More information about the Intel-gfx mailing list