From f2a575f67695dcba9062acd666ae5aab2380b95c Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Fri, 14 Feb 2014 11:53:56 +0100 Subject: [media] of: move common endpoint parsing to drivers/of This patch adds a new struct of_endpoint which is then embedded in struct v4l2_of_endpoint and contains the endpoint properties that are not V4L2 (or even media) specific: the port number, endpoint id, local device tree node and remote endpoint phandle. of_graph_parse_endpoint parses those properties and is used by v4l2_of_parse_endpoint, which just adds the V4L2 MBUS information to the containing v4l2_of_endpoint structure. Signed-off-by: Philipp Zabel Acked-by: Tomi Valkeinen Acked-by: Mauro Carvalho Chehab Acked-by: Sylwester Nawrocki --- drivers/of/base.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'drivers/of') diff --git a/drivers/of/base.c b/drivers/of/base.c index a8e47d37cc7f..715144af3a83 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1984,6 +1984,34 @@ struct device_node *of_find_next_cache_node(const struct device_node *np) return NULL; } +/** + * of_graph_parse_endpoint() - parse common endpoint node properties + * @node: pointer to endpoint device_node + * @endpoint: pointer to the OF endpoint data structure + * + * The caller should hold a reference to @node. + */ +int of_graph_parse_endpoint(const struct device_node *node, + struct of_endpoint *endpoint) +{ + struct device_node *port_node = of_get_parent(node); + + memset(endpoint, 0, sizeof(*endpoint)); + + endpoint->local_node = node; + /* + * It doesn't matter whether the two calls below succeed. + * If they don't then the default value 0 is used. + */ + of_property_read_u32(port_node, "reg", &endpoint->port); + of_property_read_u32(node, "reg", &endpoint->id); + + of_node_put(port_node); + + return 0; +} +EXPORT_SYMBOL(of_graph_parse_endpoint); + /** * of_graph_get_next_endpoint() - get next endpoint node * @parent: pointer to the parent device node -- cgit