Skip to content

Commit

Permalink
device property: Add fwnode_get_parent()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mika Westerberg authored and Rafael J. Wysocki committed Mar 28, 2017
1 parent dfa672f commit afaf26f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions drivers/base/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,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.
Expand Down
2 changes: 2 additions & 0 deletions include/linux/property.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,
int fwnode_property_match_string(struct fwnode_handle *fwnode,
const char *propname, const char *string);

struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode);

struct fwnode_handle *device_get_next_child_node(struct device *dev,
struct fwnode_handle *child);

Expand Down

0 comments on commit afaf26f

Please sign in to comment.