[PATCH] drm: Provide drm_set_busid() fallback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Thierry Reding <treding@xxxxxxxxxx>

The only reason why struct drm_bus is still around is because the
SETVERSION IOCTL calls a bus specific .set_busid() function. This commit
provides a fallback implementation if a device either doesn't have a bus
associated with it or if it doesn't implement .set_busid(). The bus ID
will be set to the device's name as returned by dev_name().

This can be useful to create DRM devices directly in drivers using the
drm_dev_alloc() and drm_dev_register() functions rather than going
through the bus-specific implementations, with the goal of eventually
getting rid of drm_bus entirely.

Signed-off-by: Thierry Reding <treding@xxxxxxxxxx>
---
 drivers/gpu/drm/drm_ioctl.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 93a42040bedb..d27134a94d69 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -122,6 +122,19 @@ err:
 	return ret;
 }
 
+static int __drm_set_busid(struct drm_device *dev, struct drm_master *master)
+{
+	const char *name = dev_name(dev->dev);
+
+	master->unique = kstrdup(name, GFP_KERNEL);
+	if (!master->unique)
+		return -ENOMEM;
+
+	master->unique_len = strlen(name);
+
+	return 0;
+}
+
 static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
 {
 	struct drm_master *master = file_priv->master;
@@ -130,9 +143,16 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
 	if (master->unique != NULL)
 		drm_unset_busid(dev, master);
 
-	ret = dev->driver->bus->set_busid(dev, master);
-	if (ret)
-		goto err;
+	if (dev->driver->bus && dev->driver->bus->set_busid) {
+		ret = dev->driver->bus->set_busid(dev, master);
+		if (ret)
+			goto err;
+	} else {
+		ret = __drm_set_busid(dev, master);
+		if (ret)
+			goto err;
+	}
+
 	return 0;
 err:
 	drm_unset_busid(dev, master);
-- 
1.9.1

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




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux