aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2016-11-30 02:20:52 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-12-01 08:25:44 -0500
commit523db19bdc35ecb76fceeb83a0a34da8d78b2689 (patch)
tree18f75edc22a36191578beff32ed6c88da2f4c40b
parentd0ab6714c53c9d7f3e42b7ea2e108afbd7449305 (diff)
ACPICA: Namespace: Add acpi_ns_handle_to_name()
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 [# 1] 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>
-rw-r--r--drivers/acpi/acpica/acnamesp.h3
-rw-r--r--drivers/acpi/acpica/nsnames.c45
-rw-r--r--drivers/acpi/acpica/nsxfname.c43
3 files changed, 59 insertions, 32 deletions
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index bb7fca1c8ba3..7affdcdfcc81 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -292,6 +292,9 @@ char *acpi_ns_get_normalized_pathname(struct acpi_namespace_node *node,
292char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state); 292char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state);
293 293
294acpi_status 294acpi_status
295acpi_ns_handle_to_name(acpi_handle target_handle, struct acpi_buffer *buffer);
296
297acpi_status
295acpi_ns_handle_to_pathname(acpi_handle target_handle, 298acpi_ns_handle_to_pathname(acpi_handle target_handle,
296 struct acpi_buffer *buffer, u8 no_trailing); 299 struct acpi_buffer *buffer, u8 no_trailing);
297 300
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index f03dd41e86d0..94d5d3339845 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -97,6 +97,51 @@ acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
97 97
98/******************************************************************************* 98/*******************************************************************************
99 * 99 *
100 * FUNCTION: acpi_ns_handle_to_name
101 *
102 * PARAMETERS: target_handle - Handle of named object whose name is
103 * to be found
104 * buffer - Where the name is returned
105 *
106 * RETURN: Status, Buffer is filled with name if status is AE_OK
107 *
108 * DESCRIPTION: Build and return a full namespace name
109 *
110 ******************************************************************************/
111
112acpi_status
113acpi_ns_handle_to_name(acpi_handle target_handle, struct acpi_buffer *buffer)
114{
115 acpi_status status;
116 struct acpi_namespace_node *node;
117 const char *node_name;
118
119 ACPI_FUNCTION_TRACE_PTR(ns_handle_to_name, target_handle);
120
121 node = acpi_ns_validate_handle(target_handle);
122 if (!node) {
123 return_ACPI_STATUS(AE_BAD_PARAMETER);
124 }
125
126 /* Validate/Allocate/Clear caller buffer */
127
128 status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
129 if (ACPI_FAILURE(status)) {
130 return_ACPI_STATUS(status);
131 }
132
133 /* Just copy the ACPI name from the Node and zero terminate it */
134
135 node_name = acpi_ut_get_node_name(node);
136 ACPI_MOVE_NAME(buffer->pointer, node_name);
137 ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
138
139 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%4.4s\n", (char *)buffer->pointer));
140 return_ACPI_STATUS(AE_OK);
141}
142
143/*******************************************************************************
144 *
100 * FUNCTION: acpi_ns_handle_to_pathname 145 * FUNCTION: acpi_ns_handle_to_pathname
101 * 146 *
102 * PARAMETERS: target_handle - Handle of named object whose name is 147 * PARAMETERS: target_handle - Handle of named object whose name is
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index 76a1bd4bb070..e525cbe7d83b 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -158,8 +158,6 @@ acpi_status
158acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer *buffer) 158acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer *buffer)
159{ 159{
160 acpi_status status; 160 acpi_status status;
161 struct acpi_namespace_node *node;
162 const char *node_name;
163 161
164 /* Parameter validation */ 162 /* Parameter validation */
165 163
@@ -172,18 +170,6 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer *buffer)
172 return (status); 170 return (status);
173 } 171 }
174 172
175 if (name_type == ACPI_FULL_PATHNAME ||
176 name_type == ACPI_FULL_PATHNAME_NO_TRAILING) {
177
178 /* Get the full pathname (From the namespace root) */
179
180 status = acpi_ns_handle_to_pathname(handle, buffer,
181 name_type ==
182 ACPI_FULL_PATHNAME ? FALSE :
183 TRUE);
184 return (status);
185 }
186
187 /* 173 /*
188 * Wants the single segment ACPI name. 174 * Wants the single segment ACPI name.
189 * Validate handle and convert to a namespace Node 175 * 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)
193 return (status); 179 return (status);
194 } 180 }
195 181
196 node = acpi_ns_validate_handle(handle); 182 if (name_type == ACPI_FULL_PATHNAME ||
197 if (!node) { 183 name_type == ACPI_FULL_PATHNAME_NO_TRAILING) {
198 status = AE_BAD_PARAMETER;
199 goto unlock_and_exit;
200 }
201
202 /* Validate/Allocate/Clear caller buffer */
203
204 status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
205 if (ACPI_FAILURE(status)) {
206 goto unlock_and_exit;
207 }
208 184
209 /* Just copy the ACPI name from the Node and zero terminate it */ 185 /* Get the full pathname (From the namespace root) */
210 186
211 node_name = acpi_ut_get_node_name(node); 187 status = acpi_ns_handle_to_pathname(handle, buffer,
212 ACPI_MOVE_NAME(buffer->pointer, node_name); 188 name_type ==
213 ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0; 189 ACPI_FULL_PATHNAME ? FALSE :
214 status = AE_OK; 190 TRUE);
191 } else {
192 /* Get the single name */
215 193
216unlock_and_exit: 194 status = acpi_ns_handle_to_name(handle, buffer);
195 }
217 196
218 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 197 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
219 return (status); 198 return (status);