On Wed, 11 Jan 2023, Maíra Canal <mcanal@xxxxxxxxxx> wrote: > Introduce the ability to add DRM debugfs files to a list managed by the > encoder and, during drm_encoder_register_all(), all added files will be > created at once. > > Moreover, introduce some typesafety as struct drm_debugfs_encoder_entry > holds a drm_encoder instead of a drm_device. So, the drivers can get > a encoder object directly from the struct drm_debugfs_encoder_entry > in the show() callback. > > Signed-off-by: Maíra Canal <mcanal@xxxxxxxxxx> > --- > drivers/gpu/drm/drm_debugfs.c | 36 ++++++++++++++++++++++++++++++++++ > drivers/gpu/drm/drm_encoder.c | 6 ++++++ > drivers/gpu/drm/drm_internal.h | 5 +++++ > include/drm/drm_debugfs.h | 26 ++++++++++++++++++++++++ > include/drm/drm_encoder.h | 15 ++++++++++++++ > 5 files changed, 88 insertions(+) > > diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c > index d9ec1ed5a7ec..6a763fe1b031 100644 > --- a/drivers/gpu/drm/drm_debugfs.c > +++ b/drivers/gpu/drm/drm_debugfs.c > @@ -36,6 +36,7 @@ > #include <drm/drm_device.h> > #include <drm/drm_drv.h> > #include <drm/drm_edid.h> > +#include <drm/drm_encoder.h> > #include <drm/drm_file.h> > #include <drm/drm_gem.h> > #include <drm/drm_managed.h> > @@ -271,6 +272,17 @@ void drm_debugfs_connector_init(struct drm_connector *connector) > drm_create_file_from_list(connector); > } > > +void drm_debugfs_encoder_init(struct drm_encoder *encoder) > +{ > + struct drm_minor *minor = encoder->dev->primary; > + struct drm_debugfs_encoder_entry *entry, *tmp; > + > + if (!minor) > + return; > + > + drm_create_file_from_list(encoder); > +} Because of the macro, this just looks like entry and tmp are unused local variables. > diff --git a/include/drm/drm_encoder.h b/include/drm/drm_encoder.h > index 3a09682af685..38b73f2a4e38 100644 > --- a/include/drm/drm_encoder.h > +++ b/include/drm/drm_encoder.h > @@ -182,6 +182,21 @@ struct drm_encoder { > */ > struct list_head bridge_chain; > > + /** > + * @debugfs_mutex: > + * > + * Protects &debugfs_list access. > + */ > + struct mutex debugfs_mutex; > + > + /** > + * @debugfs_list: > + * > + * List of debugfs files to be created by the DRM encoder. The files > + * must be added during drm_encoder_register_all(). > + */ > + struct list_head debugfs_list; > + If you added an additional struct wrapper for the above debugfs stuff (and actually defined it in a drm debugfs header where it belongs), and added that to encoder, connector, etc., you could pass a pointer to *that* to the drm_debugfs_add_file_to_list() and drm_create_file_from_list() proper functions. Less boilerplate, nicer functions, debugfs stuff grouped together and defined in the .[ch] they're used in. I think that would be much nicer. BR, Jani. > const struct drm_encoder_funcs *funcs; > const struct drm_encoder_helper_funcs *helper_private; > }; -- Jani Nikula, Intel Open Source Graphics Center