lkml.org 
[lkml]   [2015]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 07/10] device property: Add fwnode_get_next_child_node()
Date
So callers that have a handle to a firmware node but not any of the
devices related to it can iterate over their descendants.

Also adds fwnode_for_each_child_node().

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
---

drivers/base/property.c | 30 ++++++++++++++++++++++--------
include/linux/property.h | 7 +++++++
2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 3280b04..92cdbb3 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -466,28 +466,42 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,
EXPORT_SYMBOL_GPL(fwnode_property_read_string);

/**
- * 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.
+ * fwnode_get_next_child_node - Return the next child node handle for a fwnode
+ * @fwnode: Firmware node to find the next child node for.
+ * @child: Handle to one of the firmware node's child nodes or a null handle.
*/
-struct fwnode_handle *device_get_next_child_node(struct device *dev,
+struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *fwnode,
struct fwnode_handle *child)
{
- if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
+ if (is_of_node(fwnode)) {
struct device_node *node;

- node = of_get_next_available_child(dev->of_node, to_of_node(child));
+ node = of_get_next_available_child(to_of_node(fwnode),
+ to_of_node(child));
if (node)
return &node->fwnode;
- } else if (IS_ENABLED(CONFIG_ACPI)) {
+ } else if (is_acpi_node(fwnode)) {
struct acpi_device *node;

- node = acpi_get_next_child(dev, to_acpi_node(child));
+ node = acpi_dev_get_next_child(to_acpi_node(fwnode),
+ to_acpi_node(child));
if (node)
return acpi_fwnode_handle(node);
}
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.
+ */
+struct fwnode_handle *device_get_next_child_node(struct device *dev,
+ struct fwnode_handle *child)
+{
+ return fwnode_get_next_child_node(dev->fwnode, child);
+}
EXPORT_SYMBOL_GPL(device_get_next_child_node);

/**
diff --git a/include/linux/property.h b/include/linux/property.h
index 020a53c..cfd1eb2 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -63,6 +63,9 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,
struct fwnode_handle *device_get_next_child_node(struct device *dev,
struct fwnode_handle *child);

+struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *fwnode,
+ struct fwnode_handle *child);
+
struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode);

const char *fwnode_get_name(struct fwnode_handle *fwnode);
@@ -71,6 +74,10 @@ const char *fwnode_get_name(struct fwnode_handle *fwnode);
for (child = device_get_next_child_node(dev, NULL); child; \
child = device_get_next_child_node(dev, child))

+#define fwnode_for_each_child_node(fwnode, child) \
+ for (child = fwnode_get_next_child_node(fwnode, NULL); child; \
+ child = fwnode_get_next_child_node(fwnode, child))
+
void fwnode_handle_put(struct fwnode_handle *fwnode);

unsigned int device_get_child_node_count(struct device *dev);
--
2.4.1


\
 
 \ /
  Last update: 2015-06-30 17:21    [W:0.450 / U:0.732 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site