drm/rockchip: use for_each_endpoint_of_node macro, drop endpoint reference on break
authorPhilipp Zabel <p.zabel@pengutronix.de>
Sun, 21 Dec 2014 14:38:02 +0000 (15:38 +0100)
committerPhilipp Zabel <p.zabel@pengutronix.de>
Wed, 8 Apr 2015 09:14:27 +0000 (11:14 +0200)
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>
drivers/gpu/drm/rockchip/rockchip_drm_drv.c

index 21a481b224ebab6ef896bbbf5e2a9036c5cfb0ed..9bb4fd27d52f6603955bed33df97a31aa4dc7def 100644 (file)
@@ -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,
                                    struct drm_encoder *encoder)
 {
-       struct device_node *ep = NULL;
+       struct device_node *ep;
        struct drm_crtc *crtc = encoder->crtc;
        struct of_endpoint endpoint;
        struct device_node *port;
@@ -375,18 +375,15 @@ int rockchip_drm_encoder_get_mux_id(struct device_node *node,
        if (!node || !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 == crtc->port) {
                        ret = of_graph_parse_endpoint(ep, &endpoint);
+                       of_node_put(ep);
                        return ret ?: endpoint.id;
                }
-       } while (ep);
+       }
 
        return -EINVAL;
 }
This page took 0.033571 seconds and 5 git commands to generate.