drm: Introduce drm_dev_set_unique()
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / gpu / drm / drm_stub.c
index fb3cb57..c7fc68d 100644 (file)
@@ -593,6 +593,7 @@ void drm_dev_free(struct drm_device *dev)
        drm_fs_inode_free(dev->anon_inode);
 
        mutex_destroy(&dev->master_mutex);
+       kfree(dev->unique);
        kfree(dev);
 }
 EXPORT_SYMBOL(drm_dev_free);
@@ -688,3 +689,28 @@ void drm_dev_unregister(struct drm_device *dev)
        drm_unplug_minor(dev->primary);
 }
 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
+ *
+ * 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.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int drm_dev_set_unique(struct drm_device *dev, const char *fmt, ...)
+{
+       va_list ap;
+
+       kfree(dev->unique);
+
+       va_start(ap, fmt);
+       dev->unique = kvasprintf(GFP_KERNEL, fmt, ap);
+       va_end(ap);
+
+       return dev->unique ? 0 : -ENOMEM;
+}
+EXPORT_SYMBOL(drm_dev_set_unique);