Commit ecaa4902 authored by Philipp Zabel's avatar Philipp Zabel

drm/rockchip: use for_each_endpoint_of_node macro, drop endpoint reference on break

Using the for_each_... macro should make the code a bit shorter and
easier to read. Also, when breaking out of the loop, the endpoint node
reference count needs to be decremented.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: default avatarDaniel Kurtz <djkurtz@chromium.org>
parent 4af642d5
...@@ -366,7 +366,7 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = { ...@@ -366,7 +366,7 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
int rockchip_drm_encoder_get_mux_id(struct device_node *node, int rockchip_drm_encoder_get_mux_id(struct device_node *node,
struct drm_encoder *encoder) struct drm_encoder *encoder)
{ {
struct device_node *ep = NULL; struct device_node *ep;
struct drm_crtc *crtc = encoder->crtc; struct drm_crtc *crtc = encoder->crtc;
struct of_endpoint endpoint; struct of_endpoint endpoint;
struct device_node *port; struct device_node *port;
...@@ -375,18 +375,15 @@ int rockchip_drm_encoder_get_mux_id(struct device_node *node, ...@@ -375,18 +375,15 @@ int rockchip_drm_encoder_get_mux_id(struct device_node *node,
if (!node || !crtc) if (!node || !crtc)
return -EINVAL; return -EINVAL;
do { for_each_endpoint_of_node(node, ep) {
ep = of_graph_get_next_endpoint(node, ep);
if (!ep)
break;
port = of_graph_get_remote_port(ep); port = of_graph_get_remote_port(ep);
of_node_put(port); of_node_put(port);
if (port == crtc->port) { if (port == crtc->port) {
ret = of_graph_parse_endpoint(ep, &endpoint); ret = of_graph_parse_endpoint(ep, &endpoint);
of_node_put(ep);
return ret ?: endpoint.id; return ret ?: endpoint.id;
} }
} while (ep); }
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment