From 9d66abea4812d6986f5d0a8f0ab2e50a5973987d Mon Sep 17 00:00:00 2001 From: Alexei Colin Date: Fri, 26 Dec 2014 23:42:31 -0500 Subject: [PATCH 1/2] xfree86: a helper func for finding device by bus ID --- hw/xfree86/common/xf86platformBus.c | 43 ++++++++++++++++++++++--------------- hw/xfree86/common/xf86platformBus.h | 2 ++ 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c index 15988b8..336305c 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -117,6 +117,28 @@ xf86IsPrimaryPlatform(struct xf86_platform_device *plat) return ((primaryBus.type == BUS_PLATFORM) && (plat == primaryBus.id.plat)); } +struct xf86_platform_device * +xf86_find_platform_device_by_busid(const char *busID) +{ + int j; + for (j = 0; j < xf86_num_platform_devices; j++) { + if (busID && *busID) { + if (xf86PlatformDeviceCheckBusID(&xf86_platform_devices[j], busID)) + break; + } else { + /* for non-seat0 servers assume first device is the master */ + if (ServerIsNotSeat0()) + break; + + if (xf86IsPrimaryPlatform(&xf86_platform_devices[j])) + break; + } + } + if (j != xf86_num_platform_devices) + return &xf86_platform_devices[j]; + return NULL; +} + static void platform_find_pci_info(struct xf86_platform_device *pd, char *busid) { @@ -423,28 +445,15 @@ xf86platformProbeDev(DriverPtr drvp) GDevPtr *devList; const unsigned numDevs = xf86MatchDevice(drvp->driverName, &devList); int i, j; + struct xf86_platform_device *dev; /* find the main device or any device specificed in xorg.conf */ for (i = 0; i < numDevs; i++) { - for (j = 0; j < xf86_num_platform_devices; j++) { - if (devList[i]->busID && *devList[i]->busID) { - if (xf86PlatformDeviceCheckBusID(&xf86_platform_devices[j], devList[i]->busID)) - break; - } - else { - /* for non-seat0 servers assume first device is the master */ - if (ServerIsNotSeat0()) - break; - - if (xf86IsPrimaryPlatform(&xf86_platform_devices[j])) - break; - } - } - - if (j == xf86_num_platform_devices) + dev = xf86_find_platform_device_by_busid(devList[i]->busID); + if (!dev) continue; - foundScreen = probeSingleDevice(&xf86_platform_devices[j], drvp, devList[i], 0); + foundScreen = probeSingleDevice(dev, drvp, devList[i], 0); if (!foundScreen) continue; } diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h index a7335b9..073051c 100644 --- a/hw/xfree86/common/xf86platformBus.h +++ b/hw/xfree86/common/xf86platformBus.h @@ -51,6 +51,8 @@ extern int xf86_remove_platform_device(int dev_index); extern Bool xf86_get_platform_device_unowned(int index); +extern struct xf86_platform_device * +xf86_find_platform_device_by_busid(const char *busID); extern int xf86platformAddDevice(int index); -- 2.2.1