diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2017-03-28 09:52:17 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-03-29 00:00:27 +0200 |
commit | afaf26fd8458be29949ae5a52c65a464a1b0cbb6 (patch) | |
tree | d73b4b4f73b0fe5aa5df5bc4932aa5fa3c8a9d8d /drivers/base/property.c | |
parent | ACPI / property: Add possiblity to retrieve parent firmware node (diff) | |
download | linux-afaf26fd8458be29949ae5a52c65a464a1b0cbb6.tar.xz linux-afaf26fd8458be29949ae5a52c65a464a1b0cbb6.zip |
device property: Add fwnode_get_parent()
Now that ACPI has support for returning parent firmware node for both types
of nodes we can expose this to others as well. This adds a new function
fwnode_get_parent() that can be used for DT and ACPI nodes to retrieve the
parent firmware node.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/property.c')
-rw-r--r-- | drivers/base/property.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/base/property.c b/drivers/base/property.c index c458c63e353f..a25233430d18 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -932,6 +932,31 @@ int device_add_properties(struct device *dev, EXPORT_SYMBOL_GPL(device_add_properties); /** + * fwnode_get_parent - Return parent firwmare node + * @fwnode: Firmware whose parent is retrieved + * + * Return parent firmware node of the given node if possible or %NULL if no + * parent was available. + */ +struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode) +{ + struct fwnode_handle *parent = NULL; + + if (is_of_node(fwnode)) { + struct device_node *node; + + node = of_get_parent(to_of_node(fwnode)); + if (node) + parent = &node->fwnode; + } else if (is_acpi_node(fwnode)) { + parent = acpi_node_get_parent(fwnode); + } + + return parent; +} +EXPORT_SYMBOL_GPL(fwnode_get_parent); + +/** * 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. |