diff options
-rw-r--r-- | drivers/coresight/of_coresight.c | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/imx/imx-drm-core.c | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/rcar-du/rcar_du_kms.c | 15 | ||||
-rw-r--r-- | drivers/media/platform/am437x/am437x-vpfe.c | 1 | ||||
-rw-r--r-- | drivers/media/platform/soc_camera/soc_camera.c | 3 | ||||
-rw-r--r-- | drivers/of/base.c | 41 | ||||
-rw-r--r-- | drivers/video/fbdev/omap2/dss/omapdss-boot-init.c | 7 | ||||
-rw-r--r-- | include/linux/of_graph.h | 18 |
8 files changed, 61 insertions, 48 deletions
diff --git a/drivers/coresight/of_coresight.c b/drivers/coresight/of_coresight.c index c3efa418a86d..6f75e9d5b6fb 100644 --- a/drivers/coresight/of_coresight.c +++ b/drivers/coresight/of_coresight.c | |||
@@ -52,15 +52,6 @@ of_coresight_get_endpoint_device(struct device_node *endpoint) | |||
52 | endpoint, of_dev_node_match); | 52 | endpoint, of_dev_node_match); |
53 | } | 53 | } |
54 | 54 | ||
55 | static struct device_node *of_get_coresight_endpoint( | ||
56 | const struct device_node *parent, struct device_node *prev) | ||
57 | { | ||
58 | struct device_node *node = of_graph_get_next_endpoint(parent, prev); | ||
59 | |||
60 | of_node_put(prev); | ||
61 | return node; | ||
62 | } | ||
63 | |||
64 | static void of_coresight_get_ports(struct device_node *node, | 55 | static void of_coresight_get_ports(struct device_node *node, |
65 | int *nr_inport, int *nr_outport) | 56 | int *nr_inport, int *nr_outport) |
66 | { | 57 | { |
@@ -68,7 +59,7 @@ static void of_coresight_get_ports(struct device_node *node, | |||
68 | int in = 0, out = 0; | 59 | int in = 0, out = 0; |
69 | 60 | ||
70 | do { | 61 | do { |
71 | ep = of_get_coresight_endpoint(node, ep); | 62 | ep = of_graph_get_next_endpoint(node, ep); |
72 | if (!ep) | 63 | if (!ep) |
73 | break; | 64 | break; |
74 | 65 | ||
@@ -140,7 +131,7 @@ struct coresight_platform_data *of_get_coresight_platform_data( | |||
140 | /* Iterate through each port to discover topology */ | 131 | /* Iterate through each port to discover topology */ |
141 | do { | 132 | do { |
142 | /* Get a handle on a port */ | 133 | /* Get a handle on a port */ |
143 | ep = of_get_coresight_endpoint(node, ep); | 134 | ep = of_graph_get_next_endpoint(node, ep); |
144 | if (!ep) | 135 | if (!ep) |
145 | break; | 136 | break; |
146 | 137 | ||
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c index a002f53aab0e..84cf99f8d957 100644 --- a/drivers/gpu/drm/imx/imx-drm-core.c +++ b/drivers/gpu/drm/imx/imx-drm-core.c | |||
@@ -431,15 +431,6 @@ int imx_drm_encoder_parse_of(struct drm_device *drm, | |||
431 | } | 431 | } |
432 | EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of); | 432 | EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of); |
433 | 433 | ||
434 | static struct device_node *imx_drm_of_get_next_endpoint( | ||
435 | const struct device_node *parent, struct device_node *prev) | ||
436 | { | ||
437 | struct device_node *node = of_graph_get_next_endpoint(parent, prev); | ||
438 | |||
439 | of_node_put(prev); | ||
440 | return node; | ||
441 | } | ||
442 | |||
443 | /* | 434 | /* |
444 | * @node: device tree node containing encoder input ports | 435 | * @node: device tree node containing encoder input ports |
445 | * @encoder: drm_encoder | 436 | * @encoder: drm_encoder |
@@ -457,7 +448,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node, | |||
457 | return -EINVAL; | 448 | return -EINVAL; |
458 | 449 | ||
459 | do { | 450 | do { |
460 | ep = imx_drm_of_get_next_endpoint(node, ep); | 451 | ep = of_graph_get_next_endpoint(node, ep); |
461 | if (!ep) | 452 | if (!ep) |
462 | break; | 453 | break; |
463 | 454 | ||
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index cc9136e8ee9c..68dab2601bf5 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c | |||
@@ -206,7 +206,7 @@ static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu, | |||
206 | enum rcar_du_encoder_type enc_type = RCAR_DU_ENCODER_NONE; | 206 | enum rcar_du_encoder_type enc_type = RCAR_DU_ENCODER_NONE; |
207 | struct device_node *connector = NULL; | 207 | struct device_node *connector = NULL; |
208 | struct device_node *encoder = NULL; | 208 | struct device_node *encoder = NULL; |
209 | struct device_node *prev = NULL; | 209 | struct device_node *ep_node = NULL; |
210 | struct device_node *entity_ep_node; | 210 | struct device_node *entity_ep_node; |
211 | struct device_node *entity; | 211 | struct device_node *entity; |
212 | int ret; | 212 | int ret; |
@@ -225,11 +225,7 @@ static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu, | |||
225 | entity_ep_node = of_parse_phandle(ep->local_node, "remote-endpoint", 0); | 225 | entity_ep_node = of_parse_phandle(ep->local_node, "remote-endpoint", 0); |
226 | 226 | ||
227 | while (1) { | 227 | while (1) { |
228 | struct device_node *ep_node; | 228 | ep_node = of_graph_get_next_endpoint(entity, ep_node); |
229 | |||
230 | ep_node = of_graph_get_next_endpoint(entity, prev); | ||
231 | of_node_put(prev); | ||
232 | prev = ep_node; | ||
233 | 229 | ||
234 | if (!ep_node) | 230 | if (!ep_node) |
235 | break; | 231 | break; |
@@ -300,7 +296,7 @@ static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu, | |||
300 | static int rcar_du_encoders_init(struct rcar_du_device *rcdu) | 296 | static int rcar_du_encoders_init(struct rcar_du_device *rcdu) |
301 | { | 297 | { |
302 | struct device_node *np = rcdu->dev->of_node; | 298 | struct device_node *np = rcdu->dev->of_node; |
303 | struct device_node *prev = NULL; | 299 | struct device_node *ep_node = NULL; |
304 | unsigned int num_encoders = 0; | 300 | unsigned int num_encoders = 0; |
305 | 301 | ||
306 | /* | 302 | /* |
@@ -308,15 +304,12 @@ static int rcar_du_encoders_init(struct rcar_du_device *rcdu) | |||
308 | * pipeline. | 304 | * pipeline. |
309 | */ | 305 | */ |
310 | while (1) { | 306 | while (1) { |
311 | struct device_node *ep_node; | ||
312 | enum rcar_du_output output; | 307 | enum rcar_du_output output; |
313 | struct of_endpoint ep; | 308 | struct of_endpoint ep; |
314 | unsigned int i; | 309 | unsigned int i; |
315 | int ret; | 310 | int ret; |
316 | 311 | ||
317 | ep_node = of_graph_get_next_endpoint(np, prev); | 312 | ep_node = of_graph_get_next_endpoint(np, ep_node); |
318 | of_node_put(prev); | ||
319 | prev = ep_node; | ||
320 | 313 | ||
321 | if (ep_node == NULL) | 314 | if (ep_node == NULL) |
322 | break; | 315 | break; |
diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c index 56a5cb0d2152..0d07fca756fe 100644 --- a/drivers/media/platform/am437x/am437x-vpfe.c +++ b/drivers/media/platform/am437x/am437x-vpfe.c | |||
@@ -2504,7 +2504,6 @@ vpfe_get_pdata(struct platform_device *pdev) | |||
2504 | GFP_KERNEL); | 2504 | GFP_KERNEL); |
2505 | pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_OF; | 2505 | pdata->asd[i]->match_type = V4L2_ASYNC_MATCH_OF; |
2506 | pdata->asd[i]->match.of.node = rem; | 2506 | pdata->asd[i]->match.of.node = rem; |
2507 | of_node_put(endpoint); | ||
2508 | of_node_put(rem); | 2507 | of_node_put(rem); |
2509 | } | 2508 | } |
2510 | 2509 | ||
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index cee7b56f8404..f2a3d960b1a6 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c | |||
@@ -1694,7 +1694,6 @@ static void scan_of_host(struct soc_camera_host *ici) | |||
1694 | if (!i) | 1694 | if (!i) |
1695 | soc_of_bind(ici, epn, ren->parent); | 1695 | soc_of_bind(ici, epn, ren->parent); |
1696 | 1696 | ||
1697 | of_node_put(epn); | ||
1698 | of_node_put(ren); | 1697 | of_node_put(ren); |
1699 | 1698 | ||
1700 | if (i) { | 1699 | if (i) { |
@@ -1702,6 +1701,8 @@ static void scan_of_host(struct soc_camera_host *ici) | |||
1702 | break; | 1701 | break; |
1703 | } | 1702 | } |
1704 | } | 1703 | } |
1704 | |||
1705 | of_node_put(epn); | ||
1705 | } | 1706 | } |
1706 | 1707 | ||
1707 | #else | 1708 | #else |
diff --git a/drivers/of/base.c b/drivers/of/base.c index 8f165b112e03..69566b6a876d 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -2083,13 +2083,44 @@ int of_graph_parse_endpoint(const struct device_node *node, | |||
2083 | EXPORT_SYMBOL(of_graph_parse_endpoint); | 2083 | EXPORT_SYMBOL(of_graph_parse_endpoint); |
2084 | 2084 | ||
2085 | /** | 2085 | /** |
2086 | * of_graph_get_port_by_id() - get the port matching a given id | ||
2087 | * @parent: pointer to the parent device node | ||
2088 | * @id: id of the port | ||
2089 | * | ||
2090 | * Return: A 'port' node pointer with refcount incremented. The caller | ||
2091 | * has to use of_node_put() on it when done. | ||
2092 | */ | ||
2093 | struct device_node *of_graph_get_port_by_id(struct device_node *parent, u32 id) | ||
2094 | { | ||
2095 | struct device_node *node, *port; | ||
2096 | |||
2097 | node = of_get_child_by_name(parent, "ports"); | ||
2098 | if (node) | ||
2099 | parent = node; | ||
2100 | |||
2101 | for_each_child_of_node(parent, port) { | ||
2102 | u32 port_id = 0; | ||
2103 | |||
2104 | if (of_node_cmp(port->name, "port") != 0) | ||
2105 | continue; | ||
2106 | of_property_read_u32(port, "reg", &port_id); | ||
2107 | if (id == port_id) | ||
2108 | break; | ||
2109 | } | ||
2110 | |||
2111 | of_node_put(node); | ||
2112 | |||
2113 | return port; | ||
2114 | } | ||
2115 | EXPORT_SYMBOL(of_graph_get_port_by_id); | ||
2116 | |||
2117 | /** | ||
2086 | * of_graph_get_next_endpoint() - get next endpoint node | 2118 | * of_graph_get_next_endpoint() - get next endpoint node |
2087 | * @parent: pointer to the parent device node | 2119 | * @parent: pointer to the parent device node |
2088 | * @prev: previous endpoint node, or NULL to get first | 2120 | * @prev: previous endpoint node, or NULL to get first |
2089 | * | 2121 | * |
2090 | * Return: An 'endpoint' node pointer with refcount incremented. Refcount | 2122 | * Return: An 'endpoint' node pointer with refcount incremented. Refcount |
2091 | * of the passed @prev node is not decremented, the caller have to use | 2123 | * of the passed @prev node is decremented. |
2092 | * of_node_put() on it when done. | ||
2093 | */ | 2124 | */ |
2094 | struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, | 2125 | struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, |
2095 | struct device_node *prev) | 2126 | struct device_node *prev) |
@@ -2125,12 +2156,6 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, | |||
2125 | if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", | 2156 | if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", |
2126 | __func__, prev->full_name)) | 2157 | __func__, prev->full_name)) |
2127 | return NULL; | 2158 | return NULL; |
2128 | |||
2129 | /* | ||
2130 | * Avoid dropping prev node refcount to 0 when getting the next | ||
2131 | * child below. | ||
2132 | */ | ||
2133 | of_node_get(prev); | ||
2134 | } | 2159 | } |
2135 | 2160 | ||
2136 | while (1) { | 2161 | while (1) { |
diff --git a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c index 42b87f95267c..8b6f6d5fdd68 100644 --- a/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c +++ b/drivers/video/fbdev/omap2/dss/omapdss-boot-init.c | |||
@@ -164,20 +164,15 @@ static void __init omapdss_walk_device(struct device_node *node, bool root) | |||
164 | 164 | ||
165 | pn = of_graph_get_remote_port_parent(n); | 165 | pn = of_graph_get_remote_port_parent(n); |
166 | 166 | ||
167 | if (!pn) { | 167 | if (!pn) |
168 | of_node_put(n); | ||
169 | continue; | 168 | continue; |
170 | } | ||
171 | 169 | ||
172 | if (!of_device_is_available(pn) || omapdss_list_contains(pn)) { | 170 | if (!of_device_is_available(pn) || omapdss_list_contains(pn)) { |
173 | of_node_put(pn); | 171 | of_node_put(pn); |
174 | of_node_put(n); | ||
175 | continue; | 172 | continue; |
176 | } | 173 | } |
177 | 174 | ||
178 | omapdss_walk_device(pn, false); | 175 | omapdss_walk_device(pn, false); |
179 | |||
180 | of_node_put(n); | ||
181 | } | 176 | } |
182 | } | 177 | } |
183 | 178 | ||
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h index befef42e015b..3c1c95a39e0c 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h | |||
@@ -26,9 +26,21 @@ struct of_endpoint { | |||
26 | const struct device_node *local_node; | 26 | const struct device_node *local_node; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | /** | ||
30 | * for_each_endpoint_of_node - iterate over every endpoint in a device node | ||
31 | * @parent: parent device node containing ports and endpoints | ||
32 | * @child: loop variable pointing to the current endpoint node | ||
33 | * | ||
34 | * When breaking out of the loop, of_node_put(child) has to be called manually. | ||
35 | */ | ||
36 | #define for_each_endpoint_of_node(parent, child) \ | ||
37 | for (child = of_graph_get_next_endpoint(parent, NULL); child != NULL; \ | ||
38 | child = of_graph_get_next_endpoint(parent, child)) | ||
39 | |||
29 | #ifdef CONFIG_OF | 40 | #ifdef CONFIG_OF |
30 | int of_graph_parse_endpoint(const struct device_node *node, | 41 | int of_graph_parse_endpoint(const struct device_node *node, |
31 | struct of_endpoint *endpoint); | 42 | struct of_endpoint *endpoint); |
43 | struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id); | ||
32 | struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, | 44 | struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, |
33 | struct device_node *previous); | 45 | struct device_node *previous); |
34 | struct device_node *of_graph_get_remote_port_parent( | 46 | struct device_node *of_graph_get_remote_port_parent( |
@@ -42,6 +54,12 @@ static inline int of_graph_parse_endpoint(const struct device_node *node, | |||
42 | return -ENOSYS; | 54 | return -ENOSYS; |
43 | } | 55 | } |
44 | 56 | ||
57 | static inline struct device_node *of_graph_get_port_by_id( | ||
58 | struct device_node *node, u32 id) | ||
59 | { | ||
60 | return NULL; | ||
61 | } | ||
62 | |||
45 | static inline struct device_node *of_graph_get_next_endpoint( | 63 | static inline struct device_node *of_graph_get_next_endpoint( |
46 | const struct device_node *parent, | 64 | const struct device_node *parent, |
47 | struct device_node *previous) | 65 | struct device_node *previous) |