aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace/nsnames.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/namespace/nsnames.c')
-rw-r--r--drivers/acpi/namespace/nsnames.c118
1 files changed, 46 insertions, 72 deletions
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index d8ce7e39795f..d5e8dea61c27 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -41,23 +41,17 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 45#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49
50#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsnames") 49ACPI_MODULE_NAME("nsnames")
52 50
53/* Local prototypes */ 51/* Local prototypes */
54
55static void 52static void
56acpi_ns_build_external_path ( 53acpi_ns_build_external_path(struct acpi_namespace_node *node,
57 struct acpi_namespace_node *node, 54 acpi_size size, char *name_buffer);
58 acpi_size size,
59 char *name_buffer);
60
61 55
62/******************************************************************************* 56/*******************************************************************************
63 * 57 *
@@ -75,17 +69,13 @@ acpi_ns_build_external_path (
75 ******************************************************************************/ 69 ******************************************************************************/
76 70
77static void 71static void
78acpi_ns_build_external_path ( 72acpi_ns_build_external_path(struct acpi_namespace_node *node,
79 struct acpi_namespace_node *node, 73 acpi_size size, char *name_buffer)
80 acpi_size size,
81 char *name_buffer)
82{ 74{
83 acpi_size index; 75 acpi_size index;
84 struct acpi_namespace_node *parent_node; 76 struct acpi_namespace_node *parent_node;
85
86
87 ACPI_FUNCTION_NAME ("ns_build_external_path");
88 77
78 ACPI_FUNCTION_NAME("ns_build_external_path");
89 79
90 /* Special case for root */ 80 /* Special case for root */
91 81
@@ -106,8 +96,8 @@ acpi_ns_build_external_path (
106 96
107 /* Put the name into the buffer */ 97 /* Put the name into the buffer */
108 98
109 ACPI_MOVE_32_TO_32 ((name_buffer + index), &parent_node->name); 99 ACPI_MOVE_32_TO_32((name_buffer + index), &parent_node->name);
110 parent_node = acpi_ns_get_parent_node (parent_node); 100 parent_node = acpi_ns_get_parent_node(parent_node);
111 101
112 /* Prefix name with the path separator */ 102 /* Prefix name with the path separator */
113 103
@@ -120,15 +110,14 @@ acpi_ns_build_external_path (
120 name_buffer[index] = AML_ROOT_PREFIX; 110 name_buffer[index] = AML_ROOT_PREFIX;
121 111
122 if (index != 0) { 112 if (index != 0) {
123 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
124 "Could not construct pathname; index=%X, size=%X, Path=%s\n", 114 "Could not construct pathname; index=%X, size=%X, Path=%s\n",
125 (u32) index, (u32) size, &name_buffer[size])); 115 (u32) index, (u32) size, &name_buffer[size]));
126 } 116 }
127 117
128 return; 118 return;
129} 119}
130 120
131
132#ifdef ACPI_DEBUG_OUTPUT 121#ifdef ACPI_DEBUG_OUTPUT
133/******************************************************************************* 122/*******************************************************************************
134 * 123 *
@@ -144,37 +133,32 @@ acpi_ns_build_external_path (
144 * 133 *
145 ******************************************************************************/ 134 ******************************************************************************/
146 135
147char * 136char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
148acpi_ns_get_external_pathname (
149 struct acpi_namespace_node *node)
150{ 137{
151 char *name_buffer; 138 char *name_buffer;
152 acpi_size size; 139 acpi_size size;
153
154
155 ACPI_FUNCTION_TRACE_PTR ("ns_get_external_pathname", node);
156 140
141 ACPI_FUNCTION_TRACE_PTR("ns_get_external_pathname", node);
157 142
158 /* Calculate required buffer size based on depth below root */ 143 /* Calculate required buffer size based on depth below root */
159 144
160 size = acpi_ns_get_pathname_length (node); 145 size = acpi_ns_get_pathname_length(node);
161 146
162 /* Allocate a buffer to be returned to caller */ 147 /* Allocate a buffer to be returned to caller */
163 148
164 name_buffer = ACPI_MEM_CALLOCATE (size); 149 name_buffer = ACPI_MEM_CALLOCATE(size);
165 if (!name_buffer) { 150 if (!name_buffer) {
166 ACPI_REPORT_ERROR (("ns_get_table_pathname: allocation failure\n")); 151 ACPI_REPORT_ERROR(("ns_get_table_pathname: allocation failure\n"));
167 return_PTR (NULL); 152 return_PTR(NULL);
168 } 153 }
169 154
170 /* Build the path in the allocated buffer */ 155 /* Build the path in the allocated buffer */
171 156
172 acpi_ns_build_external_path (node, size, name_buffer); 157 acpi_ns_build_external_path(node, size, name_buffer);
173 return_PTR (name_buffer); 158 return_PTR(name_buffer);
174} 159}
175#endif 160#endif
176 161
177
178/******************************************************************************* 162/*******************************************************************************
179 * 163 *
180 * FUNCTION: acpi_ns_get_pathname_length 164 * FUNCTION: acpi_ns_get_pathname_length
@@ -187,16 +171,12 @@ acpi_ns_get_external_pathname (
187 * 171 *
188 ******************************************************************************/ 172 ******************************************************************************/
189 173
190acpi_size 174acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node)
191acpi_ns_get_pathname_length (
192 struct acpi_namespace_node *node)
193{ 175{
194 acpi_size size; 176 acpi_size size;
195 struct acpi_namespace_node *next_node; 177 struct acpi_namespace_node *next_node;
196
197
198 ACPI_FUNCTION_ENTRY ();
199 178
179 ACPI_FUNCTION_ENTRY();
200 180
201 /* 181 /*
202 * Compute length of pathname as 5 * number of name segments. 182 * Compute length of pathname as 5 * number of name segments.
@@ -207,17 +187,16 @@ acpi_ns_get_pathname_length (
207 187
208 while (next_node && (next_node != acpi_gbl_root_node)) { 188 while (next_node && (next_node != acpi_gbl_root_node)) {
209 size += ACPI_PATH_SEGMENT_LENGTH; 189 size += ACPI_PATH_SEGMENT_LENGTH;
210 next_node = acpi_ns_get_parent_node (next_node); 190 next_node = acpi_ns_get_parent_node(next_node);
211 } 191 }
212 192
213 if (!size) { 193 if (!size) {
214 size = 1; /* Root node case */ 194 size = 1; /* Root node case */
215 } 195 }
216 196
217 return (size + 1); /* +1 for null string terminator */ 197 return (size + 1); /* +1 for null string terminator */
218} 198}
219 199
220
221/******************************************************************************* 200/*******************************************************************************
222 * 201 *
223 * FUNCTION: acpi_ns_handle_to_pathname 202 * FUNCTION: acpi_ns_handle_to_pathname
@@ -233,41 +212,36 @@ acpi_ns_get_pathname_length (
233 ******************************************************************************/ 212 ******************************************************************************/
234 213
235acpi_status 214acpi_status
236acpi_ns_handle_to_pathname ( 215acpi_ns_handle_to_pathname(acpi_handle target_handle,
237 acpi_handle target_handle, 216 struct acpi_buffer * buffer)
238 struct acpi_buffer *buffer)
239{ 217{
240 acpi_status status; 218 acpi_status status;
241 struct acpi_namespace_node *node; 219 struct acpi_namespace_node *node;
242 acpi_size required_size; 220 acpi_size required_size;
243 221
222 ACPI_FUNCTION_TRACE_PTR("ns_handle_to_pathname", target_handle);
244 223
245 ACPI_FUNCTION_TRACE_PTR ("ns_handle_to_pathname", target_handle); 224 node = acpi_ns_map_handle_to_node(target_handle);
246
247
248 node = acpi_ns_map_handle_to_node (target_handle);
249 if (!node) { 225 if (!node) {
250 return_ACPI_STATUS (AE_BAD_PARAMETER); 226 return_ACPI_STATUS(AE_BAD_PARAMETER);
251 } 227 }
252 228
253 /* Determine size required for the caller buffer */ 229 /* Determine size required for the caller buffer */
254 230
255 required_size = acpi_ns_get_pathname_length (node); 231 required_size = acpi_ns_get_pathname_length(node);
256 232
257 /* Validate/Allocate/Clear caller buffer */ 233 /* Validate/Allocate/Clear caller buffer */
258 234
259 status = acpi_ut_initialize_buffer (buffer, required_size); 235 status = acpi_ut_initialize_buffer(buffer, required_size);
260 if (ACPI_FAILURE (status)) { 236 if (ACPI_FAILURE(status)) {
261 return_ACPI_STATUS (status); 237 return_ACPI_STATUS(status);
262 } 238 }
263 239
264 /* Build the path in the caller buffer */ 240 /* Build the path in the caller buffer */
265 241
266 acpi_ns_build_external_path (node, required_size, buffer->pointer); 242 acpi_ns_build_external_path(node, required_size, buffer->pointer);
267 243
268 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", 244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%s [%X] \n",
269 (char *) buffer->pointer, (u32) required_size)); 245 (char *)buffer->pointer, (u32) required_size));
270 return_ACPI_STATUS (AE_OK); 246 return_ACPI_STATUS(AE_OK);
271} 247}
272
273