Change the implementation of fwnode_property_get_parent() function to use
struct fwnode_operations.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/acpi/property.c | 1 +
drivers/base/property.c | 13 +------------
drivers/of/base.c | 14 ++++++++++++++
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index a20b81f..fc1d5da 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1161,4 +1161,5 @@ const struct fwnode_operations acpi_fwnode_ops = {
.property_read_int_array = acpi_fwnode_property_read_int_array,
.property_read_string_array = acpi_fwnode_property_read_string_array,
.get_parent = acpi_fwnode_get_parent,
+ .get_next_child_node = acpi_get_next_subnode,
};diff --git a/drivers/base/property.c b/drivers/base/property.c
index e730f4f..e9068b1 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -875,18 +875,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_parent);
struct fwnode_handle *fwnode_get_next_child_node(struct fwnode_handle *fwnode,
struct fwnode_handle *child)
{
- if (is_of_node(fwnode)) {
- struct device_node *node;
-
- node = of_get_next_available_child(to_of_node(fwnode),
- to_of_node(child));
- if (node)
- return &node->fwnode;
- } else if (is_acpi_node(fwnode)) {
- return acpi_get_next_subnode(fwnode, child);
- }
-
- return NULL;
+ return fwnode_call_ptr_op(fwnode, get_next_child_node, child);
}
EXPORT_SYMBOL_GPL(fwnode_get_next_child_node);
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 5825eda..66a7970 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2542,6 +2542,19 @@ static struct fwnode_handle *of_fwnode_get_parent(struct fwnode_handle *fwnode)
return NULL;
}
+static struct fwnode_handle *of_fwnode_get_next_child_node(
+ struct fwnode_handle *fwnode, struct fwnode_handle *child)
+{
+ struct device_node *node;
+
+ node = of_get_next_available_child(to_of_node(fwnode),
+ to_of_node(child));
+ if (node)
+ return of_fwnode_handle(node);
+
+ return NULL;
+}
+
const struct fwnode_operations of_fwnode_ops = {
.get = of_fwnode_get,
.put = of_fwnode_put,@@ -2549,4 +2562,5 @@ const struct fwnode_operations of_fwnode_ops = {
.property_read_int_array = of_fwnode_property_read_int_array,
.property_read_string_array = of_fwnode_property_read_string_array,
.get_parent = of_fwnode_get_parent,
+ .get_next_child_node = of_fwnode_get_next_child_node,
};--
2.7.4