[PATCH v3 2/6] drm/debugfs: Make drm_device use the struct drm_debugfs_files

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

 



The struct drm_debugfs_files encapsulates all the debugfs-related
objects, so that they can be initialized and destroyed with two helpers.
Therefore, make the struct drm_device use the struct drm_debugfs_files
instead of instantiating the debugfs list and mutex separated.

Signed-off-by: Maíra Canal <mcanal@xxxxxxxxxx>
---
 drivers/gpu/drm/drm_debugfs.c | 10 +++++-----
 drivers/gpu/drm/drm_drv.c     |  7 ++++---
 include/drm/drm_device.h      | 12 +++---------
 3 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 8658d3929ea5..aa83f230c402 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -263,7 +263,7 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 	if (dev->driver->debugfs_init)
 		dev->driver->debugfs_init(minor);
 
-	list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) {
+	list_for_each_entry_safe(entry, tmp, &dev->debugfs_files->list, list) {
 		debugfs_create_file(entry->file.name, 0444,
 				    minor->debugfs_root, entry, &drm_debugfs_entry_fops);
 		list_del(&entry->list);
@@ -280,7 +280,7 @@ void drm_debugfs_late_register(struct drm_device *dev)
 	if (!minor)
 		return;
 
-	list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) {
+	list_for_each_entry_safe(entry, tmp, &dev->debugfs_files->list, list) {
 		debugfs_create_file(entry->file.name, 0444,
 				    minor->debugfs_root, entry, &drm_debugfs_entry_fops);
 		list_del(&entry->list);
@@ -357,9 +357,9 @@ void drm_debugfs_add_file(struct drm_device *dev, const char *name,
 	entry->file.data = data;
 	entry->dev = dev;
 
-	mutex_lock(&dev->debugfs_mutex);
-	list_add(&entry->list, &dev->debugfs_list);
-	mutex_unlock(&dev->debugfs_mutex);
+	mutex_lock(&dev->debugfs_files->mutex);
+	list_add(&entry->list, &dev->debugfs_files->list);
+	mutex_unlock(&dev->debugfs_files->mutex);
 }
 EXPORT_SYMBOL(drm_debugfs_add_file);
 
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index c6eb8972451a..50812cbe1d81 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -39,6 +39,7 @@
 #include <drm/drm_cache.h>
 #include <drm/drm_client.h>
 #include <drm/drm_color_mgmt.h>
+#include <drm/drm_debugfs.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_file.h>
 #include <drm/drm_managed.h>
@@ -598,7 +599,7 @@ static void drm_dev_init_release(struct drm_device *dev, void *res)
 	mutex_destroy(&dev->clientlist_mutex);
 	mutex_destroy(&dev->filelist_mutex);
 	mutex_destroy(&dev->struct_mutex);
-	mutex_destroy(&dev->debugfs_mutex);
+	drm_debugfs_files_destroy(dev->debugfs_files);
 	drm_legacy_destroy_members(dev);
 }
 
@@ -639,14 +640,14 @@ static int drm_dev_init(struct drm_device *dev,
 	INIT_LIST_HEAD(&dev->filelist_internal);
 	INIT_LIST_HEAD(&dev->clientlist);
 	INIT_LIST_HEAD(&dev->vblank_event_list);
-	INIT_LIST_HEAD(&dev->debugfs_list);
 
 	spin_lock_init(&dev->event_lock);
 	mutex_init(&dev->struct_mutex);
 	mutex_init(&dev->filelist_mutex);
 	mutex_init(&dev->clientlist_mutex);
 	mutex_init(&dev->master_mutex);
-	mutex_init(&dev->debugfs_mutex);
+
+	dev->debugfs_files = drm_debugfs_files_init();
 
 	ret = drmm_add_action_or_reset(dev, drm_dev_init_release, NULL);
 	if (ret)
diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index 7cf4afae2e79..77290f4a06ff 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -16,6 +16,7 @@ struct drm_vblank_crtc;
 struct drm_vma_offset_manager;
 struct drm_vram_mm;
 struct drm_fb_helper;
+struct drm_debugfs_files;
 
 struct inode;
 
@@ -312,19 +313,12 @@ struct drm_device {
 	struct drm_fb_helper *fb_helper;
 
 	/**
-	 * @debugfs_mutex:
-	 *
-	 * Protects &debugfs_list access.
-	 */
-	struct mutex debugfs_mutex;
-
-	/**
-	 * @debugfs_list:
+	 * @debugfs_files:
 	 *
 	 * List of debugfs files to be created by the DRM device. The files
 	 * must be added during drm_dev_register().
 	 */
-	struct list_head debugfs_list;
+	struct drm_debugfs_files *debugfs_files;
 
 	/* Everything below here is for legacy driver, never use! */
 	/* private: */
-- 
2.39.1




[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