All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Maíra Canal" <mcanal@igalia.com>
To: "Daniel Vetter" <daniel@ffwll.ch>,
	"David Airlie" <airlied@gmail.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Liviu Dudau" <liviu.dudau@arm.com>,
	"Brian Starkey" <brian.starkey@arm.com>,
	"Noralf Trønnes" <noralf@tronnes.org>,
	"Melissa Wen" <mwen@igalia.com>,
	"Rodrigo Siqueira" <rodrigosiqueiramelo@gmail.com>,
	"Jani Nikula" <jani.nikula@linux.intel.com>
Cc: "Maíra Canal" <mcanal@igalia.com>,
	"André Almeida" <andrealmeid@igalia.com>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH v3 4/6] drm/debugfs: Create wrapper to register debugfs
Date: Tue, 31 Jan 2023 16:58:24 -0300	[thread overview]
Message-ID: <20230131195825.677487-5-mcanal@igalia.com> (raw)
In-Reply-To: <20230131195825.677487-1-mcanal@igalia.com>

Create a helper to encapsulate the code that creates a new debugfs files
from a linked list related to an object. Moreover, the helper also
provides more flexibily on the type of the object.

Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 drivers/gpu/drm/drm_debugfs.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 0e3f3ffa9f88..b4d2e7dd87f5 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -243,11 +243,21 @@ static void drm_debugfs_files_add(struct drm_debugfs_files *debugfs_files, struc
 	mutex_unlock(&debugfs_files->mutex);
 }
 
+static void drm_debugfs_register(struct drm_minor *minor, struct drm_debugfs_files *debugfs_files)
+{
+	struct drm_debugfs_entry *entry, *tmp;
+
+	list_for_each_entry_safe(entry, tmp, &debugfs_files->list, list) {
+		debugfs_create_file(entry->file.name, 0444,
+				    minor->debugfs_root, entry, &drm_debugfs_entry_fops);
+		list_del(&entry->list);
+	}
+}
+
 int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 		     struct dentry *root)
 {
 	struct drm_device *dev = minor->dev;
-	struct drm_debugfs_entry *entry, *tmp;
 	char name[64];
 
 	INIT_LIST_HEAD(&minor->debugfs_list);
@@ -270,11 +280,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_files->list, list) {
-		debugfs_create_file(entry->file.name, 0444,
-				    minor->debugfs_root, entry, &drm_debugfs_entry_fops);
-		list_del(&entry->list);
-	}
+	drm_debugfs_register(minor, dev->debugfs_files);
 
 	return 0;
 }
@@ -282,16 +288,11 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
 void drm_debugfs_late_register(struct drm_device *dev)
 {
 	struct drm_minor *minor = dev->primary;
-	struct drm_debugfs_entry *entry, *tmp;
 
 	if (!minor)
 		return;
 
-	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);
-	}
+	drm_debugfs_register(minor, dev->debugfs_files);
 }
 
 int drm_debugfs_remove_files(const struct drm_info_list *files, int count,
-- 
2.39.1


  parent reply	other threads:[~2023-01-31 20:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31 19:58 [PATCH v3 0/6] drm/debugfs: Make the debugfs structure more generic Maíra Canal
2023-01-31 19:58 ` [PATCH v3 1/6] drm/debugfs: Introduce wrapper for debugfs list Maíra Canal
2023-02-08 18:06   ` Daniel Vetter
2023-02-08 18:19     ` Daniel Vetter
2023-02-08 18:39     ` Maíra Canal
2023-02-08 18:58       ` Daniel Vetter
2023-01-31 19:58 ` [PATCH v3 2/6] drm/debugfs: Make drm_device use the struct drm_debugfs_files Maíra Canal
2023-01-31 19:58 ` [PATCH v3 3/6] drm/debugfs: Create wrapper to add files to debugfs list Maíra Canal
2023-01-31 19:58 ` Maíra Canal [this message]
2023-01-31 19:58 ` [PATCH v3 5/6] drm/debugfs: Make the show callback pass the pointer to the right object Maíra Canal
2023-02-08 18:12   ` Daniel Vetter
2023-02-08 18:17     ` Daniel Vetter
2023-02-08 19:16       ` Maíra Canal
2023-01-31 19:58 ` [PATCH v3 6/6] drm/debugfs: Make the struct drm_debugfs_entry independent of DRM device Maíra Canal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230131195825.677487-5-mcanal@igalia.com \
    --to=mcanal@igalia.com \
    --cc=airlied@gmail.com \
    --cc=andrealmeid@igalia.com \
    --cc=brian.starkey@arm.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=liviu.dudau@arm.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=mwen@igalia.com \
    --cc=noralf@tronnes.org \
    --cc=rodrigosiqueiramelo@gmail.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.