From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: "Anusha Srivatsa" <asrivats@redhat.com>,
"Paul Kocialkowski" <paulk@sys-base.io>,
"Dmitry Baryshkov" <lumag@kernel.org>,
"Hervé Codina" <herve.codina@bootlin.com>,
"Hui Pu" <Hui.Pu@gehealthcare.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
"Luca Ceresoli" <luca.ceresoli@bootlin.com>
Subject: [PATCH v8 2/3] dmr/bridge: add a .destroy func
Date: Fri, 16 May 2025 18:48:38 +0200 [thread overview]
Message-ID: <20250516-drm-bridge-alloc-doc-test-v8-2-7e356fd58ba5@bootlin.com> (raw)
In-Reply-To: <20250516-drm-bridge-alloc-doc-test-v8-0-7e356fd58ba5@bootlin.com>
Some users of DRM bridges may need to execute specific code just before
deallocation.
As of now the only known user would be KUnit tests.
Suggested-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
This patch is new in v8. The .destroy callback had appeared in v5 as well
[5], but as part of a larger patch and for different reason that do not
apply anymore.
[5] https://lore.kernel.org/all/20241231-hotplug-drm-bridge-v5-3-173065a1ece1@bootlin.com/#t
---
drivers/gpu/drm/drm_bridge.c | 2 ++
include/drm/drm_bridge.h | 10 ++++++++++
2 files changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index b4c89ec01998b849018ce031c7cd84614e65e710..6185cb29fe3162264f0912c09c205fb467975dee 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -203,6 +203,8 @@ static void __drm_bridge_free(struct kref *kref)
{
struct drm_bridge *bridge = container_of(kref, struct drm_bridge, refcount);
+ if (bridge->funcs->destroy)
+ bridge->funcs->destroy(bridge);
kfree(bridge->container);
}
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 4e418a29a9ff9d014d6ac0910a5d9bcf7118195e..3ccd493faa580845c2ed1166f398eca27b464261 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -86,6 +86,16 @@ struct drm_bridge_funcs {
*/
void (*detach)(struct drm_bridge *bridge);
+ /**
+ * @destroy:
+ *
+ * This callback is invoked when the bridge is about to be
+ * deallocated.
+ *
+ * The @destroy callback is optional.
+ */
+ void (*destroy)(struct drm_bridge *bridge);
+
/**
* @mode_valid:
*
--
2.49.0
next prev parent reply other threads:[~2025-05-16 16:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 16:48 [PATCH v8 0/3] drm/bridge: add kunit tests for devm_drm_bridge_alloc() Luca Ceresoli
2025-05-16 16:48 ` [PATCH v8 1/3] drm/tests: bridge: convert to devm_drm_bridge_alloc() API Luca Ceresoli
2025-05-27 16:06 ` Maxime Ripard
2025-05-28 22:41 ` Anusha Srivatsa
2025-05-16 16:48 ` Luca Ceresoli [this message]
2025-05-22 15:43 ` [PATCH v8 2/3] dmr/bridge: add a .destroy func Maxime Ripard
2025-05-26 11:51 ` Luca Ceresoli
2025-05-28 22:46 ` Anusha Srivatsa
2025-05-16 16:48 ` [PATCH v8 3/3] drm/tests: bridge: add KUnit tests for devm_drm_bridge_alloc() Luca Ceresoli
2025-05-27 16:10 ` Maxime Ripard
2025-06-05 18:31 ` Luca Ceresoli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250516-drm-bridge-alloc-doc-test-v8-2-7e356fd58ba5@bootlin.com \
--to=luca.ceresoli@bootlin.com \
--cc=Hui.Pu@gehealthcare.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=asrivats@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=herve.codina@bootlin.com \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=lumag@kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=paulk@sys-base.io \
--cc=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--cc=thomas.petazzoni@bootlin.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).