Message ID | 20230116102815.95063-4-mcanal@igalia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/debugfs: Make the debugfs structure more generic | expand |
On Mon, 16 Jan 2023, Maíra Canal <mcanal@igalia.com> wrote: > 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_list. > > Signed-off-by: Maíra Canal <mcanal@igalia.com> > --- > drivers/gpu/drm/drm_debugfs.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c > index 176b0f8614e5..aca460fa5d23 100644 > --- a/drivers/gpu/drm/drm_debugfs.c > +++ b/drivers/gpu/drm/drm_debugfs.c > @@ -229,6 +229,13 @@ void drm_debugfs_list_destroy(struct drm_debugfs_list *debugfs_list) > mutex_destroy(&debugfs_list->mutex); > } > > +static void drm_debugfs_list_add(struct list_head *entry, struct drm_debugfs_list *debugfs_list) Although list_add() has the arguments backwards, the type safety here would let us have the destination parameter first without confusing anyone. BR, Jani. > +{ > + mutex_lock(&debugfs_list->mutex); > + list_add(entry, &debugfs_list->list); > + mutex_unlock(&debugfs_list->mutex); > +} > + > int drm_debugfs_init(struct drm_minor *minor, int minor_id, > struct dentry *root) > { > @@ -350,9 +357,7 @@ void drm_debugfs_add_file(struct drm_device *dev, const char *name, > entry->file.data = data; > entry->dev = dev; > > - mutex_lock(&dev->debugfs_list.mutex); > - list_add(&entry->list, &dev->debugfs_list.list); > - mutex_unlock(&dev->debugfs_list.mutex); > + drm_debugfs_list_add(&entry->list, &dev->debugfs_list); > } > EXPORT_SYMBOL(drm_debugfs_add_file);
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 176b0f8614e5..aca460fa5d23 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -229,6 +229,13 @@ void drm_debugfs_list_destroy(struct drm_debugfs_list *debugfs_list) mutex_destroy(&debugfs_list->mutex); } +static void drm_debugfs_list_add(struct list_head *entry, struct drm_debugfs_list *debugfs_list) +{ + mutex_lock(&debugfs_list->mutex); + list_add(entry, &debugfs_list->list); + mutex_unlock(&debugfs_list->mutex); +} + int drm_debugfs_init(struct drm_minor *minor, int minor_id, struct dentry *root) { @@ -350,9 +357,7 @@ void drm_debugfs_add_file(struct drm_device *dev, const char *name, entry->file.data = data; entry->dev = dev; - mutex_lock(&dev->debugfs_list.mutex); - list_add(&entry->list, &dev->debugfs_list.list); - mutex_unlock(&dev->debugfs_list.mutex); + drm_debugfs_list_add(&entry->list, &dev->debugfs_list); } EXPORT_SYMBOL(drm_debugfs_add_file);
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_list. Signed-off-by: Maíra Canal <mcanal@igalia.com> --- drivers/gpu/drm/drm_debugfs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)