All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: "Maíra Canal" <mcanal@igalia.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Alain Volmat" <alain.volmat@foss.st.com>
Cc: "Melissa Wen" <mwen@igalia.com>,
	"Maíra Canal" <mcanal@igalia.com>,
	"André Almeida" <andrealmeid@igalia.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 02/13] drm/debugfs: Create helper to create debugfs files from list
Date: Thu, 12 Jan 2023 10:53:33 +0200	[thread overview]
Message-ID: <87h6wwgmlu.fsf@intel.com> (raw)
In-Reply-To: <20230111173748.752659-3-mcanal@igalia.com>

On Wed, 11 Jan 2023, Maíra Canal <mcanal@igalia.com> wrote:
> Create a helper to encapsulate the code that creates a new debugfs file
> 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 | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index 255d2068ac16..23f6ed7b5d68 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -218,6 +218,16 @@ void drm_debugfs_create_files(const struct drm_info_list *files, int count,
>  }
>  EXPORT_SYMBOL(drm_debugfs_create_files);
>  
> +#define drm_create_file_from_list(component) do {					\
> +		list_for_each_entry_safe(entry, tmp, &(component)->debugfs_list,	\
> +					 list) {					\
> +			debugfs_create_file(entry->file.name, 0444,			\
> +					    minor->debugfs_root, entry,			\
> +					    &drm_debugfs_entry_fops);			\
> +			list_del(&entry->list);						\
> +		}									\
> +	} while (0)
> +

Same here as in the previous patch. I really think you should try to
figure out how to break this into useful functions, and avoid macros
like this.

BR,
Jani.

>  int drm_debugfs_init(struct drm_minor *minor, int minor_id,
>  		     struct dentry *root)
>  {
> @@ -245,11 +255,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) {
> -		debugfs_create_file(entry->file.name, 0444,
> -				    minor->debugfs_root, entry, &drm_debugfs_entry_fops);
> -		list_del(&entry->list);
> -	}
> +	drm_create_file_from_list(dev);
>  
>  	return 0;
>  }
> @@ -262,11 +268,7 @@ void drm_debugfs_late_register(struct drm_device *dev)
>  	if (!minor)
>  		return;
>  
> -	list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) {
> -		debugfs_create_file(entry->file.name, 0444,
> -				    minor->debugfs_root, entry, &drm_debugfs_entry_fops);
> -		list_del(&entry->list);
> -	}
> +	drm_create_file_from_list(dev);
>  }
>  
>  int drm_debugfs_remove_files(const struct drm_info_list *files, int count,

-- 
Jani Nikula, Intel Open Source Graphics Center

  reply	other threads:[~2023-01-12  8:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 17:37 [PATCH 00/13] drm/debugfs: Create a debugfs infrastructure for kms objects Maíra Canal
2023-01-11 17:37 ` [PATCH 01/13] drm/debugfs: Create helper to add debugfs files to device's list Maíra Canal
2023-01-12  8:50   ` Jani Nikula
2023-01-12  9:11     ` Daniel Vetter
2023-01-12  9:25       ` Jani Nikula
2023-01-11 17:37 ` [PATCH 02/13] drm/debugfs: Create helper to create debugfs files from list Maíra Canal
2023-01-12  8:53   ` Jani Nikula [this message]
2023-01-11 17:37 ` [PATCH 03/13] drm/debugfs: Create a debugfs infrastructure for connectors Maíra Canal
2023-01-12  9:07   ` Jani Nikula
2023-01-12  9:14   ` Daniel Vetter
2023-01-12  9:21     ` Jani Nikula
2023-01-11 17:37 ` [PATCH 04/13] drm/debugfs: Create a debugfs infrastructure for encoders Maíra Canal
2023-01-12  9:01   ` Jani Nikula
2023-01-11 17:37 ` [PATCH 05/13] drm/debugfs: Create a debugfs infrastructure for CRTC Maíra Canal
2023-01-11 17:37 ` [PATCH 06/13] drm/vc4: Split variable instantiation of vc4_debugfs_regset32() Maíra Canal
2023-01-11 17:37 ` [PATCH 07/13] drm/vc4: Use the encoders' debugfs infrastructure Maíra Canal
2023-01-12  9:19   ` Jani Nikula
2023-01-12  9:47     ` Daniel Vetter
2023-01-11 17:37 ` [PATCH 08/13] drm/vc4: Use the crtc's " Maíra Canal
2023-01-11 17:37 ` [PATCH 09/13] drm/sti: " Maíra Canal
2023-01-11 17:37 ` [PATCH 10/13] drm/sti: Use the connectors' " Maíra Canal
2023-01-11 17:37 ` [PATCH 11/13] drm/sti: Use the encoders' " Maíra Canal
2023-01-11 17:37 ` [PATCH 12/13] drm/debugfs: Remove the debugfs late register function Maíra Canal
2023-01-11 17:37 ` [PATCH 13/13] drm/todo: Update the debugfs clean up task 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=87h6wwgmlu.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=airlied@gmail.com \
    --cc=alain.volmat@foss.st.com \
    --cc=andrealmeid@igalia.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mcanal@igalia.com \
    --cc=mripard@kernel.org \
    --cc=mwen@igalia.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.