[PATCH v3 09/22] drm/bridge: simple-bridge: get/put the next bridge

Luca Ceresoli
2025-12-16T18:00:16Z

This driver obtains a bridge pointer from of_drm_find_bridge() in the probe
function and stores it until driver removal. of_drm_find_bridge() is
deprecated. Move to of_drm_find_and_get_bridge() for the bridge to be
refcounted and use bridge->next_bridge to put the reference on
deallocation.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
---
drivers/gpu/drm/bridge/simple-bridge.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
index 2cd1847ba776..873b32cfb508 100644
--- a/drivers/gpu/drm/bridge/simple-bridge.c
+++ b/drivers/gpu/drm/bridge/simple-bridge.c
@@ -31,7 +31,6 @@ struct simple_bridge {

const struct simple_bridge_info *info;

- struct drm_bridge *next_bridge;
struct regulator *vdd;
struct gpio_desc *enable;
};
@@ -54,8 +53,8 @@ static int simple_bridge_get_modes(struct drm_connector *connector)
const struct drm_edid *drm_edid;
int ret;

- if (sbridge->next_bridge->ops & DRM_BRIDGE_OP_EDID) {
- drm_edid = drm_bridge_edid_read(sbridge->next_bridge, connector);
+ if (sbridge->bridge.next_bridge->ops & DRM_BRIDGE_OP_EDID) {
+ drm_edid = drm_bridge_edid_read(sbridge->bridge.next_bridge, connector);
if (!drm_edid)
DRM_INFO("EDID read failed. Fallback to standard modes\n");
} else {
@@ -90,7 +89,7 @@ simple_bridge_connector_detect(struct drm_connector *connector, bool force)
{
struct simple_bridge *sbridge = drm_connector_to_simple_bridge(connector);

- return drm_bridge_detect(sbridge->next_bridge, connector);
+ return drm_bridge_detect(sbridge->bridge.next_bridge, connector);
}

static const struct drm_connector_funcs simple_bridge_con_funcs = {
@@ -109,7 +108,7 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
struct simple_bridge *sbridge = drm_bridge_to_simple_bridge(bridge);
int ret;

- ret = drm_bridge_attach(encoder, sbridge->next_bridge, bridge,
+ ret = drm_bridge_attach(encoder, sbridge->bridge.next_bridge, bridge,
DRM_BRIDGE_ATTACH_NO_CONNECTOR);
if (ret < 0)
return ret;
@@ -122,7 +121,7 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
ret = drm_connector_init_with_ddc(bridge->dev, &sbridge->connector,
&simple_bridge_con_funcs,
sbridge->info->connector_type,
- sbridge->next_bridge->ddc);
+ sbridge->bridge.next_bridge->ddc);
if (ret) {
DRM_ERROR("Failed to initialize connector\n");
return ret;
@@ -180,10 +179,10 @@ static int simple_bridge_probe(struct platform_device *pdev)
if (!remote)
return -EINVAL;

- sbridge->next_bridge = of_drm_find_bridge(remote);
+ sbridge->bridge.next_bridge = of_drm_find_and_get_bridge(remote);
of_node_put(remote);

- if (!sbridge->next_bridge) {
+ if (!sbridge->bridge.next_bridge) {
dev_dbg(&pdev->dev, "Next bridge not found, deferring probe\n");
return -EPROBE_DEFER;
}

--
2.52.0