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>
This commit is contained in:
Emil Velikov
2016-12-10 14:28:19 +00:00
committed by Emil Velikov
parent edcbe5f52d
commit 0b3bc7addf

View File

@@ -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