xf86drm: move the final linux specific bits out of drmGetDevices
Third and final piece of making drmGetDevices less crazy/ugly. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>main
parent
ef5192e9c7
commit
a250fceaaa
19
xf86drm.c
19
xf86drm.c
|
@ -2835,21 +2835,23 @@ char *drmGetRenderDeviceNameFromFd(int fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static int drmParseSubsystemType(const char *str)
|
static int drmParseSubsystemType(int maj, int min)
|
||||||
{
|
{
|
||||||
|
char path[PATH_MAX + 1];
|
||||||
char link[PATH_MAX + 1] = "";
|
char link[PATH_MAX + 1] = "";
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (readlink(str, link, PATH_MAX) < 0)
|
snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/subsystem",
|
||||||
return -EINVAL;
|
maj, min);
|
||||||
|
|
||||||
|
if (readlink(path, link, PATH_MAX) < 0)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
name = strrchr(link, '/');
|
name = strrchr(link, '/');
|
||||||
if (!name)
|
if (!name)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
name++;
|
if (strncmp(name, "/pci", 4) == 0)
|
||||||
|
|
||||||
if (strncmp(name, "pci", 3) == 0)
|
|
||||||
return DRM_BUS_PCI;
|
return DRM_BUS_PCI;
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -3001,7 +3003,6 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices)
|
||||||
struct dirent *dent = NULL;
|
struct dirent *dent = NULL;
|
||||||
struct stat sbuf = {0};
|
struct stat sbuf = {0};
|
||||||
char node[PATH_MAX + 1] = "";
|
char node[PATH_MAX + 1] = "";
|
||||||
char path[PATH_MAX + 1] = "";
|
|
||||||
int node_type, subsystem_type;
|
int node_type, subsystem_type;
|
||||||
int maj, min;
|
int maj, min;
|
||||||
int ret, i = 0, j, node_count, device_count = 0;
|
int ret, i = 0, j, node_count, device_count = 0;
|
||||||
|
@ -3033,9 +3034,7 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices)
|
||||||
if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
|
if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/subsystem",
|
subsystem_type = drmParseSubsystemType(maj, min);
|
||||||
maj, min);
|
|
||||||
subsystem_type = drmParseSubsystemType(path);
|
|
||||||
|
|
||||||
if (subsystem_type < 0)
|
if (subsystem_type < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue