aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/executer/exnames.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/executer/exnames.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/executer/exnames.c')
-rw-r--r--drivers/acpi/executer/exnames.c235
1 files changed, 106 insertions, 129 deletions
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c
index b6ba1a7a677a..239d8473e9a5 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/executer/exnames.c
@@ -42,26 +42,18 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48#include <acpi/amlcode.h> 47#include <acpi/amlcode.h>
49 48
50#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exnames") 50ACPI_MODULE_NAME("exnames")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54 53static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs);
55static char *
56acpi_ex_allocate_name_string (
57 u32 prefix_count,
58 u32 num_name_segs);
59 54
60static acpi_status 55static acpi_status
61acpi_ex_name_segment ( 56acpi_ex_name_segment(u8 ** in_aml_address, char *name_string);
62 u8 **in_aml_address,
63 char *name_string);
64
65 57
66/******************************************************************************* 58/*******************************************************************************
67 * 59 *
@@ -79,17 +71,13 @@ acpi_ex_name_segment (
79 * 71 *
80 ******************************************************************************/ 72 ******************************************************************************/
81 73
82static char * 74static char *acpi_ex_allocate_name_string(u32 prefix_count, u32 num_name_segs)
83acpi_ex_allocate_name_string (
84 u32 prefix_count,
85 u32 num_name_segs)
86{ 75{
87 char *temp_ptr; 76 char *temp_ptr;
88 char *name_string; 77 char *name_string;
89 u32 size_needed; 78 u32 size_needed;
90
91 ACPI_FUNCTION_TRACE ("ex_allocate_name_string");
92 79
80 ACPI_FUNCTION_TRACE("ex_allocate_name_string");
93 81
94 /* 82 /*
95 * Allow room for all \ and ^ prefixes, all segments and a multi_name_prefix. 83 * Allow room for all \ and ^ prefixes, all segments and a multi_name_prefix.
@@ -100,20 +88,19 @@ acpi_ex_allocate_name_string (
100 /* Special case for root */ 88 /* Special case for root */
101 89
102 size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1; 90 size_needed = 1 + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
103 } 91 } else {
104 else { 92 size_needed =
105 size_needed = prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1; 93 prefix_count + (ACPI_NAME_SIZE * num_name_segs) + 2 + 1;
106 } 94 }
107 95
108 /* 96 /*
109 * Allocate a buffer for the name. 97 * Allocate a buffer for the name.
110 * This buffer must be deleted by the caller! 98 * This buffer must be deleted by the caller!
111 */ 99 */
112 name_string = ACPI_MEM_ALLOCATE (size_needed); 100 name_string = ACPI_MEM_ALLOCATE(size_needed);
113 if (!name_string) { 101 if (!name_string) {
114 ACPI_REPORT_ERROR (( 102 ACPI_REPORT_ERROR(("ex_allocate_name_string: Could not allocate size %d\n", size_needed));
115 "ex_allocate_name_string: Could not allocate size %d\n", size_needed)); 103 return_PTR(NULL);
116 return_PTR (NULL);
117 } 104 }
118 105
119 temp_ptr = name_string; 106 temp_ptr = name_string;
@@ -122,23 +109,20 @@ acpi_ex_allocate_name_string (
122 109
123 if (prefix_count == ACPI_UINT32_MAX) { 110 if (prefix_count == ACPI_UINT32_MAX) {
124 *temp_ptr++ = AML_ROOT_PREFIX; 111 *temp_ptr++ = AML_ROOT_PREFIX;
125 } 112 } else {
126 else {
127 while (prefix_count--) { 113 while (prefix_count--) {
128 *temp_ptr++ = AML_PARENT_PREFIX; 114 *temp_ptr++ = AML_PARENT_PREFIX;
129 } 115 }
130 } 116 }
131 117
132
133 /* Set up Dual or Multi prefixes if needed */ 118 /* Set up Dual or Multi prefixes if needed */
134 119
135 if (num_name_segs > 2) { 120 if (num_name_segs > 2) {
136 /* Set up multi prefixes */ 121 /* Set up multi prefixes */
137 122
138 *temp_ptr++ = AML_MULTI_NAME_PREFIX_OP; 123 *temp_ptr++ = AML_MULTI_NAME_PREFIX_OP;
139 *temp_ptr++ = (char) num_name_segs; 124 *temp_ptr++ = (char)num_name_segs;
140 } 125 } else if (2 == num_name_segs) {
141 else if (2 == num_name_segs) {
142 /* Set up dual prefixes */ 126 /* Set up dual prefixes */
143 127
144 *temp_ptr++ = AML_DUAL_NAME_PREFIX; 128 *temp_ptr++ = AML_DUAL_NAME_PREFIX;
@@ -150,7 +134,7 @@ acpi_ex_allocate_name_string (
150 */ 134 */
151 *temp_ptr = 0; 135 *temp_ptr = 0;
152 136
153 return_PTR (name_string); 137 return_PTR(name_string);
154} 138}
155 139
156/******************************************************************************* 140/*******************************************************************************
@@ -167,19 +151,14 @@ acpi_ex_allocate_name_string (
167 * 151 *
168 ******************************************************************************/ 152 ******************************************************************************/
169 153
170static acpi_status 154static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
171acpi_ex_name_segment (
172 u8 **in_aml_address,
173 char *name_string)
174{ 155{
175 char *aml_address = (void *) *in_aml_address; 156 char *aml_address = (void *)*in_aml_address;
176 acpi_status status = AE_OK; 157 acpi_status status = AE_OK;
177 u32 index; 158 u32 index;
178 char char_buf[5]; 159 char char_buf[5];
179
180
181 ACPI_FUNCTION_TRACE ("ex_name_segment");
182 160
161 ACPI_FUNCTION_TRACE("ex_name_segment");
183 162
184 /* 163 /*
185 * If first character is a digit, then we know that we aren't looking at a 164 * If first character is a digit, then we know that we aren't looking at a
@@ -188,20 +167,20 @@ acpi_ex_name_segment (
188 char_buf[0] = *aml_address; 167 char_buf[0] = *aml_address;
189 168
190 if ('0' <= char_buf[0] && char_buf[0] <= '9') { 169 if ('0' <= char_buf[0] && char_buf[0] <= '9') {
191 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "leading digit: %c\n", char_buf[0])); 170 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "leading digit: %c\n",
192 return_ACPI_STATUS (AE_CTRL_PENDING); 171 char_buf[0]));
172 return_ACPI_STATUS(AE_CTRL_PENDING);
193 } 173 }
194 174
195 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); 175 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Bytes from stream:\n"));
196 176
197 for (index = 0; 177 for (index = 0;
198 (index < ACPI_NAME_SIZE) && (acpi_ut_valid_acpi_character (*aml_address)); 178 (index < ACPI_NAME_SIZE)
199 index++) { 179 && (acpi_ut_valid_acpi_character(*aml_address)); index++) {
200 char_buf[index] = *aml_address++; 180 char_buf[index] = *aml_address++;
201 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", char_buf[index])); 181 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index]));
202 } 182 }
203 183
204
205 /* Valid name segment */ 184 /* Valid name segment */
206 185
207 if (index == 4) { 186 if (index == 4) {
@@ -210,41 +189,37 @@ acpi_ex_name_segment (
210 char_buf[4] = '\0'; 189 char_buf[4] = '\0';
211 190
212 if (name_string) { 191 if (name_string) {
213 ACPI_STRCAT (name_string, char_buf); 192 ACPI_STRCAT(name_string, char_buf);
214 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, 193 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
215 "Appended to - %s \n", name_string)); 194 "Appended to - %s \n", name_string));
195 } else {
196 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
197 "No Name string - %s \n", char_buf));
216 } 198 }
217 else { 199 } else if (index == 0) {
218 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES,
219 "No Name string - %s \n", char_buf));
220 }
221 }
222 else if (index == 0) {
223 /* 200 /*
224 * First character was not a valid name character, 201 * First character was not a valid name character,
225 * so we are looking at something other than a name. 202 * so we are looking at something other than a name.
226 */ 203 */
227 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 204 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
228 "Leading character is not alpha: %02Xh (not a name)\n", 205 "Leading character is not alpha: %02Xh (not a name)\n",
229 char_buf[0])); 206 char_buf[0]));
230 status = AE_CTRL_PENDING; 207 status = AE_CTRL_PENDING;
231 } 208 } else {
232 else {
233 /* 209 /*
234 * Segment started with one or more valid characters, but fewer than 210 * Segment started with one or more valid characters, but fewer than
235 * the required 4 211 * the required 4
236 */ 212 */
237 status = AE_AML_BAD_NAME; 213 status = AE_AML_BAD_NAME;
238 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 214 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
239 "Bad character %02x in name, at %p\n", 215 "Bad character %02x in name, at %p\n",
240 *aml_address, aml_address)); 216 *aml_address, aml_address));
241 } 217 }
242 218
243 *in_aml_address = (u8 *) aml_address; 219 *in_aml_address = (u8 *) aml_address;
244 return_ACPI_STATUS (status); 220 return_ACPI_STATUS(status);
245} 221}
246 222
247
248/******************************************************************************* 223/*******************************************************************************
249 * 224 *
250 * FUNCTION: acpi_ex_get_name_string 225 * FUNCTION: acpi_ex_get_name_string
@@ -263,37 +238,32 @@ acpi_ex_name_segment (
263 ******************************************************************************/ 238 ******************************************************************************/
264 239
265acpi_status 240acpi_status
266acpi_ex_get_name_string ( 241acpi_ex_get_name_string(acpi_object_type data_type,
267 acpi_object_type data_type, 242 u8 * in_aml_address,
268 u8 *in_aml_address, 243 char **out_name_string, u32 * out_name_length)
269 char **out_name_string,
270 u32 *out_name_length)
271{ 244{
272 acpi_status status = AE_OK; 245 acpi_status status = AE_OK;
273 u8 *aml_address = in_aml_address; 246 u8 *aml_address = in_aml_address;
274 char *name_string = NULL; 247 char *name_string = NULL;
275 u32 num_segments; 248 u32 num_segments;
276 u32 prefix_count = 0; 249 u32 prefix_count = 0;
277 u8 has_prefix = FALSE; 250 u8 has_prefix = FALSE;
278 251
279 252 ACPI_FUNCTION_TRACE_PTR("ex_get_name_string", aml_address);
280 ACPI_FUNCTION_TRACE_PTR ("ex_get_name_string", aml_address); 253
281 254 if (ACPI_TYPE_LOCAL_REGION_FIELD == data_type ||
282 255 ACPI_TYPE_LOCAL_BANK_FIELD == data_type ||
283 if (ACPI_TYPE_LOCAL_REGION_FIELD == data_type || 256 ACPI_TYPE_LOCAL_INDEX_FIELD == data_type) {
284 ACPI_TYPE_LOCAL_BANK_FIELD == data_type ||
285 ACPI_TYPE_LOCAL_INDEX_FIELD == data_type) {
286 /* Disallow prefixes for types associated with field_unit names */ 257 /* Disallow prefixes for types associated with field_unit names */
287 258
288 name_string = acpi_ex_allocate_name_string (0, 1); 259 name_string = acpi_ex_allocate_name_string(0, 1);
289 if (!name_string) { 260 if (!name_string) {
290 status = AE_NO_MEMORY; 261 status = AE_NO_MEMORY;
262 } else {
263 status =
264 acpi_ex_name_segment(&aml_address, name_string);
291 } 265 }
292 else { 266 } else {
293 status = acpi_ex_name_segment (&aml_address, name_string);
294 }
295 }
296 else {
297 /* 267 /*
298 * data_type is not a field name. 268 * data_type is not a field name.
299 * Examine first character of name for root or parent prefix operators 269 * Examine first character of name for root or parent prefix operators
@@ -301,8 +271,9 @@ acpi_ex_get_name_string (
301 switch (*aml_address) { 271 switch (*aml_address) {
302 case AML_ROOT_PREFIX: 272 case AML_ROOT_PREFIX:
303 273
304 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "root_prefix(\\) at %p\n", 274 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
305 aml_address)); 275 "root_prefix(\\) at %p\n",
276 aml_address));
306 277
307 /* 278 /*
308 * Remember that we have a root_prefix -- 279 * Remember that we have a root_prefix --
@@ -313,14 +284,14 @@ acpi_ex_get_name_string (
313 has_prefix = TRUE; 284 has_prefix = TRUE;
314 break; 285 break;
315 286
316
317 case AML_PARENT_PREFIX: 287 case AML_PARENT_PREFIX:
318 288
319 /* Increment past possibly multiple parent prefixes */ 289 /* Increment past possibly multiple parent prefixes */
320 290
321 do { 291 do {
322 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "parent_prefix (^) at %p\n", 292 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
323 aml_address)); 293 "parent_prefix (^) at %p\n",
294 aml_address));
324 295
325 aml_address++; 296 aml_address++;
326 prefix_count++; 297 prefix_count++;
@@ -330,7 +301,6 @@ acpi_ex_get_name_string (
330 has_prefix = TRUE; 301 has_prefix = TRUE;
331 break; 302 break;
332 303
333
334 default: 304 default:
335 305
336 /* Not a prefix character */ 306 /* Not a prefix character */
@@ -343,11 +313,13 @@ acpi_ex_get_name_string (
343 switch (*aml_address) { 313 switch (*aml_address) {
344 case AML_DUAL_NAME_PREFIX: 314 case AML_DUAL_NAME_PREFIX:
345 315
346 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "dual_name_prefix at %p\n", 316 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
347 aml_address)); 317 "dual_name_prefix at %p\n",
318 aml_address));
348 319
349 aml_address++; 320 aml_address++;
350 name_string = acpi_ex_allocate_name_string (prefix_count, 2); 321 name_string =
322 acpi_ex_allocate_name_string(prefix_count, 2);
351 if (!name_string) { 323 if (!name_string) {
352 status = AE_NO_MEMORY; 324 status = AE_NO_MEMORY;
353 break; 325 break;
@@ -357,24 +329,29 @@ acpi_ex_get_name_string (
357 329
358 has_prefix = TRUE; 330 has_prefix = TRUE;
359 331
360 status = acpi_ex_name_segment (&aml_address, name_string); 332 status =
361 if (ACPI_SUCCESS (status)) { 333 acpi_ex_name_segment(&aml_address, name_string);
362 status = acpi_ex_name_segment (&aml_address, name_string); 334 if (ACPI_SUCCESS(status)) {
335 status =
336 acpi_ex_name_segment(&aml_address,
337 name_string);
363 } 338 }
364 break; 339 break;
365 340
366
367 case AML_MULTI_NAME_PREFIX_OP: 341 case AML_MULTI_NAME_PREFIX_OP:
368 342
369 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "multi_name_prefix at %p\n", 343 ACPI_DEBUG_PRINT((ACPI_DB_LOAD,
370 aml_address)); 344 "multi_name_prefix at %p\n",
345 aml_address));
371 346
372 /* Fetch count of segments remaining in name path */ 347 /* Fetch count of segments remaining in name path */
373 348
374 aml_address++; 349 aml_address++;
375 num_segments = *aml_address; 350 num_segments = *aml_address;
376 351
377 name_string = acpi_ex_allocate_name_string (prefix_count, num_segments); 352 name_string =
353 acpi_ex_allocate_name_string(prefix_count,
354 num_segments);
378 if (!name_string) { 355 if (!name_string) {
379 status = AE_NO_MEMORY; 356 status = AE_NO_MEMORY;
380 break; 357 break;
@@ -386,27 +363,28 @@ acpi_ex_get_name_string (
386 has_prefix = TRUE; 363 has_prefix = TRUE;
387 364
388 while (num_segments && 365 while (num_segments &&
389 (status = acpi_ex_name_segment (&aml_address, name_string)) == 366 (status =
390 AE_OK) { 367 acpi_ex_name_segment(&aml_address,
368 name_string)) == AE_OK) {
391 num_segments--; 369 num_segments--;
392 } 370 }
393 371
394 break; 372 break;
395 373
396
397 case 0: 374 case 0:
398 375
399 /* null_name valid as of 8-12-98 ASL/AML Grammar Update */ 376 /* null_name valid as of 8-12-98 ASL/AML Grammar Update */
400 377
401 if (prefix_count == ACPI_UINT32_MAX) { 378 if (prefix_count == ACPI_UINT32_MAX) {
402 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 379 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
403 "name_seg is \"\\\" followed by NULL\n")); 380 "name_seg is \"\\\" followed by NULL\n"));
404 } 381 }
405 382
406 /* Consume the NULL byte */ 383 /* Consume the NULL byte */
407 384
408 aml_address++; 385 aml_address++;
409 name_string = acpi_ex_allocate_name_string (prefix_count, 0); 386 name_string =
387 acpi_ex_allocate_name_string(prefix_count, 0);
410 if (!name_string) { 388 if (!name_string) {
411 status = AE_NO_MEMORY; 389 status = AE_NO_MEMORY;
412 break; 390 break;
@@ -414,18 +392,19 @@ acpi_ex_get_name_string (
414 392
415 break; 393 break;
416 394
417
418 default: 395 default:
419 396
420 /* Name segment string */ 397 /* Name segment string */
421 398
422 name_string = acpi_ex_allocate_name_string (prefix_count, 1); 399 name_string =
400 acpi_ex_allocate_name_string(prefix_count, 1);
423 if (!name_string) { 401 if (!name_string) {
424 status = AE_NO_MEMORY; 402 status = AE_NO_MEMORY;
425 break; 403 break;
426 } 404 }
427 405
428 status = acpi_ex_name_segment (&aml_address, name_string); 406 status =
407 acpi_ex_name_segment(&aml_address, name_string);
429 break; 408 break;
430 } 409 }
431 } 410 }
@@ -433,22 +412,20 @@ acpi_ex_get_name_string (
433 if (AE_CTRL_PENDING == status && has_prefix) { 412 if (AE_CTRL_PENDING == status && has_prefix) {
434 /* Ran out of segments after processing a prefix */ 413 /* Ran out of segments after processing a prefix */
435 414
436 ACPI_REPORT_ERROR ( 415 ACPI_REPORT_ERROR(("ex_do_name: Malformed Name at %p\n",
437 ("ex_do_name: Malformed Name at %p\n", name_string)); 416 name_string));
438 status = AE_AML_BAD_NAME; 417 status = AE_AML_BAD_NAME;
439 } 418 }
440 419
441 if (ACPI_FAILURE (status)) { 420 if (ACPI_FAILURE(status)) {
442 if (name_string) { 421 if (name_string) {
443 ACPI_MEM_FREE (name_string); 422 ACPI_MEM_FREE(name_string);
444 } 423 }
445 return_ACPI_STATUS (status); 424 return_ACPI_STATUS(status);
446 } 425 }
447 426
448 *out_name_string = name_string; 427 *out_name_string = name_string;
449 *out_name_length = (u32) (aml_address - in_aml_address); 428 *out_name_length = (u32) (aml_address - in_aml_address);
450 429
451 return_ACPI_STATUS (status); 430 return_ACPI_STATUS(status);
452} 431}
453
454