[PATCH 4/5] Fix non PCI device probing

2012-03-03 Thread Sascha Hauer
When no devicename is found in the option then the driver probes
by PciInfo no matter if it's valid or not. Instead of doing this
use PciInfo only when it's valid and fall back to the devicename
otherwise. With devicename probing use open_hw() to fall back
on the KMSDEVICE environment variable or to the default device.

Signed-off-by: Sascha Hauer 
---
 src/driver.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/driver.c b/src/driver.c
index a9422a5..c7532d3 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -416,8 +416,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 if (ms->pEnt->location.type != BUS_PCI)
return FALSE;

-ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
-
 /* Allocate an entity private if necessary */
 if (xf86IsEntityShared(pScrn->entityList[0])) {
msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
@@ -463,8 +461,8 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 memcpy(ms->Options, Options, sizeof(Options));
 xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);

-devicename = xf86GetOptValString(ms->Options, OPTION_DEVICE_PATH);
-if (!devicename) {
+ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
+if (ms->PciInfo) {
BusID = malloc(64);
sprintf(BusID, "PCI:%d:%d:%d",
 #if XSERVER_LIBPCIACCESS
@@ -479,7 +477,8 @@ PreInit(ScrnInfoPtr pScrn, int flags)

ms->fd = drmOpen(NULL, BusID);
 } else {
-   ms->fd = open(devicename, O_RDWR, 0);
+   devicename = xf86GetOptValString(ms->Options, OPTION_DEVICE_PATH);
+   ms->fd = open_hw(devicename);
 }
 if (ms->fd < 0)
return FALSE;
-- 
1.7.9.1



[PATCH 4/5] Fix non PCI device probing

2012-03-03 Thread Sascha Hauer
When no devicename is found in the option then the driver probes
by PciInfo no matter if it's valid or not. Instead of doing this
use PciInfo only when it's valid and fall back to the devicename
otherwise. With devicename probing use open_hw() to fall back
on the KMSDEVICE environment variable or to the default device.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 src/driver.c |9 -
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/driver.c b/src/driver.c
index a9422a5..c7532d3 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -416,8 +416,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 if (ms-pEnt-location.type != BUS_PCI)
return FALSE;
 
-ms-PciInfo = xf86GetPciInfoForEntity(ms-pEnt-index);
-
 /* Allocate an entity private if necessary */
 if (xf86IsEntityShared(pScrn-entityList[0])) {
msEnt = xf86GetEntityPrivate(pScrn-entityList[0],
@@ -463,8 +461,8 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 memcpy(ms-Options, Options, sizeof(Options));
 xf86ProcessOptions(pScrn-scrnIndex, pScrn-options, ms-Options);
 
-devicename = xf86GetOptValString(ms-Options, OPTION_DEVICE_PATH);
-if (!devicename) {
+ms-PciInfo = xf86GetPciInfoForEntity(ms-pEnt-index);
+if (ms-PciInfo) {
BusID = malloc(64);
sprintf(BusID, PCI:%d:%d:%d,
 #if XSERVER_LIBPCIACCESS
@@ -479,7 +477,8 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 
ms-fd = drmOpen(NULL, BusID);
 } else {
-   ms-fd = open(devicename, O_RDWR, 0);
+   devicename = xf86GetOptValString(ms-Options, OPTION_DEVICE_PATH);
+   ms-fd = open_hw(devicename);
 }
 if (ms-fd  0)
return FALSE;
-- 
1.7.9.1

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