[PATCH v3 13/22] drm/bridge: imx8qxp-pxl2dpi: simplify put of device_node pointers

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

Simplify the error-management code in
imx8qxp_pxl2dpi_get_available_ep_from_port() by using a release action for
the struct device_node pointers.

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

diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
index 111310acab2c..a4941f39a2e6 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pxl2dpi.c
@@ -258,35 +258,28 @@ imx8qxp_pxl2dpi_get_available_ep_from_port(struct imx8qxp_pxl2dpi *p2d,
static struct drm_bridge *
imx8qxp_pxl2dpi_find_next_bridge(struct imx8qxp_pxl2dpi *p2d)
{
- struct device_node *ep, *remote;
struct drm_bridge *next_bridge;
int ret;

- ep = imx8qxp_pxl2dpi_get_available_ep_from_port(p2d, 1);
+ struct device_node *ep __free(device_node) =
+ imx8qxp_pxl2dpi_get_available_ep_from_port(p2d, 1);
if (IS_ERR(ep)) {
ret = PTR_ERR(ep);
return ERR_PTR(ret);
}

- remote = of_graph_get_remote_port_parent(ep);
+ struct device_node *remote __free(device_node) = of_graph_get_remote_port_parent(ep);
if (!remote || !of_device_is_available(remote)) {
DRM_DEV_ERROR(p2d->dev, "no available remote\n");
- next_bridge = ERR_PTR(-ENODEV);
- goto out;
+ return ERR_PTR(-ENODEV);
} else if (!of_device_is_available(remote->parent)) {
DRM_DEV_ERROR(p2d->dev, "remote parent is not available\n");
- next_bridge = ERR_PTR(-ENODEV);
- goto out;
+ return ERR_PTR(-ENODEV);
}

next_bridge = of_drm_find_bridge(remote);
- if (!next_bridge) {
- next_bridge = ERR_PTR(-EPROBE_DEFER);
- goto out;
- }
-out:
- of_node_put(remote);
- of_node_put(ep);
+ if (!next_bridge)
+ return ERR_PTR(-EPROBE_DEFER);

return next_bridge;
}

--
2.52.0