]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
ACPICA: Namespace: Add acpi_ns_handle_to_name()
authorLv Zheng <lv.zheng@intel.com>
Wed, 30 Nov 2016 07:20:52 +0000 (15:20 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 1 Dec 2016 13:25:44 +0000 (14:25 +0100)
ACPICA commit f9fe27a68a90c9d32dd3156241a5e788fb6956ea

This patch adds acpi_ns_handle_to_name() so that in the acpi_get_name():
1. Logics can be made simpler,
2. Lock held for acpi_ns_handle_to_name() can also be applied to
   acpi_ns_handle_to_pathname().
The lock might be useless (see Link 1 below), but kept as acpi_get_name()
is an external API. Except the lock correction, this patch is a functional
no-op. BZ 1182, Lv Zheng.

Link: https://github.com/acpica/acpica/commit/f9fe27a6
Link: https://bugs.acpica.org/show_bug.cgi?id=1182
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/acpica/acnamesp.h
drivers/acpi/acpica/nsnames.c
drivers/acpi/acpica/nsxfname.c

index bb7fca1c8ba307add15b588cd38a64084275d037..7affdcdfcc816e827651f83c82979fd398c74a14 100644 (file)
@@ -291,6 +291,9 @@ char *acpi_ns_get_normalized_pathname(struct acpi_namespace_node *node,
 
 char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state);
 
+acpi_status
+acpi_ns_handle_to_name(acpi_handle target_handle, struct acpi_buffer *buffer);
+
 acpi_status
 acpi_ns_handle_to_pathname(acpi_handle target_handle,
                           struct acpi_buffer *buffer, u8 no_trailing);
index f03dd41e86d023b521e90fe4aa6cd1ef635ff3be..94d5d3339845f954110c5214305c775117c3d231 100644 (file)
@@ -95,6 +95,51 @@ acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
        return (size);
 }
 
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_handle_to_name
+ *
+ * PARAMETERS:  target_handle           - Handle of named object whose name is
+ *                                        to be found
+ *              buffer                  - Where the name is returned
+ *
+ * RETURN:      Status, Buffer is filled with name if status is AE_OK
+ *
+ * DESCRIPTION: Build and return a full namespace name
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_ns_handle_to_name(acpi_handle target_handle, struct acpi_buffer *buffer)
+{
+       acpi_status status;
+       struct acpi_namespace_node *node;
+       const char *node_name;
+
+       ACPI_FUNCTION_TRACE_PTR(ns_handle_to_name, target_handle);
+
+       node = acpi_ns_validate_handle(target_handle);
+       if (!node) {
+               return_ACPI_STATUS(AE_BAD_PARAMETER);
+       }
+
+       /* Validate/Allocate/Clear caller buffer */
+
+       status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
+       if (ACPI_FAILURE(status)) {
+               return_ACPI_STATUS(status);
+       }
+
+       /* Just copy the ACPI name from the Node and zero terminate it */
+
+       node_name = acpi_ut_get_node_name(node);
+       ACPI_MOVE_NAME(buffer->pointer, node_name);
+       ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
+
+       ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%4.4s\n", (char *)buffer->pointer));
+       return_ACPI_STATUS(AE_OK);
+}
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ns_handle_to_pathname
index 76a1bd4bb0700aa6ff6b129b399ed3ebdd729ba8..e525cbe7d83b63966e9050ebd6d8bbfb36c3fa9f 100644 (file)
@@ -158,8 +158,6 @@ acpi_status
 acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer *buffer)
 {
        acpi_status status;
-       struct acpi_namespace_node *node;
-       const char *node_name;
 
        /* Parameter validation */
 
@@ -172,18 +170,6 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer *buffer)
                return (status);
        }
 
-       if (name_type == ACPI_FULL_PATHNAME ||
-           name_type == ACPI_FULL_PATHNAME_NO_TRAILING) {
-
-               /* Get the full pathname (From the namespace root) */
-
-               status = acpi_ns_handle_to_pathname(handle, buffer,
-                                                   name_type ==
-                                                   ACPI_FULL_PATHNAME ? FALSE :
-                                                   TRUE);
-               return (status);
-       }
-
        /*
         * Wants the single segment ACPI name.
         * Validate handle and convert to a namespace Node
@@ -193,27 +179,20 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer *buffer)
                return (status);
        }
 
-       node = acpi_ns_validate_handle(handle);
-       if (!node) {
-               status = AE_BAD_PARAMETER;
-               goto unlock_and_exit;
-       }
-
-       /* Validate/Allocate/Clear caller buffer */
-
-       status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
-       if (ACPI_FAILURE(status)) {
-               goto unlock_and_exit;
-       }
+       if (name_type == ACPI_FULL_PATHNAME ||
+           name_type == ACPI_FULL_PATHNAME_NO_TRAILING) {
 
-       /* Just copy the ACPI name from the Node and zero terminate it */
+               /* Get the full pathname (From the namespace root) */
 
-       node_name = acpi_ut_get_node_name(node);
-       ACPI_MOVE_NAME(buffer->pointer, node_name);
-       ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
-       status = AE_OK;
+               status = acpi_ns_handle_to_pathname(handle, buffer,
+                                                   name_type ==
+                                                   ACPI_FULL_PATHNAME ? FALSE :
+                                                   TRUE);
+       } else {
+               /* Get the single name */
 
-unlock_and_exit:
+               status = acpi_ns_handle_to_name(handle, buffer);
+       }
 
        (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
        return (status);