From 97c594f71fa71dc30a0583a76d8b6ef5c5ea10b1 Mon Sep 17 00:00:00 2001 From: Luca Ceresoli Date: Fri, 14 Aug 2026 16:05:50 +0200 Subject: [PATCH] drm: of: drm_of_find_panel_or_bridge: simplify error return paths In prepataion to further modify the logic of this function, simplify the error-returning code. With this change, on any error there is an immediate 'return -;' statement, without having to carry on the return value until the end. Additionally, clear both the panel and the bridge pointers at the beginning. Even though this is redundant in some code paths, it allows to have a simpler code in the rest of the function. Reviewed-by: Maxime Ripard Link: https://patch.msgid.link/20260814-drm-bridge-every-panel-v1-2-19cd5277cc8d@bootlin.com Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/drm_of.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index 25ebaff580fe..2b53124ded68 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -287,12 +287,12 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, struct drm_panel **panel, struct drm_bridge **bridge) { - int ret = -EPROBE_DEFER; - if (WARN_ON(!panel)) return -EINVAL; *panel = NULL; + if (bridge) + *bridge = NULL; /* * of_graph_get_remote_node() produces a noisy error message if port @@ -310,23 +310,20 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, *panel = of_drm_find_panel(remote); if (!IS_ERR(*panel)) - ret = 0; - else - *panel = NULL; + return 0; + + *panel = NULL; if (bridge) { - if (ret) { - /* No panel found yet, check for a bridge next. */ - *bridge = of_drm_find_bridge(remote); - if (*bridge) - ret = 0; - } else { - *bridge = NULL; - } + /* No panel found yet, check for a bridge next. */ + *bridge = of_drm_find_bridge(remote); + if (*bridge) + return 0; + *bridge = NULL; } - return ret; + return -EPROBE_DEFER; } EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge);