]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/panel: add devm_drm_panel_add() helper
authorDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Mon, 13 Apr 2026 14:05:41 +0000 (17:05 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Fri, 17 Apr 2026 23:10:37 +0000 (02:10 +0300)
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>
drivers/gpu/drm/drm_panel.c
include/drm/drm_panel.h

index d1e6598ea3bc02a8075428ce5825397d40f37c34..a6029b699b7305cc05a40e94a7afe845bfedb601 100644 (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
index 2407bfa60236f8a87c79f13c9cf2962646d75e05..1fb9148dd095761573273b9dc9e790d6ce5a0e6f 100644 (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);