From: Dave Airlie <airl...@redhat.com>

This adds an implementation for the busid callback so userspace can distinguish
usb devices better.

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 drivers/gpu/drm/drm_usb.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
index 445003f..ca77aa6 100644
--- a/drivers/gpu/drm/drm_usb.c
+++ b/drivers/gpu/drm/drm_usb.c
@@ -85,7 +85,39 @@ static const char *drm_usb_get_name(struct drm_device *dev)
 static int drm_usb_set_busid(struct drm_device *dev,
                               struct drm_master *master)
 {
+       struct usb_driver *udriver = dev->driver->kdriver.usb;
+       int len, ret;
+
+       master->unique_len = 40;
+       master->unique_size = master->unique_len;
+       master->unique = kmalloc(master->unique_size, GFP_KERNEL);
+       if (master->unique == NULL)
+               return -ENOMEM;
+
+       len = snprintf(master->unique, master->unique_len,
+                      "usb:%s", dev_name(&dev->usbdev->dev));
+
+       if (len >= master->unique_len) {
+               DRM_ERROR("buffer overflow");
+               ret = -EINVAL;
+               goto err;
+       } else
+               master->unique_len = len;
+
+       dev->devname = kmalloc(strlen(udriver->name) +
+                              master->unique_len + 2, GFP_KERNEL);
+
+       if (dev->devname == NULL) {
+               ret = -ENOMEM;
+               goto err;
+       }
+
+       sprintf(dev->devname, "%s@%s", udriver->name,
+               master->unique);
+
        return 0;
+err:
+       return ret;
 }
 
 static struct drm_bus drm_usb_bus = {
-- 
1.7.6

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to