drm: Branch 'master' - 2 commits
[email protected] (GitLab Mirror) Tue, 20 Nov 2018 04:37:15 +0000 (UTC)
| Newsgroups | gmane.comp.video.dri.patches |
|---|---|
| Message-ID | <[email protected]> |
xf86drm.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) New commits: commit 89700ab0aa73a85a90a2e1c2fd0d6857a0ee300d Author: Eric Anholt <[email protected]> Date: Thu Nov 15 17:52:19 2018 -0800 drm: Attempt to parse SPI devices as platform bus devices. For ARM systems with tinydrm displays attached to SPI, the bus name is /spi but we have platform device info for the rest. Fixes eglInitialize() failures on hx8357d since the EGL_EXT_device_drm changes. Acked-by: Eric Engestrom <[email protected]> diff --git a/xf86drm.c b/xf86drm.c index 60fbc49b..71ad54ba 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -2993,6 +2993,7 @@ static int drmParseSubsystemType(int maj, int min) { "/pci", DRM_BUS_PCI }, { "/usb", DRM_BUS_USB }, { "/platform", DRM_BUS_PLATFORM }, + { "/spi", DRM_BUS_PLATFORM }, { "/host1x", DRM_BUS_HOST1X }, { "/virtio", DRM_BUS_VIRTIO }, }; commit 9b28c5aea3a37dc6382a61fb65c97a9db6eeeac0 Author: Eric Anholt <[email protected]> Date: Thu Nov 15 17:48:53 2018 -0800 Avoid hardcoded strlens in drmParseSubsystemType(). Having people count characters is error-prone, when we could just have a computer do it. Reviewed-by: Eric Engestrom <[email protected]> diff --git a/xf86drm.c b/xf86drm.c index 10df682b..60fbc49b 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -59,6 +59,8 @@ #endif #include <math.h> +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + /* Not all systems have MAP_FAILED defined */ #ifndef MAP_FAILED #define MAP_FAILED ((void *)-1) @@ -2984,6 +2986,16 @@ static int drmParseSubsystemType(int maj, int min) char path[PATH_MAX + 1]; char link[PATH_MAX + 1] = ""; char *name; + struct { + const char *name; + int bus_type; + } bus_types[] = { + { "/pci", DRM_BUS_PCI }, + { "/usb", DRM_BUS_USB }, + { "/platform", DRM_BUS_PLATFORM }, + { "/host1x", DRM_BUS_HOST1X }, + { "/virtio", DRM_BUS_VIRTIO }, + }; snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/subsystem", maj, min); @@ -2995,20 +3007,10 @@ static int drmParseSubsystemType(int maj, int min) if (!name) return -EINVAL; - if (strncmp(name, "/pci", 4) == 0) - return DRM_BUS_PCI; - - if (strncmp(name, "/usb", 4) == 0) - return DRM_BUS_USB; - - if (strncmp(name, "/platform", 9) == 0) - return DRM_BUS_PLATFORM; - - if (strncmp(name, "/host1x", 7) == 0) - return DRM_BUS_HOST1X; - - if (strncmp(name, "/virtio", 7) == 0) - return DRM_BUS_VIRTIO; + for (unsigned i = 0; i < ARRAY_SIZE(bus_types); i++) { + if (strncmp(name, bus_types[i].name, strlen(bus_types[i].name)) == 0) + return bus_types[i].bus_type; + } return -EINVAL; #elif defined(__OpenBSD__) @@ -3149,7 +3151,6 @@ static int parse_separate_sysfs_files(int maj, int min, drmPciDeviceInfoPtr device, bool ignore_revision) { -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) static const char *attrs[] = { "revision", /* Older kernels are missing the file, so check for it first */ "vendor", --