From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Biju Das <biju.das.jz@bp.renesas.com>,
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>,
Anitha Chrisanthus <anitha.chrisanthus@intel.com>,
Linus Walleij <linusw@kernel.org>,
Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>,
Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>,
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Hui Pu <Hui.Pu@gehealthcare.com>,
Ian Ray <ian.ray@gehealthcare.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
dri-devel@lists.freedesktop.org,
linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
Luca Ceresoli <luca.ceresoli@bootlin.com>
Subject: [PATCH v2 4/6] drm/mcde: dsi: convert to of_drm_find_and_get_bridge()
Date: Sat, 31 Jan 2026 16:58:36 +0100 [thread overview]
Message-ID: <20260131-drm-bridge-alloc-getput-drm_of_find_bridge-4-v2-4-e081bcdc1467@bootlin.com> (raw)
In-Reply-To: <20260131-drm-bridge-alloc-getput-drm_of_find_bridge-4-v2-0-e081bcdc1467@bootlin.com>
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.
We need to handle the two cases: when a panel is found and when it isn't,
even though the latter is not supported. So:
* in case a panel is not found and bridge is, get a reference to the
found bridge
* in case a panel is found, get a reference to the panel_bridge when it
is added, so the following code always get exactly one reference that
it needs to put
Finally, use the next_bridge pointer in struct drm_bridge in order to
simplify putting the reference.
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
Changes in v2:
- Removed drm_bridge_put(), not needed after the previous patch changes:
the loop cannot assign 'bridge' more than once now
- Not added Linus' R-by because of this change
---
drivers/gpu/drm/mcde/mcde_dsi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index 5893fd2681b3..47d45897ed06 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -40,7 +40,6 @@ struct mcde_dsi {
struct mcde *mcde;
struct drm_bridge bridge;
struct drm_panel *panel;
- struct drm_bridge *bridge_out;
struct mipi_dsi_host dsi_host;
struct mipi_dsi_device *mdsi;
const struct drm_display_mode *mode;
@@ -1060,7 +1059,7 @@ static int mcde_dsi_bridge_attach(struct drm_bridge *bridge,
}
/* Attach the DSI bridge to the output (panel etc) bridge */
- return drm_bridge_attach(encoder, d->bridge_out, bridge, flags);
+ return drm_bridge_attach(encoder, d->bridge.next_bridge, bridge, flags);
}
static const struct drm_bridge_funcs mcde_dsi_bridge_funcs = {
@@ -1076,7 +1075,7 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
struct mcde_dsi *d = dev_get_drvdata(dev);
struct device_node *child;
struct drm_panel *panel = NULL;
- struct drm_bridge *bridge = NULL;
+ struct drm_bridge *bridge __free(drm_bridge_put) = NULL;
if (!of_get_available_child_count(dev->of_node)) {
dev_info(dev, "unused DSI interface\n");
@@ -1109,7 +1108,7 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
PTR_ERR(panel));
panel = NULL;
- bridge = of_drm_find_bridge(child);
+ bridge = of_drm_find_and_get_bridge(child);
if (!bridge) {
dev_err(dev, "failed to find bridge\n");
of_node_put(child);
@@ -1129,6 +1128,7 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
dev_err(dev, "error adding panel bridge\n");
return PTR_ERR(bridge);
}
+ drm_bridge_get(bridge);
dev_info(dev, "connected to panel\n");
d->panel = panel;
} else if (bridge) {
@@ -1140,7 +1140,7 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
return -ENODEV;
}
- d->bridge_out = bridge;
+ d->bridge.next_bridge = drm_bridge_get(bridge);
/* Create a bridge for this DSI channel */
d->bridge.of_node = dev->of_node;
@@ -1160,7 +1160,7 @@ static void mcde_dsi_unbind(struct device *dev, struct device *master,
struct mcde_dsi *d = dev_get_drvdata(dev);
if (d->panel)
- drm_panel_bridge_remove(d->bridge_out);
+ drm_panel_bridge_remove(d->bridge.next_bridge);
regmap_update_bits(d->prcmu, PRCM_DSI_SW_RESET,
PRCM_DSI_SW_RESET_DSI0_SW_RESETN, 0);
}
--
2.52.0
next prev parent reply other threads:[~2026-01-31 15:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 15:58 [PATCH v2 0/6] drm/bridge: convert users of of_drm_find_bridge(), part 4 Luca Ceresoli
2026-01-31 15:58 ` [PATCH v2 1/6] drm: renesas: rz-du: rzg2l_du_encoder: convert to of_drm_find_and_get_bridge() Luca Ceresoli
2026-01-31 15:58 ` [PATCH v2 2/6] drm/kmb/dsi: " Luca Ceresoli
2026-01-31 15:58 ` [PATCH v2 3/6] drm/mcde: dsi: mcde_dsi_bind: break when a panel or bridge is found Luca Ceresoli
2026-02-03 0:00 ` Linus Walleij
2026-01-31 15:58 ` Luca Ceresoli [this message]
2026-02-03 0:01 ` [PATCH v2 4/6] drm/mcde: dsi: convert to of_drm_find_and_get_bridge() Linus Walleij
2026-01-31 15:58 ` [PATCH v2 5/6] drm: rcar-du: encoder: " Luca Ceresoli
2026-01-31 15:58 ` [PATCH v2 6/6] drm/omap: dss: " Luca Ceresoli
2026-02-23 9:25 ` (subset) [PATCH v2 0/6] drm/bridge: convert users of of_drm_find_bridge(), part 4 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=20260131-drm-bridge-alloc-getput-drm_of_find_bridge-4-v2-4-e081bcdc1467@bootlin.com \
--to=luca.ceresoli@bootlin.com \
--cc=Hui.Pu@gehealthcare.com \
--cc=airlied@gmail.com \
--cc=anitha.chrisanthus@intel.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert+renesas@glider.be \
--cc=ian.ray@gehealthcare.com \
--cc=kieran.bingham+renesas@ideasonboard.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=magnus.damm@gmail.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=thomas.petazzoni@bootlin.com \
--cc=tomi.valkeinen+renesas@ideasonboard.com \
--cc=tomi.valkeinen@ideasonboard.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
all inboxes | Powered by JetHome®