drm: use dev_name as default unique name in drm_dev_alloc()
[cascardo/linux.git] / drivers / gpu / drm / drm_drv.c
index 9362609..bf934cd 100644 (file)
@@ -160,6 +160,11 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data,
                goto out_unlock;
        }
 
+       if (!file_priv->allowed_master) {
+               ret = drm_new_set_master(dev, file_priv);
+               goto out_unlock;
+       }
+
        file_priv->minor->master = drm_master_get(file_priv->master);
        file_priv->is_master = 1;
        if (dev->driver->master_set) {
@@ -628,8 +633,17 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver,
                }
        }
 
+       if (parent) {
+               ret = drm_dev_set_unique(dev, dev_name(parent));
+               if (ret)
+                       goto err_setunique;
+       }
+
        return dev;
 
+err_setunique:
+       if (drm_core_check_feature(dev, DRIVER_GEM))
+               drm_gem_destroy(dev);
 err_ctxbitmap:
        drm_legacy_ctxbitmap_cleanup(dev);
        drm_ht_remove(&dev->map_hash);
@@ -792,23 +806,18 @@ EXPORT_SYMBOL(drm_dev_unregister);
 /**
  * drm_dev_set_unique - Set the unique name of a DRM device
  * @dev: device of which to set the unique name
- * @fmt: format string for unique name
+ * @name: unique name
  *
- * Sets the unique name of a DRM device using the specified format string and
- * a variable list of arguments. Drivers can use this at driver probe time if
- * the unique name of the devices they drive is static.
+ * Sets the unique name of a DRM device using the specified string. Drivers
+ * can use this at driver probe time if the unique name of the devices they
+ * drive is static.
  *
  * Return: 0 on success or a negative error code on failure.
  */
-int drm_dev_set_unique(struct drm_device *dev, const char *fmt, ...)
+int drm_dev_set_unique(struct drm_device *dev, const char *name)
 {
-       va_list ap;
-
        kfree(dev->unique);
-
-       va_start(ap, fmt);
-       dev->unique = kvasprintf(GFP_KERNEL, fmt, ap);
-       va_end(ap);
+       dev->unique = kstrdup(name, GFP_KERNEL);
 
        return dev->unique ? 0 : -ENOMEM;
 }