of_drm_find_bridge() is deprecated. Move to its replacement
of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it
is put when done.

Since the companion bridge pointer is used by many bridge funcs, putting
its reference in the remove function would be dangerous. Use .destroy to
put it on final deallocation.

Signed-off-by: Luca Ceresoli <[email protected]>

---

Changes in v2:
- put in .destroy, not in remove
---
 drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c 
b/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
index 122502968927..675995cbeb6b 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-ldb.c
@@ -62,6 +62,15 @@ static inline struct imx8qxp_ldb *base_to_imx8qxp_ldb(struct 
ldb *base)
        return container_of(base, struct imx8qxp_ldb, base);
 }
 
+static void imx8qxp_ldb_bridge_destroy(struct drm_bridge *bridge)
+{
+       struct ldb_channel *ldb_ch = bridge->driver_private;
+       struct ldb *ldb = ldb_ch->ldb;
+       struct imx8qxp_ldb *imx8qxp_ldb = base_to_imx8qxp_ldb(ldb);
+
+       drm_bridge_put(imx8qxp_ldb->companion);
+}
+
 static void imx8qxp_ldb_set_phy_cfg(struct imx8qxp_ldb *imx8qxp_ldb,
                                    unsigned long di_clk, bool is_split,
                                    struct phy_configure_opts_lvds *phy_cfg)
@@ -391,6 +400,7 @@ imx8qxp_ldb_bridge_mode_valid(struct drm_bridge *bridge,
 }
 
 static const struct drm_bridge_funcs imx8qxp_ldb_bridge_funcs = {
+       .destroy                = imx8qxp_ldb_bridge_destroy,
        .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
        .atomic_destroy_state   = drm_atomic_helper_bridge_destroy_state,
        .atomic_reset           = drm_atomic_helper_bridge_reset,
@@ -552,7 +562,7 @@ static int imx8qxp_ldb_parse_dt_companion(struct 
imx8qxp_ldb *imx8qxp_ldb)
                goto out;
        }
 
-       imx8qxp_ldb->companion = of_drm_find_bridge(companion_port);
+       imx8qxp_ldb->companion = of_drm_find_and_get_bridge(companion_port);
        if (!imx8qxp_ldb->companion) {
                ret = -EPROBE_DEFER;
                DRM_DEV_DEBUG_DRIVER(dev,

-- 
2.52.0

Reply via email to