All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Rob Herring <robh+dt@kernel.org>, Mark Brown <broonie@linaro.org>,
	Mark Brown <broonie@kernel.org>,
	Laurent <laurent.pinchart@ideasonboard.com>,
	Guennadi <g.liakhovetski@gmx.de>,
	Grant Likely <grant.likely@linaro.org>,
	Frank Rowand <frowand.list@gmail.com>
Cc: Linux-Kernel <linux-kernel@vger.kernel.org>,
	Linux-DT <devicetree@vger.kernel.org>,
	Linux-ALSA <alsa-devel@alsa-project.org>
Subject: [PATCH 4/7] of_graph: add of_graph_get_endpoint_count()
Date: Fri, 24 Jun 2016 02:33:20 +0000	[thread overview]
Message-ID: <87a8ibxqy6.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87fus3xr2q.wl%kuninori.morimoto.gx@renesas.com>


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

OF graph want to count its endpoint number, same as
of_get_child_count(). This patch adds of_graph_get_endpoint_count()
which can check specific type. It will count all endpoint if type was NULL.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/of/base.c        | 16 ++++++++++++++++
 include/linux/of_graph.h |  8 ++++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index a0fc63c..a39d470 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2430,3 +2430,19 @@ bool of_graph_endpoint_type_is(struct device_node *ep, char *type)
 	return of_graph_port_type_is(of_get_parent(ep), type);
 }
 EXPORT_SYMBOL(of_graph_endpoint_type_is);
+
+int of_graph_get_endpoint_count(const struct device_node *np, char *type)
+{
+	struct device_node *child;
+	int num = 0;
+
+	for_each_endpoint_of_node(np, child) {
+		if (!type)
+			num++;
+		else
+			num += of_graph_endpoint_type_is(child, type);
+	}
+
+	return num;
+}
+EXPORT_SYMBOL(of_graph_get_endpoint_count);
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 1750d5c..86baae5 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -42,12 +42,14 @@ struct of_endpoint {
 
 #define of_graph_port_type_is_sound(n)		of_graph_port_type_is(n, "sound")
 #define of_graph_endpoint_type_is_sound(n)	of_graph_endpoint_type_is(n, "sound")
+#define of_graph_get_sound_endpoint_count(n)	of_graph_get_endpoint_count(n, "sound")
 
 #ifdef CONFIG_OF
 int of_graph_parse_endpoint(const struct device_node *node,
 				struct of_endpoint *endpoint);
 bool of_graph_port_type_is(struct device_node *port, char *type);
 bool of_graph_endpoint_type_is(struct device_node *ep, char *type);
+int of_graph_get_endpoint_count(const struct device_node *np, char *type);
 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 					struct device_node *previous);
@@ -76,6 +78,12 @@ static bool of_graph_endpoint_type_is(struct device_node *ep, char *type)
 	return false;
 }
 
+static inline int of_graph_get_endpoint_count(const struct device_node *np,
+					      char *type)
+{
+	return 0;
+}
+
 static inline struct device_node *of_graph_get_port_by_id(
 					struct device_node *node, u32 id)
 {
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
To: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Mark Brown <broonie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Laurent
	<laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>,
	Guennadi <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>,
	Grant Likely
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Frank Rowand
	<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Linux-Kernel
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Linux-DT <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Linux-ALSA <alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org>
Subject: [PATCH 4/7] of_graph: add of_graph_get_endpoint_count()
Date: Fri, 24 Jun 2016 02:33:20 +0000	[thread overview]
Message-ID: <87a8ibxqy6.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87fus3xr2q.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>


From: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>

OF graph want to count its endpoint number, same as
of_get_child_count(). This patch adds of_graph_get_endpoint_count()
which can check specific type. It will count all endpoint if type was NULL.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
---
 drivers/of/base.c        | 16 ++++++++++++++++
 include/linux/of_graph.h |  8 ++++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index a0fc63c..a39d470 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2430,3 +2430,19 @@ bool of_graph_endpoint_type_is(struct device_node *ep, char *type)
 	return of_graph_port_type_is(of_get_parent(ep), type);
 }
 EXPORT_SYMBOL(of_graph_endpoint_type_is);
+
+int of_graph_get_endpoint_count(const struct device_node *np, char *type)
+{
+	struct device_node *child;
+	int num = 0;
+
+	for_each_endpoint_of_node(np, child) {
+		if (!type)
+			num++;
+		else
+			num += of_graph_endpoint_type_is(child, type);
+	}
+
+	return num;
+}
+EXPORT_SYMBOL(of_graph_get_endpoint_count);
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 1750d5c..86baae5 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -42,12 +42,14 @@ struct of_endpoint {
 
 #define of_graph_port_type_is_sound(n)		of_graph_port_type_is(n, "sound")
 #define of_graph_endpoint_type_is_sound(n)	of_graph_endpoint_type_is(n, "sound")
+#define of_graph_get_sound_endpoint_count(n)	of_graph_get_endpoint_count(n, "sound")
 
 #ifdef CONFIG_OF
 int of_graph_parse_endpoint(const struct device_node *node,
 				struct of_endpoint *endpoint);
 bool of_graph_port_type_is(struct device_node *port, char *type);
 bool of_graph_endpoint_type_is(struct device_node *ep, char *type);
+int of_graph_get_endpoint_count(const struct device_node *np, char *type);
 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
 					struct device_node *previous);
@@ -76,6 +78,12 @@ static bool of_graph_endpoint_type_is(struct device_node *ep, char *type)
 	return false;
 }
 
+static inline int of_graph_get_endpoint_count(const struct device_node *np,
+					      char *type)
+{
+	return 0;
+}
+
 static inline struct device_node *of_graph_get_port_by_id(
 					struct device_node *node, u32 id)
 {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-06-24  2:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24  2:30 [PATCH 0/7] of_graph: prepare for ALSA graph support Kuninori Morimoto
2016-06-24  2:32 ` [PATCH 1/7] Documentation: of: add type property Kuninori Morimoto
2016-06-24  2:32   ` Kuninori Morimoto
2016-06-24 17:41   ` Rob Herring
2016-06-27  0:09     ` Kuninori Morimoto
2016-06-27  0:09       ` Kuninori Morimoto
2016-06-27  1:14       ` [alsa-devel] " Kuninori Morimoto
2016-06-27  1:14         ` Kuninori Morimoto
2016-06-24  2:32 ` [PATCH 2/7] of_graph: add of_graph_get_remote_endpoint() Kuninori Morimoto
2017-05-17  9:53   ` Applied "of_graph: add of_graph_get_remote_endpoint()" to the asoc tree Mark Brown
2017-05-17  9:53     ` Mark Brown
2016-06-24  2:32 ` [PATCH 3/7] of_graph: add of_graph_port/endpoint_type_is() Kuninori Morimoto
2016-06-24  2:32   ` Kuninori Morimoto
2016-06-24  2:33 ` Kuninori Morimoto [this message]
2016-06-24  2:33   ` [PATCH 4/7] of_graph: add of_graph_get_endpoint_count() Kuninori Morimoto
2016-06-24  2:33 ` [PATCH 5/7] of_graph: add of_graph_get_port_parent() Kuninori Morimoto
2016-06-24  2:33   ` Kuninori Morimoto
2017-05-17  9:53   ` Applied "of_graph: add of_graph_get_port_parent()" to the asoc tree Mark Brown
2017-05-17  9:53     ` Mark Brown
2016-06-24  2:33 ` [PATCH 6/7] of_graph: add of_graph_get_top_port() Kuninori Morimoto
2016-06-24  2:33   ` Kuninori Morimoto
2016-06-24  4:39   ` kbuild test robot
2016-06-24  9:22     ` Kuninori Morimoto
2016-06-24  9:22       ` Kuninori Morimoto
2016-06-24  2:34 ` [PATCH 7/7] of_graph: add for_each_of_port() / for_each_of_endpoint_in_port() Kuninori Morimoto
2016-06-24  2:34   ` Kuninori Morimoto

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=87a8ibxqy6.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=broonie@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=grant.likely@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.