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 -<ERRNO>;' 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. Signed-off-by: Luca Ceresoli <[email protected]> --- 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 b42a321f3052..8ec352f3df93 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); -- 2.55.0
