summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-03-03 14:09:24 +0100
committerDave Airlie <airlied@redhat.com>2012-03-05 15:18:36 +0000
commit90caeb0839a7bd0f0e49e6ad0d8bd948e1fd9faa (patch)
tree3ac9acdee948aea86c743644a3e6df310b192e92
parent2c2a3743347652a964315a91b1e7d066e90bfc6a (diff)
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 <s.hauer@pengutronix.de> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--src/driver.c19
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 *