lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87a8ibxqy6.wl%kuninori.morimoto.gx@renesas.com>
Date:	Fri, 24 Jun 2016 02:33:20 +0000
From:	Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
To:	Rob Herring <robh+dt@...nel.org>, Mark Brown <broonie@...aro.org>,
	Mark Brown <broonie@...nel.org>,
	Laurent <laurent.pinchart@...asonboard.com>,
	Guennadi <g.liakhovetski@....de>,
	Grant Likely <grant.likely@...aro.org>,
	Frank Rowand <frowand.list@...il.com>
CC:	Linux-Kernel <linux-kernel@...r.kernel.org>,
	Linux-DT <devicetree@...r.kernel.org>,
	Linux-ALSA <alsa-devel@...a-project.org>
Subject: [PATCH 4/7] of_graph: add of_graph_get_endpoint_count()


From: Kuninori Morimoto <kuninori.morimoto.gx@...esas.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@...esas.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ