Skip to content

Commit 086f2e5

Browse files
notrodanvet
authored andcommitted
drm: debugfs: Remove all files automatically on cleanup
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 <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 73f1a58 commit 086f2e5

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

drivers/gpu/drm/drm_debugfs.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ static const struct file_operations drm_debugfs_fops = {
8181
* \return Zero on success, non-zero on failure
8282
*
8383
* Create a given set of debugfs files represented by an array of
84-
* gdm_debugfs_lists in the given root directory.
84+
* &drm_info_list in the given root directory. These files will be removed
85+
* automatically on drm_debugfs_cleanup().
8586
*/
8687
int drm_debugfs_create_files(const struct drm_info_list *files, int count,
8788
struct dentry *root, struct drm_minor *minor)
@@ -218,6 +219,19 @@ int drm_debugfs_remove_files(const struct drm_info_list *files, int count,
218219
}
219220
EXPORT_SYMBOL(drm_debugfs_remove_files);
220221

222+
static void drm_debugfs_remove_all_files(struct drm_minor *minor)
223+
{
224+
struct drm_info_node *node, *tmp;
225+
226+
mutex_lock(&minor->debugfs_lock);
227+
list_for_each_entry_safe(node, tmp, &minor->debugfs_list, list) {
228+
debugfs_remove(node->dent);
229+
list_del(&node->list);
230+
kfree(node);
231+
}
232+
mutex_unlock(&minor->debugfs_lock);
233+
}
234+
221235
/**
222236
* Cleanup the debugfs filesystem resources.
223237
*
@@ -245,9 +259,9 @@ int drm_debugfs_cleanup(struct drm_minor *minor)
245259
}
246260
}
247261

248-
drm_debugfs_remove_files(drm_debugfs_list, DRM_DEBUGFS_ENTRIES, minor);
262+
drm_debugfs_remove_all_files(minor);
249263

250-
debugfs_remove(minor->debugfs_root);
264+
debugfs_remove_recursive(minor->debugfs_root);
251265
minor->debugfs_root = NULL;
252266

253267
return 0;

0 commit comments

Comments
 (0)