]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/bridge: add a .destroy func
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Fri, 6 Jun 2025 08:41:20 +0000 (10:41 +0200)
committerMaxime Ripard <mripard@kernel.org>
Fri, 6 Jun 2025 13:50:22 +0000 (15:50 +0200)
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>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Link: https://lore.kernel.org/r/20250606-drm-bridge-alloc-doc-test-v9-2-b5bf7b43ed92@bootlin.com
Signed-off-by: Maxime Ripard <mripard@kernel.org>
drivers/gpu/drm/drm_bridge.c
include/drm/drm_bridge.h

index d0e81639927a73422671b7b43f3e8a946f1d4300..bf34cc5ab0316889186ddf5ebb3a984b09eeb86c 100644 (file)
@@ -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);
 }
 
index ecdeb90e558651262cf4e0d4036889c8f210ab94..7f66f9018c1090642876ff948bbf06ca66a46bfe 100644 (file)
@@ -77,6 +77,16 @@ struct drm_bridge_funcs {
        int (*attach)(struct drm_bridge *bridge, struct drm_encoder *encoder,
                      enum drm_bridge_attach_flags flags);
 
+       /**
+        * @destroy:
+        *
+        * This callback is invoked when the bridge is about to be
+        * deallocated.
+        *
+        * The @destroy callback is optional.
+        */
+       void (*destroy)(struct drm_bridge *bridge);
+
        /**
         * @detach:
         *