[PATCH v2 RESEND 2/5] xfree86: Store kernel driver name in platform device attribute

Aaron Plattner aplattner at nvidia.com
Fri Mar 14 08:54:09 PDT 2014


From: Thierry Reding <treding at nvidia.com>

When opening a DRM device, query the version and store the driver name
as a new attribute for future reference.

Signed-off-by: Thierry Reding <treding at nvidia.com>
Reviewed-By: Aaron Plattner <aplattner at nvidia.com>
Tested-By: Aaron Plattner <aplattner at nvidia.com>
Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
[aplattner at nvidia.com: resolved against 5fb641a29bfb]
---
 hw/xfree86/os-support/linux/lnx_platform.c | 12 ++++++++++++
 include/hotplug.h                          |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c
index 109a9a77466d..9b57e595aff6 100644
--- a/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
@@ -24,6 +24,7 @@ static Bool
 get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
 {
     drmSetVersion sv;
+    drmVersionPtr v;
     char *buf;
     int major, minor, fd;
     int err = 0;
@@ -77,6 +78,17 @@ get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
     xf86_add_platform_device_attrib(delayed_index,
                                     ODEV_ATTRIB_BUSID, buf);
     drmFreeBusid(buf);
+
+    v = drmGetVersion(fd);
+    if (!v) {
+        xf86Msg(X_ERROR, "%s: failed to query DRM version\n", path);
+        goto out;
+    }
+
+    xf86_add_platform_device_attrib(delayed_index, ODEV_ATTRIB_DRIVER,
+                                    v->name);
+    drmFreeVersion(v);
+
 out:
     if (!server_fd)
         close(fd);
diff --git a/include/hotplug.h b/include/hotplug.h
index 1d9364eeec0c..7c52de124876 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -84,6 +84,8 @@ config_odev_free_attributes(struct OdevAttributes *attribs);
 #define ODEV_ATTRIB_MAJOR 5
 /* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */
 #define ODEV_ATTRIB_MINOR 6
+/* kernel driver name */
+#define ODEV_ATTRIB_DRIVER 7
 
 typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs);
 void config_odev_probe(config_odev_probe_proc_ptr probe_callback);
-- 
1.9.0



More information about the xorg-devel mailing list