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: <20170125000641.25520-4-furquan@chromium.org>
Date:   Tue, 24 Jan 2017 16:06:37 -0800
From:   Furquan Shaikh <furquan@...omium.org>
To:     "Rafael J . Wysocki" <rjw@...ysocki.net>,
        Mark Brown <broonie@...nel.org>
Cc:     Liam Girdwood <lgirdwood@...il.com>,
        Tony Lindgren <tony@...mide.com>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Len Brown <lenb@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Hanjun Guo <hanjun.guo@...aro.org>,
        Will Deacon <will.deacon@....com>,
        Rob Herring <robh@...nel.org>,
        Sathyanarayana Nujella <sathyanarayana.nujella@...el.com>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Adam Thomson <Adam.Thomson.Opensource@...semi.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Alexandre Courbot <gnurou@...il.com>,
        linux-gpio@...r.kernel.org, linux-acpi@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-omap@...r.kernel.org,
        Dmitry Torokhov <dtor@...omium.org>,
        Furquan Shaikh <furquan@...omium.org>
Subject: [PATCH 3/7] device property: introduce fwnode_for_each_child()

From: Dmitry Torokhov <dtor@...omium.org>

Generic code, that wishes to work with ACPI, device tree, and pset
properties needs iterator that can work with fwnode_handle.

Signed-off-by: Dmitry Torokhov <dtor@...omium.org>
Signed-off-by: Furquan Shaikh <furquan@...omium.org>
---
 drivers/base/property.c | 33 +++++++++++++++++++++++----------
 include/linux/fwnode.h  |  7 +++++++
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index f2f8220534c4..fbb05a4a7595 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -867,6 +867,28 @@ int device_add_properties(struct device *dev, struct property_entry *properties)
 EXPORT_SYMBOL_GPL(device_add_properties);
 
 /**
+ * fwnode_get_next_child_node - Return the next child node handle for a device
+ * @node: Node to find the next child node for.
+ * @child: Handle to one of the device's child nodes or a null handle.
+ */
+struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *node,
+						 struct fwnode_handle *child)
+{
+	if (IS_ENABLED(CONFIG_OF) && is_of_node(node)) {
+		struct device_node *np;
+
+		np = of_get_next_available_child(to_of_node(node),
+						   to_of_node(child));
+		if (np)
+			return &np->fwnode;
+	} else if (IS_ENABLED(CONFIG_ACPI) && is_acpi_node(node)) {
+		return acpi_get_next_subnode(node, child);
+	}
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(fwnode_get_next_child_node);
+
+/**
  * device_get_next_child_node - Return the next child node handle for a device
  * @dev: Device to find the next child node for.
  * @child: Handle to one of the device's child nodes or a null handle.
@@ -874,16 +896,7 @@ EXPORT_SYMBOL_GPL(device_add_properties);
 struct fwnode_handle *device_get_next_child_node(struct device *dev,
 						 struct fwnode_handle *child)
 {
-	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
-		struct device_node *node;
-
-		node = of_get_next_available_child(dev->of_node, to_of_node(child));
-		if (node)
-			return &node->fwnode;
-	} else if (IS_ENABLED(CONFIG_ACPI)) {
-		return acpi_get_next_subnode(dev->fwnode, child);
-	}
-	return NULL;
+	return fwnode_get_next_child_node(dev_fwnode(dev), child);
 }
 EXPORT_SYMBOL_GPL(device_get_next_child_node);
 
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 8bd28ce6d76e..b4efe2a088ae 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -27,4 +27,11 @@ struct fwnode_handle {
 	struct fwnode_handle *secondary;
 };
 
+struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *node,
+						 struct fwnode_handle *child);
+
+#define fwnode_for_each_child_node(node, child) \
+	for (child = fwnode_get_next_child_node(node, NULL); child; \
+	     child = fwnode_get_next_child_node(node, child))
+
 #endif
-- 
2.11.0.483.g087da7b7c-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ