xf86drm: generalize the device subsystem type parsing code
Move the code, which used to get the device subsystem type from a device path in sysfs, to a separate function to be reusable. Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com> Signed-off-by: Mikhail Golubev <Mikhail.Golubev@opensynergy.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>main
parent
2c0a01261d
commit
c4eae71d7e
21
xf86drm.c
21
xf86drm.c
|
@ -2964,10 +2964,10 @@ sysfs_uevent_get(const char *path, const char *fmt, ...)
|
||||||
/* Little white lie to avoid major rework of the existing code */
|
/* Little white lie to avoid major rework of the existing code */
|
||||||
#define DRM_BUS_VIRTIO 0x10
|
#define DRM_BUS_VIRTIO 0x10
|
||||||
|
|
||||||
static int drmParseSubsystemType(int maj, int min)
|
|
||||||
{
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
char path[PATH_MAX + 1];
|
static int get_subsystem_type(const char *device_path)
|
||||||
|
{
|
||||||
|
char path[PATH_MAX + 1] = "";
|
||||||
char link[PATH_MAX + 1] = "";
|
char link[PATH_MAX + 1] = "";
|
||||||
char *name;
|
char *name;
|
||||||
struct {
|
struct {
|
||||||
|
@ -2982,8 +2982,8 @@ static int drmParseSubsystemType(int maj, int min)
|
||||||
{ "/virtio", DRM_BUS_VIRTIO },
|
{ "/virtio", DRM_BUS_VIRTIO },
|
||||||
};
|
};
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/subsystem",
|
strncpy(path, device_path, PATH_MAX);
|
||||||
maj, min);
|
strncat(path, "/subsystem", PATH_MAX);
|
||||||
|
|
||||||
if (readlink(path, link, PATH_MAX) < 0)
|
if (readlink(path, link, PATH_MAX) < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
@ -2998,6 +2998,17 @@ static int drmParseSubsystemType(int maj, int min)
|
||||||
}
|
}
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int drmParseSubsystemType(int maj, int min)
|
||||||
|
{
|
||||||
|
#ifdef __linux__
|
||||||
|
char path[PATH_MAX + 1] = "";
|
||||||
|
|
||||||
|
snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device", maj, min);
|
||||||
|
|
||||||
|
return get_subsystem_type(path);
|
||||||
#elif defined(__OpenBSD__) || defined(__DragonFly__)
|
#elif defined(__OpenBSD__) || defined(__DragonFly__)
|
||||||
return DRM_BUS_PCI;
|
return DRM_BUS_PCI;
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue