From: Sakari Ailus Date: Wed, 1 Oct 2025 10:43:20 +0000 (+0300) Subject: ACPI: property: Rework acpi_graph_get_next_endpoint() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b889ed5abf4796671b742692fdca35c4002892ee;p=thirdparty%2Flinux.git ACPI: property: Rework acpi_graph_get_next_endpoint() Rework the code obtaining the next endpoint in acpi_graph_get_next_endpoint(). The resulting code removes unnecessary contitionals and should be easier to follow. Suggested-by: Andy Shevchenko Signed-off-by: Sakari Ailus Reviewed-by: Laurent Pinchart Link: https://patch.msgid.link/20251001104320.1272752-4-sakari.ailus@linux.intel.com Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index b88bad197fca9..73171d277ab62 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1491,14 +1491,17 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint( if (!port) return NULL; - endpoint = acpi_get_next_subnode(port, prev); - while (!endpoint) { - port = acpi_get_next_subnode(fwnode, port); - if (!port) + do { + endpoint = acpi_get_next_subnode(port, prev); + if (endpoint) break; - if (is_acpi_graph_node(port, "port")) - endpoint = acpi_get_next_subnode(port, NULL); - } + + prev = NULL; + + do { + port = acpi_get_next_subnode(fwnode, port); + } while (port && !is_acpi_graph_node(port, "port")); + } while (port); /* * The names of the endpoint nodes begin with "endpoint@" followed by