Skip to content

Commit

Permalink
drm/imx: use for_each_endpoint_of_node macro in imx_drm_encoder_get_m…
Browse files Browse the repository at this point in the history
…ux_id

Using the for_each_... macro should make the code bit shorter and
easier to read. This patch also properly decrements the endpoint node
reference count before returning out of the loop.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
  • Loading branch information
Philipp Zabel committed Apr 8, 2015
1 parent 7416f4e commit 539bb6a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions drivers/gpu/drm/imx/imx-drm-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,26 +439,23 @@ int imx_drm_encoder_get_mux_id(struct device_node *node,
struct drm_encoder *encoder)
{
struct imx_drm_crtc *imx_crtc = imx_drm_find_crtc(encoder->crtc);
struct device_node *ep = NULL;
struct device_node *ep;
struct of_endpoint endpoint;
struct device_node *port;
int ret;

if (!node || !imx_crtc)
return -EINVAL;

do {
ep = of_graph_get_next_endpoint(node, ep);
if (!ep)
break;

for_each_endpoint_of_node(node, ep) {
port = of_graph_get_remote_port(ep);
of_node_put(port);
if (port == imx_crtc->crtc->port) {
ret = of_graph_parse_endpoint(ep, &endpoint);
of_node_put(ep);
return ret ? ret : endpoint.port;
}
} while (ep);
}

return -EINVAL;
}
Expand Down

0 comments on commit 539bb6a

Please sign in to comment.