[PATCH 3/3] ACPI: property: Rework acpi_graph_get_next_endpoint()

Sakari Ailus posted 3 patches 10 hours ago
[PATCH 3/3] ACPI: property: Rework acpi_graph_get_next_endpoint()
Posted by Sakari Ailus 10 hours ago
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 <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/acpi/property.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 200e5d717f16..c07f45929a25 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1421,14 +1421,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
-- 
2.47.3
Re: [PATCH 3/3] ACPI: property: Rework acpi_graph_get_next_endpoint()
Posted by Laurent Pinchart 9 hours ago
On Wed, Oct 01, 2025 at 01:43:20PM +0300, Sakari Ailus wrote:
> 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 <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

> ---
>  drivers/acpi/property.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
> index 200e5d717f16..c07f45929a25 100644
> --- a/drivers/acpi/property.c
> +++ b/drivers/acpi/property.c
> @@ -1421,14 +1421,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

-- 
Regards,

Laurent Pinchart