diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2014-12-21 09:38:02 -0500 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2015-04-08 05:14:27 -0400 |
commit | ecaa4902222fd4d28692203bec028513fbac29c7 (patch) | |
tree | 5a403d0f2647f067f1a9a744ebf58a10853d3283 | |
parent | 4af642d5bf75c726c874a198daf742589db30981 (diff) |
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: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
-rw-r--r-- | drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 21a481b224eb..9bb4fd27d52f 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c | |||
@@ -366,7 +366,7 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = { | |||
366 | int rockchip_drm_encoder_get_mux_id(struct device_node *node, | 366 | int rockchip_drm_encoder_get_mux_id(struct device_node *node, |
367 | struct drm_encoder *encoder) | 367 | struct drm_encoder *encoder) |
368 | { | 368 | { |
369 | struct device_node *ep = NULL; | 369 | struct device_node *ep; |
370 | struct drm_crtc *crtc = encoder->crtc; | 370 | struct drm_crtc *crtc = encoder->crtc; |
371 | struct of_endpoint endpoint; | 371 | struct of_endpoint endpoint; |
372 | struct device_node *port; | 372 | struct device_node *port; |
@@ -375,18 +375,15 @@ int rockchip_drm_encoder_get_mux_id(struct device_node *node, | |||
375 | if (!node || !crtc) | 375 | if (!node || !crtc) |
376 | return -EINVAL; | 376 | return -EINVAL; |
377 | 377 | ||
378 | do { | 378 | for_each_endpoint_of_node(node, ep) { |
379 | ep = of_graph_get_next_endpoint(node, ep); | ||
380 | if (!ep) | ||
381 | break; | ||
382 | |||
383 | port = of_graph_get_remote_port(ep); | 379 | port = of_graph_get_remote_port(ep); |
384 | of_node_put(port); | 380 | of_node_put(port); |
385 | if (port == crtc->port) { | 381 | if (port == crtc->port) { |
386 | ret = of_graph_parse_endpoint(ep, &endpoint); | 382 | ret = of_graph_parse_endpoint(ep, &endpoint); |
383 | of_node_put(ep); | ||
387 | return ret ?: endpoint.id; | 384 | return ret ?: endpoint.id; |
388 | } | 385 | } |
389 | } while (ep); | 386 | } |
390 | 387 | ||
391 | return -EINVAL; | 388 | return -EINVAL; |
392 | } | 389 | } |