ACPI / property: Add fwnode_get_next_child_node()
The ACPI _DSD hierarchical data extension makes it possible to have hierarchies deeper than one level in similar way than DT allows. These "subsubnodes" have not been accessible because device property implementation only provides device_get_next_child_node() that is limited to direct descendants of a device. We need this ability in order support things like remote endpoints currently supported in DT with of_graph_* APIs. Modify acpi_get_next_subnode() to accept fwnode handle instead and update callers accordingly. Also add a new function fwnode_get_next_child_node() that works directly with fwnodes and modify device_get_next_child_node() to call it directly. While there add a macro fwnode_for_each_child_node() analogous to the current device_for_each_child_node() but it works with fwnodes instead of devices. Link: http://www.uefi.org/sites/default/files/resources/_DSD-hierarchical-data-extension-UUID-v1.pdf Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:

committed by
Rafael J. Wysocki

parent
afaf26fd84
commit
34055190b1
@@ -956,6 +956,29 @@ struct fwnode_handle *fwnode_get_parent(struct fwnode_handle *fwnode)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(fwnode_get_parent);
|
||||
|
||||
/**
|
||||
* fwnode_get_next_child_node - Return the next child node handle for a node
|
||||
* @fwnode: Firmware node to find the next child node for.
|
||||
* @child: Handle to one of the node's child nodes or a %NULL handle.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
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.
|
||||
@@ -964,16 +987,15 @@ EXPORT_SYMBOL_GPL(fwnode_get_parent);
|
||||
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;
|
||||
struct acpi_device *adev = ACPI_COMPANION(dev);
|
||||
struct fwnode_handle *fwnode = NULL;
|
||||
|
||||
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, child);
|
||||
}
|
||||
return NULL;
|
||||
if (dev->of_node)
|
||||
fwnode = &dev->of_node->fwnode;
|
||||
else if (adev)
|
||||
fwnode = acpi_fwnode_handle(adev);
|
||||
|
||||
return fwnode_get_next_child_node(fwnode, child);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(device_get_next_child_node);
|
||||
|
||||
|
Reference in New Issue
Block a user