[PATCH 2/5] introduce open_hw() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]




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 <s.hauer@xxxxxxxxxxxxxx>
---
 src/driver.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/driver.c b/src/driver.c
index 2004434..dc90e04 100644
--- a/src/driver.c
+++ b/src/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 *
-- 
1.7.9.1

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


[Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Video Projectors]     [PDAs]     [Free Online Dating]     [Linux Kernel]     [Linux SCSI]     [XFree86] [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Video Projectors]     [PDAs]     [Free Online Dating]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Devices]

Add to Google Powered by Linux