Re: [PATCH 01/19] drm: debugfs: Remove all files automatically on cleanup

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

 



On Thu, Jan 26, 2017 at 11:56:03PM +0100, Noralf Trønnes wrote:
> Instead of having the drivers call drm_debugfs_remove_files() in
> their drm_driver->debugfs_cleanup hook, do it automatically by
> traversing minor->debugfs_list.
> Also use debugfs_remove_recursive() so drivers who add their own
> debugfs files don't have to keep track of them for removal.
> 
> Signed-off-by: Noralf Trønnes <noralf@xxxxxxxxxxx>
> ---
>  drivers/gpu/drm/drm_debugfs.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index 37fd612..04b0af3 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -81,7 +81,8 @@ static const struct file_operations drm_debugfs_fops = {
>   * \return Zero on success, non-zero on failure
>   *
>   * Create a given set of debugfs files represented by an array of
> - * gdm_debugfs_lists in the given root directory.
> + * &drm_info_list in the given root directory. These files will be removed
> + * automatically on drm_debugfs_cleanup().

I'm starting to feel guilty about asking you all this, but you're doing
great work so here we go: I just noticed that the comments here aren't
really kernel-doc, and that the drm_debugfs.[hc] stuff ins't pulled into
the sphinx documentation (which is why it's not checked). Would be really
awesome if you could add a chapter to gpu/drm-uapi.rst about debugfs
interfaces (with a big warning that it's not stable api and for debugging
only), and pull the kerneldoc for it (plus fix it to be properly parsing
kerenldoc)? Strictly optional :-)
-Daniel

>   */
>  int drm_debugfs_create_files(const struct drm_info_list *files, int count,
>  			     struct dentry *root, struct drm_minor *minor)
> @@ -218,6 +219,19 @@ int drm_debugfs_remove_files(const struct drm_info_list *files, int count,
>  }
>  EXPORT_SYMBOL(drm_debugfs_remove_files);
>  
> +static void drm_debugfs_remove_all_files(struct drm_minor *minor)
> +{
> +	struct drm_info_node *node, *tmp;
> +
> +	mutex_lock(&minor->debugfs_lock);
> +	list_for_each_entry_safe(node, tmp, &minor->debugfs_list, list) {
> +		debugfs_remove(node->dent);
> +		list_del(&node->list);
> +		kfree(node);
> +	}
> +	mutex_unlock(&minor->debugfs_lock);
> +}
> +
>  /**
>   * Cleanup the debugfs filesystem resources.
>   *
> @@ -245,9 +259,9 @@ int drm_debugfs_cleanup(struct drm_minor *minor)
>  		}
>  	}
>  
> -	drm_debugfs_remove_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, minor);
> +	drm_debugfs_remove_all_files(minor);
>  
> -	debugfs_remove(minor->debugfs_root);
> +	debugfs_remove_recursive(minor->debugfs_root);
>  	minor->debugfs_root = NULL;
>  
>  	return 0;
> -- 
> 2.10.2
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[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