drm/panel: add devm_drm_panel_add() helper

Add devm_drm_panel_add(), devres-managed version of drm_panel_add().
It's not uncommon for the panel drivers to use devres functions for most
of the resources. Provide corresponding replacement for drm_panel_add().

Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260413-waveshare-dsi-touch-v3-18-3aeb53022c32@oss.qualcomm.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
This commit is contained in:
Dmitry Baryshkov 2026-04-13 17:05:41 +03:00
parent 13414cfd48
commit e43a8e3ad8
2 changed files with 24 additions and 0 deletions

View File

@ -101,6 +101,29 @@ void drm_panel_remove(struct drm_panel *panel)
}
EXPORT_SYMBOL(drm_panel_remove);
static void drm_panel_add_release(void *data)
{
drm_panel_remove(data);
}
/**
* devm_drm_panel_add - add a panel to the global registry using devres
* @panel: panel to add
*
* Add a panel to the global registry so that it can be looked
* up by display drivers. The panel to be added must have been
* allocated by devm_drm_panel_alloc(). Unlike drm_panel_add() with this
* function there is no need to call drm_panel_remove(), it will be called
* automatically.
*/
int devm_drm_panel_add(struct device *dev, struct drm_panel *panel)
{
drm_panel_add(panel);
return devm_add_action_or_reset(dev, drm_panel_add_release, panel);
}
EXPORT_SYMBOL(devm_drm_panel_add);
/**
* drm_panel_prepare - power on a panel
* @panel: DRM panel

View File

@ -329,6 +329,7 @@ void drm_panel_put(struct drm_panel *panel);
void drm_panel_add(struct drm_panel *panel);
void drm_panel_remove(struct drm_panel *panel);
int devm_drm_panel_add(struct device *dev, struct drm_panel *panel);
void drm_panel_prepare(struct drm_panel *panel);
void drm_panel_unprepare(struct drm_panel *panel);