summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Velikov <emil.velikov@collabora.com>2016-12-10 14:28:19 +0000
committerEmil Velikov <emil.l.velikov@gmail.com>2020-03-16 14:24:50 +0000
commit0b3bc7addf9b5989bfad7c2c31979a15f5ba701d (patch)
tree0da7b41af37656041971c2cb86376ae31559e733
parentedcbe5f52ddfceee3d66d69bbcebbceac06b6d0d (diff)
Use ODEV_ATTRIB_PATH where possible for the device node.
Use the device node path, if the server knows it. Note: ODEV_ATTRIB_PATH was introduced with xserver 1.13 - the minimum version required to build amdgpu. Yet it's defined in xf86platformBus.h. With the header included only when XSERVER_PLATFORM_BUS is set. Keep things obvious and use a ODEV_ATTRIB_PATH guard. v2: Rebase, add commit message Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--src/amdgpu_probe.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c
index 2dc934f..7abe13d 100644
--- a/src/amdgpu_probe.c
+++ b/src/amdgpu_probe.c
@@ -33,6 +33,8 @@
#include <errno.h>
#include <string.h>
#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
/*
* Authors:
@@ -115,18 +117,28 @@ static int amdgpu_kernel_open_fd(ScrnInfoPtr pScrn,
struct xf86_platform_device *platform_dev)
{
struct pci_device *dev;
+ const char *path;
char *busid;
int fd;
-#ifdef ODEV_ATTRIB_FD
if (platform_dev) {
+#ifdef ODEV_ATTRIB_FD
fd = xf86_get_platform_device_int_attrib(platform_dev,
ODEV_ATTRIB_FD, -1);
if (fd != -1)
return fd;
- }
#endif
+#ifdef ODEV_ATTRIB_PATH
+ path = xf86_get_platform_device_attrib(platform_dev,
+ ODEV_ATTRIB_PATH);
+
+ fd = open(path, O_RDWR | O_CLOEXEC);
+ if (fd != -1)
+ return fd;
+#endif
+ }
+
if (platform_dev)
dev = platform_dev->pdev;
else