Skip to contentSkip to conversation

ACPI property cleanups

PATCH In review Sakari Ailus 2 participants 5 messages Oct 1, 2025 ACPI

lore
Share & tools
lore
#0 lore raw

cover ACPI property cleanups

Hello everyone,

This is a small set of ACPI property cleanups.

The previous set including with the tree-wide changes can be found here <URL:https://lore.kernel.org/linux-acpi/CAJZ5v0gQ9vnT+Z8zryEausp-2xX7HocoBgwmiptxg7BGiU9C8g@mail.gmail.com/T/#t>.

No functional change intended.

since tree-wide set v2 <[email protected]>, WRT. this patch:

- Don't use kernel-doc functions to document static functions in .c files.

- Use more robust algorithm for enumerating sub-nodes (thanks to Laurent).

since v1 <[email protected]> (entire tree-wide set):

- Move patch "ACPI: property: Make acpi_get_next_subnode() static" as first.

- Add missing parentheses and kernel-doc Return: section in acpi_get_next_present_subnode() documentation and move the Return
section: of fwnode_graph_get_endpoint_by_id() to the end of the documentation section (new patch for the latter).

- Use device_get_next_child_node() instead of fwnode_get_next_child_node() in flash LED driver drivers.

- Rework iterating port nodes in acpi_graph_get_next_endpoint() as suggested by Andy (new patch).

Sakari Ailus (3):
ACPI: property: Make acpi_get_next_subnode() static
ACPI: property: Use ACPI functions in acpi_graph_get_next_endpoint()
only
ACPI: property: Rework acpi_graph_get_next_endpoint()

 drivers/acpi/property.c | 26 +++++++++++++++-----------
 include/linux/acpi.h    | 10 ----------
 2 files changed, 15 insertions(+), 21 deletions(-)
Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/3 ACPI: property: Make acpi_get_next_subnode() static

acpi_get_next_subnode() is only used in drivers/acpi/property.c. Remove its prototype from include/linux/acpi.h and make it static.

---
 drivers/acpi/property.c |  7 ++++---
 include/linux/acpi.h    | 10 ----------
 2 files changed, 4 insertions(+), 13 deletions(-)
drivers/acpi/property.c +4 -3
index 10bab30300f3..59ed2d9f1007 100644
@@ -1259,13 +1259,14 @@ static int stop_on_next(struct acpi_device *adev, void *data)
 	return 0;
 }
 
-/**
+/*
  * acpi_get_next_subnode - Return the next child node handle for a fwnode
  * @fwnode: Firmware node to find the next child node for.
  * @child: Handle to one of the device's child nodes or a null handle.
  */
-struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
-					    struct fwnode_handle *child)
+static struct fwnode_handle *
+acpi_get_next_subnode(const struct fwnode_handle *fwnode,
+		      struct fwnode_handle *child)
 {
 	struct acpi_device *adev = to_acpi_device_node(fwnode);
 
include/linux/acpi.h +0 -10
index 5ff5d99f6ead..703323b9fe0c 100644
@@ -1349,9 +1349,6 @@ acpi_data_add_props(struct acpi_device_data *data, const guid_t *guid,
 int acpi_node_prop_get(const struct fwnode_handle *fwnode, const char *propname,
 		       void **valptr);
 
-struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
-					    struct fwnode_handle *child);
-
 struct acpi_probe_entry;
 typedef bool (*acpi_probe_entry_validate_subtbl)(struct acpi_subtable_header *,
 						 struct acpi_probe_entry *);
@@ -1450,13 +1447,6 @@ static inline int acpi_node_prop_get(const struct fwnode_handle *fwnode,
 	return -ENXIO;
 }
 
-static inline struct fwnode_handle *
-acpi_get_next_subnode(const struct fwnode_handle *fwnode,
-		      struct fwnode_handle *child)
-{
-	return NULL;
-}
-
 static inline struct fwnode_handle *
 acpi_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
 			     struct fwnode_handle *prev)
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/3 ACPI: property: Use ACPI functions in acpi_graph_get_next_endpoint() only

In reply to Sakari Ailus

Calling fwnode_get_next_child_node() in ACPI implementation of the fwnode property API is somewhat problematic as the latter is used in the impelementation of the former. Instead of using fwnode_get_next_child_node() in acpi_graph_get_next_endpoint(), call acpi_get_next_subnode() directly instead.

---
 drivers/acpi/property.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/property.c +4 -4
index 59ed2d9f1007..200e5d717f16 100644
@@ -1403,7 +1403,7 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint(
 
 	if (!prev) {
 		do {
-			port = fwnode_get_next_child_node(fwnode, port);
+			port = acpi_get_next_subnode(fwnode, port);
 			/*
 			 * The names of the port nodes begin with "port@"
 			 * followed by the number of the port node and they also
@@ -1421,13 +1421,13 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint(
 	if (!port)
 		return NULL;
 
-	endpoint = fwnode_get_next_child_node(port, prev);
+	endpoint = acpi_get_next_subnode(port, prev);
 	while (!endpoint) {
-		port = fwnode_get_next_child_node(fwnode, port);
+		port = acpi_get_next_subnode(fwnode, port);
 		if (!port)
 			break;
 		if (is_acpi_graph_node(port, "port"))
-			endpoint = fwnode_get_next_child_node(port, NULL);
+			endpoint = acpi_get_next_subnode(port, NULL);
 	}
 
 	/*
Signature · 1 line
2.47.3
#3 lore raw

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

In reply to Sakari Ailus

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.

---
 drivers/acpi/property.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/acpi/property.c +10 -7
index 200e5d717f16..c07f45929a25 100644
@@ -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
Signature · 1 line
2.47.3
Reviewed-by on v1 3/3
#4 lore raw

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

Quoted 6 lines · Sakari Ailus

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.

Quoted 33 lines
---
 drivers/acpi/property.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/acpi/property.c +10 -7
index 200e5d717f16..c07f45929a25 100644
@@ -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
Signature · 3 lines
Regards,

Laurent Pinchart