Skip to content

Commit d9f866b

Browse files
Sakari Ailusrafaeljw
authored andcommitted
ACPI: property: Return present device nodes only on fwnode interface
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>
1 parent 0f83b1d commit d9f866b

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
@@ -1358,6 +1358,28 @@ struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
13581358
return NULL;
13591359
}
13601360

1361+
/*
1362+
* acpi_get_next_present_subnode - Return the next present child node handle
1363+
* @fwnode: Firmware node to find the next child node for.
1364+
* @child: Handle to one of the device's child nodes or a null handle.
1365+
*
1366+
* Like acpi_get_next_subnode(), but the device nodes returned by
1367+
* acpi_get_next_present_subnode() are guaranteed to be present.
1368+
*
1369+
* Returns: The fwnode handle of the next present sub-node.
1370+
*/
1371+
static struct fwnode_handle *
1372+
acpi_get_next_present_subnode(const struct fwnode_handle *fwnode,
1373+
struct fwnode_handle *child)
1374+
{
1375+
do {
1376+
child = acpi_get_next_subnode(fwnode, child);
1377+
} while (is_acpi_device_node(child) &&
1378+
!acpi_device_is_present(to_acpi_device_node(child)));
1379+
1380+
return child;
1381+
}
1382+
13611383
/**
13621384
* acpi_node_get_parent - Return parent fwnode of this fwnode
13631385
* @fwnode: Firmware node whose parent to get
@@ -1702,7 +1724,7 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode,
17021724
.property_read_string_array = \
17031725
acpi_fwnode_property_read_string_array, \
17041726
.get_parent = acpi_node_get_parent, \
1705-
.get_next_child_node = acpi_get_next_subnode, \
1727+
.get_next_child_node = acpi_get_next_present_subnode, \
17061728
.get_named_child_node = acpi_fwnode_get_named_child_node, \
17071729
.get_name = acpi_fwnode_get_name, \
17081730
.get_name_prefix = acpi_fwnode_get_name_prefix, \

0 commit comments

Comments
 (0)