diff mbox

[RFC,3/4] drm: Create driver specific root directory inside drmfs

Message ID 1480935972-6005-4-git-send-email-swati.dhingra@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

swati.dhingra@intel.com Dec. 5, 2016, 11:06 a.m. UTC
From: Sourab Gupta <sourab.gupta@intel.com>

A driver specific directory is created inside drmfs root, and dentry of
this directory is saved for subsequent use by the driver (e.g. i915).
The driver can then create files/directories inside this root directory
directly.

In case of i915 driver, the top directory is created at '/sys/kernel/drm/i915'.

Signed-off-by: Sourab Gupta <sourab.gupta@intel.com>
Signed-off-by: Swati Dhingra <swati.dhingra@intel.com>
---
 drivers/gpu/drm/drm_drv.c | 6 ++++++
 include/drm/drm_drv.h     | 3 +++
 2 files changed, 9 insertions(+)
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 298013c..4c32cf8 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -671,6 +671,11 @@  EXPORT_SYMBOL(drm_dev_unref);
 int drm_dev_register(struct drm_device *dev, unsigned long flags)
 {
 	int ret;
+	struct dentry *drmfs_root;
+
+	drmfs_root = drmfs_create_dir(dev->driver->name, NULL);
+	if (!IS_ERR(drmfs_root))
+		dev->driver->drmfs_root = drmfs_root;
 
 	mutex_lock(&drm_global_mutex);
 
@@ -742,6 +747,7 @@  void drm_dev_unregister(struct drm_device *dev)
 	drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
 	drm_minor_unregister(dev, DRM_MINOR_RENDER);
 	drm_minor_unregister(dev, DRM_MINOR_CONTROL);
+	drmfs_remove(dev->driver->drmfs_root);
 }
 EXPORT_SYMBOL(drm_dev_unregister);
 
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index c4fc495..d646296 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -405,6 +405,9 @@  struct drm_driver {
 
 	/* List of devices hanging off this driver with stealth attach. */
 	struct list_head legacy_dev_list;
+
+	/* drmfs parent directory dentry for this driver */
+	struct dentry *drmfs_root;
 };
 
 extern __printf(6, 7)