From 456a001e3f7a24f443cf0bad8400d5d600e2ad46 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Sat, 3 Mar 2012 14:09:24 +0100 Subject: [PATCH] introduce open_hw() function probe_hw opens the hardware in the order we want it: first try devname, if this is NULL then try the KMSDEVICE environment variable and as a last fallback use "/dev/dri/card0". Instead of implementing the same code again when really opening the device move the code to a open_hw() function and let probe_hw use it. Signed-off-by: Sascha Hauer Signed-off-by: Dave Airlie --- hw/xfree86/drivers/modesetting/driver.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c index 2004434f2a..dc90e04d6b 100644 --- a/hw/xfree86/drivers/modesetting/driver.c +++ b/hw/xfree86/drivers/modesetting/driver.c @@ -174,7 +174,7 @@ Identify(int flags) Chipsets); } -static Bool probe_hw(char *dev) +static int open_hw(char *dev) { int fd; if (dev) @@ -186,13 +186,20 @@ static Bool probe_hw(char *dev) fd = open(dev,O_RDWR, 0); } } - if (fd == -1) { + if (fd == -1) xf86DrvMsg(-1, X_ERROR,"open %s: %s\n", dev, strerror(errno)); - return FALSE; - } - close(fd); - return TRUE; + return fd; +} + +static Bool probe_hw(char *dev) +{ + int fd = open_hw(dev); + if (fd != -1) { + close(fd); + return TRUE; + } + return FALSE; } static const OptionInfoRec *