summaryrefslogtreecommitdiffstats
path: root/src/drm-shim/drm_shim.c
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2020-02-10 16:15:58 +0200
committerMarge Bot <[email protected]>2020-04-03 21:14:18 +0000
commitc3e305616cbc53317bbace6f1f316c9167f14313 (patch)
tree6c520e5222faadf215719811235e2cfb56069636 /src/drm-shim/drm_shim.c
parentfa5a36dbd474fb3c755da51553c6ca18dab76a06 (diff)
drm-shim: return device platform as specified
v2: Embed the libdrm dependency inside the drm-shim dependency Signed-off-by: Lionel Landwerlin <[email protected]> Acked-by: Eric Anholt <[email protected]> (v1) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4429>
Diffstat (limited to 'src/drm-shim/drm_shim.c')
-rw-r--r--src/drm-shim/drm_shim.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/drm-shim/drm_shim.c b/src/drm-shim/drm_shim.c
index 381a94fb9d1..e6f7bf9e992 100644
--- a/src/drm-shim/drm_shim.c
+++ b/src/drm-shim/drm_shim.c
@@ -452,8 +452,26 @@ readlink(const char *path, char *buf, size_t size)
if (strcmp(path, subsystem_path) != 0)
return real_readlink(path, buf, size);
- strncpy(buf, "/platform", size);
- buf[size - 1] = 0;
+
+ static const struct {
+ const char *name;
+ int bus_type;
+ } bus_types[] = {
+ { "/pci", DRM_BUS_PCI },
+ { "/usb", DRM_BUS_USB },
+ { "/platform", DRM_BUS_PLATFORM },
+ { "/spi", DRM_BUS_PLATFORM },
+ { "/host1x", DRM_BUS_HOST1X },
+ };
+
+ for (uint32_t i = 0; i < ARRAY_SIZE(bus_types); i++) {
+ if (bus_types[i].bus_type != shim_device.bus_type)
+ continue;
+
+ strncpy(buf, bus_types[i].name, size);
+ buf[size - 1] = 0;
+ break;
+ }
return strlen(buf) + 1;
}