[PATCH xf86-video-amdgpu 03/19] Use ODEV_ATTRIB_PATH where possible for the device node.

Emil Velikov emil.l.velikov at gmail.com
Wed Apr 4 14:29:38 UTC 2018


From: Emil Velikov <emil.velikov at collabora.com>

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/amdgpu_probe.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c
index e65c83b..78cc005 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:
@@ -117,18 +119,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
-- 
2.16.0



More information about the amd-gfx mailing list