dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Emil Velikov <emil.l.velikov@gmail.com>,
	Hyungwon Hwang <human.hwang@samsung.com>
Subject: [PATCH libdrm 08/10] modetest: Use util_open()
Date: Wed,  9 Dec 2015 18:37:46 +0100	[thread overview]
Message-ID: <1449682668-22487-8-git-send-email-thierry.reding@gmail.com> (raw)
In-Reply-To: <1449682668-22487-1-git-send-email-thierry.reding@gmail.com>

From: Thierry Reding <treding@nvidia.com>

Use the new util_open() helper instead of open-coding the method for
finding a usable device.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 tests/modetest/modetest.c | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 0e009d87fdee..22e3e81bd3cc 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1503,7 +1503,6 @@ int main(int argc, char **argv)
 	int drop_master = 0;
 	int test_vsync = 0;
 	int test_cursor = 0;
-	const char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm", "exynos", "tilcdc", "msm", "sti", "tegra", "imx-drm", "rockchip", "atmel-hlcdc" };
 	char *device = NULL;
 	char *module = NULL;
 	unsigned int i;
@@ -1604,29 +1603,9 @@ int main(int argc, char **argv)
 	if (!args)
 		encoders = connectors = crtcs = planes = framebuffers = 1;
 
-	if (module) {
-		dev.fd = drmOpen(module, device);
-		if (dev.fd < 0) {
-			fprintf(stderr, "failed to open device '%s'.\n", module);
-			return 1;
-		}
-	} else {
-		for (i = 0; i < ARRAY_SIZE(modules); i++) {
-			printf("trying to open device '%s'...", modules[i]);
-			dev.fd = drmOpen(modules[i], device);
-			if (dev.fd < 0) {
-				printf("failed.\n");
-			} else {
-				printf("success.\n");
-				break;
-			}
-		}
-
-		if (dev.fd < 0) {
-			fprintf(stderr, "no device found.\n");
-			return 1;
-		}
-	}
+	dev.fd = util_open(module, device);
+	if (dev.fd < 0)
+		return -1;
 
 	if (test_vsync && !page_flipping_supported()) {
 		fprintf(stderr, "page flipping not supported by drm.\n");
-- 
2.5.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-12-09 17:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 17:37 [PATCH libdrm 01/10] tests: Split helpers into library Thierry Reding
2015-12-09 17:37 ` [PATCH libdrm 02/10] tests: Move name tables to libutil Thierry Reding
2015-12-09 17:37 ` [PATCH libdrm 03/10] proptest: Add Android support Thierry Reding
2015-12-09 17:37 ` [PATCH libdrm 04/10] tests: Add libkms-test library Thierry Reding
2015-12-09 17:37 ` [PATCH libdrm 05/10] tests: kms: Implement CRTC stealing test Thierry Reding
2015-12-09 17:37 ` [PATCH libdrm 06/10] tests: kms: Implement universal planes test Thierry Reding
2015-12-09 17:37 ` [PATCH libdrm 07/10] tests: Add helper to open a device/module Thierry Reding
2015-12-09 17:37 ` Thierry Reding [this message]
2015-12-09 17:37 ` [PATCH libdrm 09/10] proptest: Use util_open() Thierry Reding
2015-12-09 17:37 ` [PATCH libdrm 10/10] vbltest: " Thierry Reding
2015-12-12 15:26 ` [PATCH libdrm 01/10] tests: Split helpers into library Emil Velikov
2015-12-14  8:12   ` Thierry Reding
2015-12-14 13:10     ` Emil Velikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449682668-22487-8-git-send-email-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=human.hwang@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox