Skip to content

Commit a0d1fb8

Browse files
Sakari AilusUlrich Hecht
authored andcommitted
ACPI: property: Return present device nodes only on fwnode interface
[ Upstream commit d9f866b2bb3eec38b3734f1fed325ec7c55ccdfa ] fwnode_graph_get_next_subnode() may return fwnode backed by ACPI device nodes and there has been no check these devices are present in the system, unlike there has been on fwnode OF backend. In order to provide consistent behaviour towards callers, add a check for device presence by introducing a new function acpi_get_next_present_subnode(), used as the get_next_child_node() fwnode operation that also checks device node presence. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Link: https://patch.msgid.link/20251001102636.1272722-2-sakari.ailus@linux.intel.com [ rjw: Kerneldoc comment and changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Ulrich Hecht <uli@kernel.org>
1 parent 0e853d2 commit a0d1fb8

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

drivers/acpi/property.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,28 @@ struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
10341034
return NULL;
10351035
}
10361036

1037+
/*
1038+
* acpi_get_next_present_subnode - Return the next present child node handle
1039+
* @fwnode: Firmware node to find the next child node for.
1040+
* @child: Handle to one of the device's child nodes or a null handle.
1041+
*
1042+
* Like acpi_get_next_subnode(), but the device nodes returned by
1043+
* acpi_get_next_present_subnode() are guaranteed to be present.
1044+
*
1045+
* Returns: The fwnode handle of the next present sub-node.
1046+
*/
1047+
static struct fwnode_handle *
1048+
acpi_get_next_present_subnode(const struct fwnode_handle *fwnode,
1049+
struct fwnode_handle *child)
1050+
{
1051+
do {
1052+
child = acpi_get_next_subnode(fwnode, child);
1053+
} while (is_acpi_device_node(child) &&
1054+
!acpi_device_is_present(to_acpi_device_node(child)));
1055+
1056+
return child;
1057+
}
1058+
10371059
/**
10381060
* acpi_node_get_parent - Return parent fwnode of this fwnode
10391061
* @fwnode: Firmware node whose parent to get
@@ -1307,7 +1329,7 @@ acpi_fwnode_device_get_match_data(const struct fwnode_handle *fwnode,
13071329
.property_read_string_array = \
13081330
acpi_fwnode_property_read_string_array, \
13091331
.get_parent = acpi_node_get_parent, \
1310-
.get_next_child_node = acpi_get_next_subnode, \
1332+
.get_next_child_node = acpi_get_next_present_subnode, \
13111333
.get_named_child_node = acpi_fwnode_get_named_child_node, \
13121334
.get_reference_args = acpi_fwnode_get_reference_args, \
13131335
.graph_get_next_endpoint = \

0 commit comments

Comments
 (0)