diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2014-07-03 17:07:49 -0400 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2015-04-08 05:14:26 -0400 |
commit | 539bb6a248858edd99d8645677345799f37ca51d (patch) | |
tree | 8ab15ba97423eba1daed520c69210c2cf8ca21e1 /drivers/gpu | |
parent | 7416f4e33b5e924baa030ddab1f261a0a85fa32e (diff) |
drm/imx: use for_each_endpoint_of_node macro in imx_drm_encoder_get_mux_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>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/imx/imx-drm-core.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index 84cf99f8d957..db2f5a739e05 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c | |||
@@ -439,7 +439,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node, | |||
439 | struct drm_encoder *encoder) | 439 | struct drm_encoder *encoder) |
440 | { | 440 | { |
441 | struct imx_drm_crtc *imx_crtc = imx_drm_find_crtc(encoder->crtc); | 441 | struct imx_drm_crtc *imx_crtc = imx_drm_find_crtc(encoder->crtc); |
442 | struct device_node *ep = NULL; | 442 | struct device_node *ep; |
443 | struct of_endpoint endpoint; | 443 | struct of_endpoint endpoint; |
444 | struct device_node *port; | 444 | struct device_node *port; |
445 | int ret; | 445 | int ret; |
@@ -447,18 +447,15 @@ int imx_drm_encoder_get_mux_id(struct device_node *node, | |||
447 | if (!node || !imx_crtc) | 447 | if (!node || !imx_crtc) |
448 | return -EINVAL; | 448 | return -EINVAL; |
449 | 449 | ||
450 | do { | 450 | for_each_endpoint_of_node(node, ep) { |
451 | ep = of_graph_get_next_endpoint(node, ep); | ||
452 | if (!ep) | ||
453 | break; | ||
454 | |||
455 | port = of_graph_get_remote_port(ep); | 451 | port = of_graph_get_remote_port(ep); |
456 | of_node_put(port); | 452 | of_node_put(port); |
457 | if (port == imx_crtc->crtc->port) { | 453 | if (port == imx_crtc->crtc->port) { |
458 | ret = of_graph_parse_endpoint(ep, &endpoint); | 454 | ret = of_graph_parse_endpoint(ep, &endpoint); |
455 | of_node_put(ep); | ||
459 | return ret ? ret : endpoint.port; | 456 | return ret ? ret : endpoint.port; |
460 | } | 457 | } |
461 | } while (ep); | 458 | } |
462 | 459 | ||
463 | return -EINVAL; | 460 | return -EINVAL; |
464 | } | 461 | } |