dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Airlie <airlied@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH 1/5] drm/usb: add a busid implementation
Date: Mon, 20 Feb 2012 16:13:45 +0000	[thread overview]
Message-ID: <1329754429-5491-2-git-send-email-airlied@gmail.com> (raw)
In-Reply-To: <1329754429-5491-1-git-send-email-airlied@gmail.com>

From: Dave Airlie <airlied@redhat.com>

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

Signed-off-by: Dave Airlie <airlied@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

  reply	other threads:[~2012-02-20 16:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-20 16:13 initial displaylink kms driver + drm hotplug Dave Airlie
2012-02-20 16:13 ` Dave Airlie [this message]
2012-02-20 18:12   ` [PATCH 1/5] drm/usb: add a busid implementation Sascha Hauer
2012-02-20 16:13 ` [PATCH 2/5] drm/sysfs: protect sysfs removal code against being run twice Dave Airlie
2012-02-21  8:39   ` Daniel Vetter
2012-02-20 16:13 ` [PATCH 3/5] drm/modeset: add helper to unplug all connectors from sysfs Dave Airlie
2012-02-21  8:45   ` Daniel Vetter
2012-02-20 16:13 ` [PATCH 4/5] drm: add core support for unplugging a device Dave Airlie
2012-02-21  8:59   ` Daniel Vetter
2012-02-20 16:13 ` [PATCH 5/5] drm/udl: initial UDL driver (v4) Dave Airlie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329754429-5491-2-git-send-email-airlied@gmail.com \
    --to=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox