diff mbox series

[v2,3/6] drm/debugfs: Create wrapper to add files to debugfs list

Message ID 20230130123008.287141-4-mcanal@igalia.com (mailing list archive)
State New, archived
Headers show
Series drm/debugfs: Make the debugfs structure more generic | expand

Commit Message

Maíra Canal Jan. 30, 2023, 12:30 p.m. UTC
Create a helper to encapsulate the code that adds a new debugfs file to
a linked list related to a object. Moreover, the helper also provides
more flexibily, as the parameter is a struct drm_debugfs_files.

Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 drivers/gpu/drm/drm_debugfs.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index aa83f230c402..0e3f3ffa9f88 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -236,6 +236,13 @@  void drm_debugfs_files_destroy(struct drm_debugfs_files *debugfs_files)
 	kfree(debugfs_files);
 }
 
+static void drm_debugfs_files_add(struct drm_debugfs_files *debugfs_files, struct list_head *entry)
+{
+	mutex_lock(&debugfs_files->mutex);
+	list_add(entry, &debugfs_files->list);
+	mutex_unlock(&debugfs_files->mutex);
+}
+
 int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 		     struct dentry *root)
 {
@@ -357,9 +364,7 @@  void drm_debugfs_add_file(struct drm_device *dev, const char *name,
 	entry->file.data = data;
 	entry->dev = dev;
 
-	mutex_lock(&dev->debugfs_files->mutex);
-	list_add(&entry->list, &dev->debugfs_files->list);
-	mutex_unlock(&dev->debugfs_files->mutex);
+	drm_debugfs_files_add(dev->debugfs_files, &entry->list);
 }
 EXPORT_SYMBOL(drm_debugfs_add_file);