aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Jackson2017-05-04 09:48:56 -0500
committerAdam Jackson2017-05-04 13:36:25 -0500
commit7c27cd7c5da0b87cea0dacd454307e2613d3b415 (patch)
tree27f1e68b8c4746f6e3c93f56c36041d75a0bd99e /xf86drm.c
parent00aa2c18810efb896afd9ff0acbadd4aa9540fe6 (diff)
downloadexternal-libgbm-7c27cd7c5da0b87cea0dacd454307e2613d3b415.tar.gz
external-libgbm-7c27cd7c5da0b87cea0dacd454307e2613d3b415.tar.xz
external-libgbm-7c27cd7c5da0b87cea0dacd454307e2613d3b415.zip
Export drmDevicesEqual
drmCompareBusInfo was almost this already, but it wasn't exported, its name didn't match its functionality, and while it almost looks like it was usable for sorting due to memcmp it wouldn't work if you had multiple bus types. I don't really want to think about defining a sensible sort order for bus types, so let's at least make it less of a trap for the caller. Invert its boolean sense to be 'true if equal', rename it to describe the types it actually operates on, and export. Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Emil Velikov <emil.velilkov@collabora.com> Signed-off-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'xf86drm.c')
-rw-r--r--xf86drm.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/xf86drm.c b/xf86drm.c
index 685cf69d..29fea331 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3029,32 +3029,32 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
3029#endif 3029#endif
3030} 3030}
3031 3031
3032static int drmCompareBusInfo(drmDevicePtr a, drmDevicePtr b) 3032int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b)
3033{ 3033{
3034 if (a == NULL || b == NULL) 3034 if (a == NULL || b == NULL)
3035 return -1; 3035 return 0;
3036 3036
3037 if (a->bustype != b->bustype) 3037 if (a->bustype != b->bustype)
3038 return -1; 3038 return 0;
3039 3039
3040 switch (a->bustype) { 3040 switch (a->bustype) {
3041 case DRM_BUS_PCI: 3041 case DRM_BUS_PCI:
3042 return memcmp(a->businfo.pci, b->businfo.pci, sizeof(drmPciBusInfo)); 3042 return memcmp(a->businfo.pci, b->businfo.pci, sizeof(drmPciBusInfo)) == 0;
3043 3043
3044 case DRM_BUS_USB: 3044 case DRM_BUS_USB:
3045 return memcmp(a->businfo.usb, b->businfo.usb, sizeof(drmUsbBusInfo)); 3045 return memcmp(a->businfo.usb, b->businfo.usb, sizeof(drmUsbBusInfo)) == 0;
3046 3046
3047 case DRM_BUS_PLATFORM: 3047 case DRM_BUS_PLATFORM:
3048 return memcmp(a->businfo.platform, b->businfo.platform, sizeof(drmPlatformBusInfo)); 3048 return memcmp(a->businfo.platform, b->businfo.platform, sizeof(drmPlatformBusInfo)) == 0;
3049 3049
3050 case DRM_BUS_HOST1X: 3050 case DRM_BUS_HOST1X:
3051 return memcmp(a->businfo.host1x, b->businfo.host1x, sizeof(drmHost1xBusInfo)); 3051 return memcmp(a->businfo.host1x, b->businfo.host1x, sizeof(drmHost1xBusInfo)) == 0;
3052 3052
3053 default: 3053 default:
3054 break; 3054 break;
3055 } 3055 }
3056 3056
3057 return -1; 3057 return 0;
3058} 3058}
3059 3059
3060static int drmGetNodeType(const char *name) 3060static int drmGetNodeType(const char *name)
@@ -3669,7 +3669,7 @@ static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count)
3669 3669
3670 for (i = 0; i < count; i++) { 3670 for (i = 0; i < count; i++) {
3671 for (j = i + 1; j < count; j++) { 3671 for (j = i + 1; j < count; j++) {
3672 if (drmCompareBusInfo(local_devices[i], local_devices[j]) == 0) { 3672 if (drmCompareDevices(local_devices[i], local_devices[j])) {
3673 local_devices[i]->available_nodes |= local_devices[j]->available_nodes; 3673 local_devices[i]->available_nodes |= local_devices[j]->available_nodes;
3674 node_type = log2(local_devices[j]->available_nodes); 3674 node_type = log2(local_devices[j]->available_nodes);
3675 memcpy(local_devices[i]->nodes[node_type], 3675 memcpy(local_devices[i]->nodes[node_type],