[RFC 1/3] xfree86: Store kernel driver name in platform device attribute

Aaron Plattner aplattner at nvidia.com
Thu Feb 13 08:41:15 PST 2014


On 02/13/14 05:22, Thierry Reding wrote:
> When opening a DRM device, query the version and store the driver name
> as a new attribute for future reference.

Awesome, thanks for doing this!  Minor comments below.

> Signed-off-by: Thierry Reding <treding at nvidia.com>
> ---
>   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 1865b31b9d02..a42909aef219 100644
> --- a/hw/xfree86/os-support/linux/lnx_platform.c
> +++ b/hw/xfree86/os-support/linux/lnx_platform.c
> @@ -23,6 +23,7 @@ static Bool
>   get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
>   {
>       drmSetVersion sv;
> +    drmVersionPtr v;
>       char *buf;
>       int fd;
>       int err = 0;
> @@ -52,6 +53,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) {
> +        ErrorF("getversion failed\n");

I know there's precedent in this function, but this error message could 
use some more info.  Maybe something like this?

   xf86Msg(X_ERROR, "%s: failed to query DRM version\n", path);

Other than that,

Reviewed-by: Aaron Plattner <aplattner at nvidia.com>

> +        goto out;
> +    }
> +
> +    xf86_add_platform_device_attrib(delayed_index, ODEV_ATTRIB_DRIVER,
> +                                    v->name);
> +    drmFreeVersion(v);
> +
>   out:
>       close(fd);
>       return (err == 0);
> diff --git a/include/hotplug.h b/include/hotplug.h
> index 29a22c4daee0..95fdc6ebe621 100644
> --- a/include/hotplug.h
> +++ b/include/hotplug.h
> @@ -62,6 +62,8 @@ config_odev_free_attributes(struct OdevAttributes *attribs);
>   #define ODEV_ATTRIB_SYSPATH 2
>   /* DRI-style bus id */
>   #define ODEV_ATTRIB_BUSID 3
> +/* kernel driver name */
> +#define ODEV_ATTRIB_DRIVER 4
>
>   typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs);
>   void config_odev_probe(config_odev_probe_proc_ptr probe_callback);
>



More information about the xorg-devel mailing list