From 2b6848fcb3f85f9ce18a6de1dc6c3ac047101aa8 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Sat, 3 Mar 2012 14:09:26 +0100 Subject: [PATCH] Fix non PCI device probing 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 Signed-off-by: Dave Airlie --- hw/xfree86/drivers/modesetting/driver.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c index dc90e04d6..45643a8e6 100644 --- a/hw/xfree86/drivers/modesetting/driver.c +++ b/hw/xfree86/drivers/modesetting/driver.c @@ -418,8 +418,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], @@ -465,8 +463,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 @@ -481,7 +479,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;