xf86drm: use maj/min in drmParsePciDeviceInfo()

Be consistent with drmParsePciBusInfo() and use solely the device
major/minor pair.

Cc: Jonathan Gray <jsg@jsg.id.au>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
main
Emil Velikov 2016-11-30 16:41:27 +00:00 committed by Emil Velikov
parent dae413e438
commit b40a65d448
1 changed files with 6 additions and 7 deletions

View File

@ -2946,7 +2946,7 @@ static int drmGetMaxNodeName(void)
3 /* length of the node number */; 3 /* length of the node number */;
} }
static int drmParsePciDeviceInfo(const char *d_name, static int drmParsePciDeviceInfo(int maj, int min,
drmPciDeviceInfoPtr device) drmPciDeviceInfoPtr device)
{ {
#ifdef __linux__ #ifdef __linux__
@ -2954,7 +2954,7 @@ static int drmParsePciDeviceInfo(const char *d_name,
unsigned char config[64]; unsigned char config[64];
int fd, ret; int fd, ret;
snprintf(path, PATH_MAX, "/sys/class/drm/%s/device/config", d_name); snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/config", maj, min);
fd = open(path, O_RDONLY); fd = open(path, O_RDONLY);
if (fd < 0) if (fd < 0)
return -errno; return -errno;
@ -2998,7 +2998,7 @@ void drmFreeDevices(drmDevicePtr devices[], int count)
drmFreeDevice(&devices[i]); drmFreeDevice(&devices[i]);
} }
static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name, static int drmProcessPciDevice(drmDevicePtr *device,
const char *node, int node_type, const char *node, int node_type,
int maj, int min, bool fetch_deviceinfo) int maj, int min, bool fetch_deviceinfo)
{ {
@ -3039,7 +3039,7 @@ static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name,
addr += sizeof(drmPciBusInfo); addr += sizeof(drmPciBusInfo);
(*device)->deviceinfo.pci = (drmPciDeviceInfoPtr)addr; (*device)->deviceinfo.pci = (drmPciDeviceInfoPtr)addr;
ret = drmParsePciDeviceInfo(d_name, (*device)->deviceinfo.pci); ret = drmParsePciDeviceInfo(maj, min, (*device)->deviceinfo.pci);
if (ret) if (ret)
goto free_device; goto free_device;
} }
@ -3142,8 +3142,7 @@ int drmGetDevice(int fd, drmDevicePtr *device)
switch (subsystem_type) { switch (subsystem_type) {
case DRM_BUS_PCI: case DRM_BUS_PCI:
ret = drmProcessPciDevice(&d, dent->d_name, node, node_type, ret = drmProcessPciDevice(&d, node, node_type, maj, min, true);
maj, min, true);
if (ret) if (ret)
goto free_devices; goto free_devices;
@ -3251,7 +3250,7 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices)
switch (subsystem_type) { switch (subsystem_type) {
case DRM_BUS_PCI: case DRM_BUS_PCI:
ret = drmProcessPciDevice(&device, dent->d_name, node, node_type, ret = drmProcessPciDevice(&device, node, node_type,
maj, min, devices != NULL); maj, min, devices != NULL);
if (ret) if (ret)
goto free_devices; goto free_devices;