devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Mauro Carvalho Chehab <m.chehab@samsung.com>,
	Grant Likely <grant.likely@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	devicetree@vger.kernel.org,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Philipp Zabel <p.zabel@pengutronix.de>
Subject: [PATCH v4 2/3] [media] of: move common endpoint parsing to drivers/of
Date: Tue, 25 Feb 2014 15:58:23 +0100	[thread overview]
Message-ID: <1393340304-19005-3-git-send-email-p.zabel@pengutronix.de> (raw)
In-Reply-To: <1393340304-19005-1-git-send-email-p.zabel@pengutronix.de>

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
specific, or in fact not even media specific: 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 <p.zabel@pengutronix.de>
---
 drivers/media/v4l2-core/v4l2-of.c | 16 +++-------------
 drivers/of/of_graph.c             | 32 ++++++++++++++++++++++++++++++++
 include/linux/of_graph.h          | 20 ++++++++++++++++++++
 include/media/v4l2-of.h           |  9 +++------
 4 files changed, 58 insertions(+), 19 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-of.c b/drivers/media/v4l2-core/v4l2-of.c
index f919db3..222ed58 100644
--- a/drivers/media/v4l2-core/v4l2-of.c
+++ b/drivers/media/v4l2-core/v4l2-of.c
@@ -127,17 +127,9 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node,
 int v4l2_of_parse_endpoint(const struct device_node *node,
 			   struct v4l2_of_endpoint *endpoint)
 {
-	struct device_node *port_node = of_get_parent(node);
-
-	memset(endpoint, 0, offsetof(struct v4l2_of_endpoint, head));
-
-	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_graph_parse_endpoint(node, &endpoint->ep);
+	endpoint->bus_type = 0;
+	memset(&endpoint->bus, 0, sizeof(endpoint->bus));
 
 	v4l2_of_parse_csi_bus(node, endpoint);
 	/*
@@ -147,8 +139,6 @@ int v4l2_of_parse_endpoint(const struct device_node *node,
 	if (endpoint->bus.mipi_csi2.flags == 0)
 		v4l2_of_parse_parallel_bus(node, endpoint);
 
-	of_node_put(port_node);
-
 	return 0;
 }
 EXPORT_SYMBOL(v4l2_of_parse_endpoint);
diff --git a/drivers/of/of_graph.c b/drivers/of/of_graph.c
index 267d8f7..d0f1683 100644
--- a/drivers/of/of_graph.c
+++ b/drivers/of/of_graph.c
@@ -15,6 +15,38 @@
 #include <linux/of.h>
 #include <linux/of_graph.h>
 #include <linux/types.h>
+#include <media/of_graph.h>
+
+/**
+ * of_graph_parse_endpoint() - parse common endpoint node properties
+ * @node: pointer to endpoint device_node
+ * @endpoint: pointer to the OF endpoint data structure
+ *
+ * All properties are optional. If none are found, we don't set any flags.
+ * This means the port has a static configuration and no properties have
+ * to be specified explicitly.
+ * 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
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 3bbeb60..2b233db 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -14,7 +14,21 @@
 #ifndef __LINUX_OF_GRAPH_H
 #define __LINUX_OF_GRAPH_H
 
+/**
+ * struct of_endpoint - the OF graph endpoint data structure
+ * @port: identifier (value of reg property) of a port this endpoint belongs to
+ * @id: identifier (value of reg property) of this endpoint
+ * @local_node: pointer to device_node of this endpoint
+ */
+struct of_endpoint {
+	unsigned int port;
+	unsigned int id;
+	const struct device_node *local_node;
+};
+
 #ifdef CONFIG_OF
+int of_graph_parse_endpoint(const struct device_node *node,
+				struct of_endpoint *endpoint);
 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 					struct device_node *previous);
 struct device_node *of_graph_get_remote_port_parent(
@@ -22,6 +36,12 @@ struct device_node *of_graph_get_remote_port_parent(
 struct device_node *of_graph_get_remote_port(const struct device_node *node);
 #else
 
+static inline int of_graph_parse_endpoint(const struct device_node *node,
+					struct of_endpoint *endpoint);
+{
+	return -ENOSYS;
+}
+
 static inline struct device_node *of_graph_get_next_endpoint(
 					const struct device_node *parent,
 					struct device_node *previous)
diff --git a/include/media/v4l2-of.h b/include/media/v4l2-of.h
index 3a49735..2229a0e 100644
--- a/include/media/v4l2-of.h
+++ b/include/media/v4l2-of.h
@@ -19,6 +19,7 @@
 #include <linux/errno.h>
 #include <linux/of_graph.h>
 
+#include <media/of_graph.h>
 #include <media/v4l2-mediabus.h>
 
 struct device_node;
@@ -51,17 +52,13 @@ struct v4l2_of_bus_parallel {
 
 /**
  * struct v4l2_of_endpoint - the endpoint data structure
- * @port: identifier (value of reg property) of a port this endpoint belongs to
- * @id: identifier (value of reg property) of this endpoint
- * @local_node: pointer to device_node of this endpoint
+ * @ep: struct of_endpoint containing port, id, and local of_node
  * @bus_type: bus type
  * @bus: bus configuration data structure
  * @head: list head for this structure
  */
 struct v4l2_of_endpoint {
-	unsigned int port;
-	unsigned int id;
-	const struct device_node *local_node;
+	struct of_endpoint ep;
 	enum v4l2_mbus_type bus_type;
 	union {
 		struct v4l2_of_bus_parallel parallel;
-- 
1.8.5.3

  parent reply	other threads:[~2014-02-25 14:58 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-25 14:58 [PATCH v4 0/3] Move device tree graph parsing helpers to drivers/of Philipp Zabel
     [not found] ` < 1393340304-19005-4-git-send-email-p.zabel@pengutronix.de>
     [not found] ` < 20140226113729.A9D5AC40A89@trevor.secretlab.ca>
     [not found] ` < 1393340304-19005-2-git-send-email-p.zabel@pengutronix.de>
     [not found]   ` <20140226113729. A9D5AC40A89@trevor.secretlab.ca>
     [not found] ` < 1393428297.3248.92.camel@paszta.hi.pengutronix.de>
     [not found]   ` <20140307171804. EF245C40A32@trevor.secretlab.ca>
2014-02-25 14:58 ` [PATCH v4 1/3] [media] of: move graph helpers from drivers/media/v4l2-core " Philipp Zabel
2014-02-26 11:37   ` Grant Likely
2014-02-26 15:24     ` Philipp Zabel
2014-03-07 17:18       ` Grant Likely
2014-03-08 10:46         ` Tomi Valkeinen
2014-03-08 12:23           ` Grant Likely
2014-03-08 15:50             ` Laurent Pinchart
2014-03-20 22:23               ` Grant Likely
     [not found]                 ` <20140320222347.CAB6DC412EA-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-03-20 22:32                   ` Laurent Pinchart
2014-03-21 13:37                     ` Tomi Valkeinen
2014-03-21 14:10                       ` Sylwester Nawrocki
     [not found]                       ` <532C408D.4070002-l0cyMroinI0@public.gmane.org>
2014-03-21 14:13                         ` Laurent Pinchart
2014-03-21 14:22                           ` Tomi Valkeinen
     [not found]                             ` <532C4B3C.4030406-l0cyMroinI0@public.gmane.org>
2014-03-21 14:30                               ` Laurent Pinchart
2014-03-10  6:34             ` Tomi Valkeinen
2014-03-20 22:26               ` Grant Likely
2014-03-08 12:07         ` Philipp Zabel
     [not found]           ` <CA+gwMcfgKre8S4KHPvTVuAuz672aehGrN1UfFpwKAueTAcrMZQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-03-08 15:54             ` Laurent Pinchart
2014-03-10  6:00               ` Tomi Valkeinen
     [not found]                 ` <531D54E2.8030303-l0cyMroinI0@public.gmane.org>
2014-03-10 13:57                   ` Laurent Pinchart
2014-03-10  8:58               ` Andrzej Hajda
     [not found]                 ` <531D7E9F.3090708-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2014-03-10  9:29                   ` Tomi Valkeinen
2014-03-10 11:42                   ` Laurent Pinchart
2014-03-11 13:55                     ` Andrzej Hajda
2014-03-20 22:33             ` Grant Likely
2014-02-25 14:58 ` Philipp Zabel [this message]
2014-02-25 14:58 ` [PATCH v4 3/3] Documentation: of: Document graph bindings Philipp Zabel
2014-02-26 13:14   ` Tomi Valkeinen
2014-02-26 14:57     ` Philipp Zabel
     [not found]       ` <1393426623.3248.70.camel-+qGW7pzALmz7o/J7KWpOmN53zsg1cpMQ@public.gmane.org>
2014-02-26 14:50         ` Tomi Valkeinen
2014-02-26 15:47           ` Philipp Zabel
     [not found]             ` <1393429676.3248.110.camel-+qGW7pzALmz7o/J7KWpOmN53zsg1cpMQ@public.gmane.org>
2014-02-27  8:08               ` Tomi Valkeinen
2014-02-27 10:52                 ` Philipp Zabel
2014-02-27 10:41                   ` Tomi Valkeinen
     [not found]       ` < 530DFF4C.8080807@ti.com>
     [not found]         ` <530DFF4C.8080807-l0cyMroinI0@public.gmane.org>
2014-03-07 18:11           ` Grant Likely
2014-03-08  9:35             ` Tomi Valkeinen
2014-03-08 12:25               ` Grant Likely
2014-03-08 15:43                 ` Laurent Pinchart
2014-03-10  6:53                 ` Tomi Valkeinen
     [not found]                   ` <531D6178.3070906-l0cyMroinI0@public.gmane.org>
2014-03-11 13:47                     ` Sylwester Nawrocki
2014-03-07 17:20     ` Grant Likely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393340304-19005-3-git-send-email-p.zabel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=devicetree@vger.kernel.org \
    --cc=g.liakhovetski@gmx.de \
    --cc=grant.likely@linaro.org \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m.chehab@samsung.com \
    --cc=robh+dt@kernel.org \
    --cc=s.nawrocki@samsung.com \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).