aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace/nsinit.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/namespace/nsinit.c')
-rw-r--r--drivers/acpi/namespace/nsinit.c257
1 files changed, 118 insertions, 139 deletions
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c
index 362802ae29a2..0a08d2f04a06 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/namespace/nsinit.c
@@ -41,31 +41,22 @@
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/acnamesp.h> 45#include <acpi/acnamesp.h>
47#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49 48
50#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsinit") 50ACPI_MODULE_NAME("nsinit")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54
55static acpi_status 53static acpi_status
56acpi_ns_init_one_object ( 54acpi_ns_init_one_object(acpi_handle obj_handle,
57 acpi_handle obj_handle, 55 u32 level, void *context, void **return_value);
58 u32 level,
59 void *context,
60 void **return_value);
61 56
62static acpi_status 57static acpi_status
63acpi_ns_init_one_device ( 58acpi_ns_init_one_device(acpi_handle obj_handle,
64 acpi_handle obj_handle, 59 u32 nesting_level, void *context, void **return_value);
65 u32 nesting_level,
66 void *context,
67 void **return_value);
68
69 60
70/******************************************************************************* 61/*******************************************************************************
71 * 62 *
@@ -80,52 +71,48 @@ acpi_ns_init_one_device (
80 * 71 *
81 ******************************************************************************/ 72 ******************************************************************************/
82 73
83acpi_status 74acpi_status acpi_ns_initialize_objects(void)
84acpi_ns_initialize_objects (
85 void)
86{ 75{
87 acpi_status status; 76 acpi_status status;
88 struct acpi_init_walk_info info; 77 struct acpi_init_walk_info info;
89
90 78
91 ACPI_FUNCTION_TRACE ("ns_initialize_objects"); 79 ACPI_FUNCTION_TRACE("ns_initialize_objects");
92 80
93 81 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
94 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 82 "**** Starting initialization of namespace objects ****\n"));
95 "**** Starting initialization of namespace objects ****\n")); 83 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
96 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 84 "Completing Region/Field/Buffer/Package initialization:"));
97 "Completing Region/Field/Buffer/Package initialization:"));
98 85
99 /* Set all init info to zero */ 86 /* Set all init info to zero */
100 87
101 ACPI_MEMSET (&info, 0, sizeof (struct acpi_init_walk_info)); 88 ACPI_MEMSET(&info, 0, sizeof(struct acpi_init_walk_info));
102 89
103 /* Walk entire namespace from the supplied root */ 90 /* Walk entire namespace from the supplied root */
104 91
105 status = acpi_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 92 status = acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
106 ACPI_UINT32_MAX, acpi_ns_init_one_object, 93 ACPI_UINT32_MAX, acpi_ns_init_one_object,
107 &info, NULL); 94 &info, NULL);
108 if (ACPI_FAILURE (status)) { 95 if (ACPI_FAILURE(status)) {
109 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed! %s\n", 96 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n",
110 acpi_format_exception (status))); 97 acpi_format_exception(status)));
111 } 98 }
112 99
113 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 100 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
114 "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n", 101 "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n",
115 info.op_region_init, info.op_region_count, 102 info.op_region_init, info.op_region_count,
116 info.field_init, info.field_count, 103 info.field_init, info.field_count,
117 info.buffer_init, info.buffer_count, 104 info.buffer_init, info.buffer_count,
118 info.package_init, info.package_count, info.object_count)); 105 info.package_init, info.package_count,
106 info.object_count));
119 107
120 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 108 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
121 "%hd Control Methods found\n", info.method_count)); 109 "%hd Control Methods found\n", info.method_count));
122 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, 110 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
123 "%hd Op Regions found\n", info.op_region_count)); 111 "%hd Op Regions found\n", info.op_region_count));
124 112
125 return_ACPI_STATUS (AE_OK); 113 return_ACPI_STATUS(AE_OK);
126} 114}
127 115
128
129/******************************************************************************* 116/*******************************************************************************
130 * 117 *
131 * FUNCTION: acpi_ns_initialize_devices 118 * FUNCTION: acpi_ns_initialize_devices
@@ -142,16 +129,12 @@ acpi_ns_initialize_objects (
142 * 129 *
143 ******************************************************************************/ 130 ******************************************************************************/
144 131
145acpi_status 132acpi_status acpi_ns_initialize_devices(void)
146acpi_ns_initialize_devices (
147 void)
148{ 133{
149 acpi_status status; 134 acpi_status status;
150 struct acpi_device_walk_info info; 135 struct acpi_device_walk_info info;
151
152
153 ACPI_FUNCTION_TRACE ("ns_initialize_devices");
154 136
137 ACPI_FUNCTION_TRACE("ns_initialize_devices");
155 138
156 /* Init counters */ 139 /* Init counters */
157 140
@@ -159,34 +142,34 @@ acpi_ns_initialize_devices (
159 info.num_STA = 0; 142 info.num_STA = 0;
160 info.num_INI = 0; 143 info.num_INI = 0;
161 144
162 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 145 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
163 "Executing all Device _STA and_INI methods:")); 146 "Executing all Device _STA and_INI methods:"));
164 147
165 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE); 148 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
166 if (ACPI_FAILURE (status)) { 149 if (ACPI_FAILURE(status)) {
167 return_ACPI_STATUS (status); 150 return_ACPI_STATUS(status);
168 } 151 }
169 152
170 /* Walk namespace for all objects */ 153 /* Walk namespace for all objects */
171 154
172 status = acpi_ns_walk_namespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, 155 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
173 ACPI_UINT32_MAX, TRUE, acpi_ns_init_one_device, &info, NULL); 156 ACPI_UINT32_MAX, TRUE,
157 acpi_ns_init_one_device, &info, NULL);
174 158
175 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE); 159 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
176 160
177 if (ACPI_FAILURE (status)) { 161 if (ACPI_FAILURE(status)) {
178 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed! %s\n", 162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n",
179 acpi_format_exception (status))); 163 acpi_format_exception(status)));
180 } 164 }
181 165
182 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, 166 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
183 "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n", 167 "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n",
184 info.device_count, info.num_STA, info.num_INI)); 168 info.device_count, info.num_STA, info.num_INI));
185 169
186 return_ACPI_STATUS (status); 170 return_ACPI_STATUS(status);
187} 171}
188 172
189
190/******************************************************************************* 173/*******************************************************************************
191 * 174 *
192 * FUNCTION: acpi_ns_init_one_object 175 * FUNCTION: acpi_ns_init_one_object
@@ -208,28 +191,25 @@ acpi_ns_initialize_devices (
208 ******************************************************************************/ 191 ******************************************************************************/
209 192
210static acpi_status 193static acpi_status
211acpi_ns_init_one_object ( 194acpi_ns_init_one_object(acpi_handle obj_handle,
212 acpi_handle obj_handle, 195 u32 level, void *context, void **return_value)
213 u32 level,
214 void *context,
215 void **return_value)
216{ 196{
217 acpi_object_type type; 197 acpi_object_type type;
218 acpi_status status; 198 acpi_status status;
219 struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context; 199 struct acpi_init_walk_info *info =
220 struct acpi_namespace_node *node = (struct acpi_namespace_node *) obj_handle; 200 (struct acpi_init_walk_info *)context;
221 union acpi_operand_object *obj_desc; 201 struct acpi_namespace_node *node =
222 202 (struct acpi_namespace_node *)obj_handle;
223 203 union acpi_operand_object *obj_desc;
224 ACPI_FUNCTION_NAME ("ns_init_one_object");
225 204
205 ACPI_FUNCTION_NAME("ns_init_one_object");
226 206
227 info->object_count++; 207 info->object_count++;
228 208
229 /* And even then, we are only interested in a few object types */ 209 /* And even then, we are only interested in a few object types */
230 210
231 type = acpi_ns_get_type (obj_handle); 211 type = acpi_ns_get_type(obj_handle);
232 obj_desc = acpi_ns_get_attached_object (node); 212 obj_desc = acpi_ns_get_attached_object(node);
233 if (!obj_desc) { 213 if (!obj_desc) {
234 return (AE_OK); 214 return (AE_OK);
235 } 215 }
@@ -269,8 +249,8 @@ acpi_ns_init_one_object (
269 /* 249 /*
270 * Must lock the interpreter before executing AML code 250 * Must lock the interpreter before executing AML code
271 */ 251 */
272 status = acpi_ex_enter_interpreter (); 252 status = acpi_ex_enter_interpreter();
273 if (ACPI_FAILURE (status)) { 253 if (ACPI_FAILURE(status)) {
274 return (status); 254 return (status);
275 } 255 }
276 256
@@ -282,25 +262,25 @@ acpi_ns_init_one_object (
282 case ACPI_TYPE_REGION: 262 case ACPI_TYPE_REGION:
283 263
284 info->op_region_init++; 264 info->op_region_init++;
285 status = acpi_ds_get_region_arguments (obj_desc); 265 status = acpi_ds_get_region_arguments(obj_desc);
286 break; 266 break;
287 267
288 case ACPI_TYPE_BUFFER_FIELD: 268 case ACPI_TYPE_BUFFER_FIELD:
289 269
290 info->field_init++; 270 info->field_init++;
291 status = acpi_ds_get_buffer_field_arguments (obj_desc); 271 status = acpi_ds_get_buffer_field_arguments(obj_desc);
292 break; 272 break;
293 273
294 case ACPI_TYPE_BUFFER: 274 case ACPI_TYPE_BUFFER:
295 275
296 info->buffer_init++; 276 info->buffer_init++;
297 status = acpi_ds_get_buffer_arguments (obj_desc); 277 status = acpi_ds_get_buffer_arguments(obj_desc);
298 break; 278 break;
299 279
300 case ACPI_TYPE_PACKAGE: 280 case ACPI_TYPE_PACKAGE:
301 281
302 info->package_init++; 282 info->package_init++;
303 status = acpi_ds_get_package_arguments (obj_desc); 283 status = acpi_ds_get_package_arguments(obj_desc);
304 break; 284 break;
305 285
306 default: 286 default:
@@ -308,12 +288,13 @@ acpi_ns_init_one_object (
308 break; 288 break;
309 } 289 }
310 290
311 if (ACPI_FAILURE (status)) { 291 if (ACPI_FAILURE(status)) {
312 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "\n")); 292 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, "\n"));
313 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 293 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
314 "Could not execute arguments for [%4.4s] (%s), %s\n", 294 "Could not execute arguments for [%4.4s] (%s), %s\n",
315 acpi_ut_get_node_name (node), acpi_ut_get_type_name (type), 295 acpi_ut_get_node_name(node),
316 acpi_format_exception (status))); 296 acpi_ut_get_type_name(type),
297 acpi_format_exception(status)));
317 } 298 }
318 299
319 /* 300 /*
@@ -321,18 +302,17 @@ acpi_ns_init_one_object (
321 * pathname 302 * pathname
322 */ 303 */
323 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) { 304 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
324 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 305 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
325 } 306 }
326 307
327 /* 308 /*
328 * We ignore errors from above, and always return OK, since we don't want 309 * We ignore errors from above, and always return OK, since we don't want
329 * to abort the walk on any single error. 310 * to abort the walk on any single error.
330 */ 311 */
331 acpi_ex_exit_interpreter (); 312 acpi_ex_exit_interpreter();
332 return (AE_OK); 313 return (AE_OK);
333} 314}
334 315
335
336/******************************************************************************* 316/*******************************************************************************
337 * 317 *
338 * FUNCTION: acpi_ns_init_one_device 318 * FUNCTION: acpi_ns_init_one_device
@@ -348,41 +328,37 @@ acpi_ns_init_one_object (
348 ******************************************************************************/ 328 ******************************************************************************/
349 329
350static acpi_status 330static acpi_status
351acpi_ns_init_one_device ( 331acpi_ns_init_one_device(acpi_handle obj_handle,
352 acpi_handle obj_handle, 332 u32 nesting_level, void *context, void **return_value)
353 u32 nesting_level,
354 void *context,
355 void **return_value)
356{ 333{
357 struct acpi_device_walk_info *info = (struct acpi_device_walk_info *) context; 334 struct acpi_device_walk_info *info =
358 struct acpi_parameter_info pinfo; 335 (struct acpi_device_walk_info *)context;
359 u32 flags; 336 struct acpi_parameter_info pinfo;
360 acpi_status status; 337 u32 flags;
361 338 acpi_status status;
362
363 ACPI_FUNCTION_TRACE ("ns_init_one_device");
364 339
340 ACPI_FUNCTION_TRACE("ns_init_one_device");
365 341
366 pinfo.parameters = NULL; 342 pinfo.parameters = NULL;
367 pinfo.parameter_type = ACPI_PARAM_ARGS; 343 pinfo.parameter_type = ACPI_PARAM_ARGS;
368 344
369 pinfo.node = acpi_ns_map_handle_to_node (obj_handle); 345 pinfo.node = acpi_ns_map_handle_to_node(obj_handle);
370 if (!pinfo.node) { 346 if (!pinfo.node) {
371 return_ACPI_STATUS (AE_BAD_PARAMETER); 347 return_ACPI_STATUS(AE_BAD_PARAMETER);
372 } 348 }
373 349
374 /* 350 /*
375 * We will run _STA/_INI on Devices, Processors and thermal_zones only 351 * We will run _STA/_INI on Devices, Processors and thermal_zones only
376 */ 352 */
377 if ((pinfo.node->type != ACPI_TYPE_DEVICE) && 353 if ((pinfo.node->type != ACPI_TYPE_DEVICE) &&
378 (pinfo.node->type != ACPI_TYPE_PROCESSOR) && 354 (pinfo.node->type != ACPI_TYPE_PROCESSOR) &&
379 (pinfo.node->type != ACPI_TYPE_THERMAL)) { 355 (pinfo.node->type != ACPI_TYPE_THERMAL)) {
380 return_ACPI_STATUS (AE_OK); 356 return_ACPI_STATUS(AE_OK);
381 } 357 }
382 358
383 if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) && 359 if ((acpi_dbg_level <= ACPI_LV_ALL_EXCEPTIONS) &&
384 (!(acpi_dbg_level & ACPI_LV_INFO))) { 360 (!(acpi_dbg_level & ACPI_LV_INFO))) {
385 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); 361 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
386 } 362 }
387 363
388 info->device_count++; 364 info->device_count++;
@@ -390,20 +366,20 @@ acpi_ns_init_one_device (
390 /* 366 /*
391 * Run _STA to determine if we can run _INI on the device. 367 * Run _STA to determine if we can run _INI on the device.
392 */ 368 */
393 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, 369 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD,
394 pinfo.node, METHOD_NAME__STA)); 370 pinfo.node,
395 status = acpi_ut_execute_STA (pinfo.node, &flags); 371 METHOD_NAME__STA));
372 status = acpi_ut_execute_STA(pinfo.node, &flags);
396 373
397 if (ACPI_FAILURE (status)) { 374 if (ACPI_FAILURE(status)) {
398 if (pinfo.node->type == ACPI_TYPE_DEVICE) { 375 if (pinfo.node->type == ACPI_TYPE_DEVICE) {
399 /* Ignore error and move on to next device */ 376 /* Ignore error and move on to next device */
400 377
401 return_ACPI_STATUS (AE_OK); 378 return_ACPI_STATUS(AE_OK);
402 } 379 }
403 380
404 /* _STA is not required for Processor or thermal_zone objects */ 381 /* _STA is not required for Processor or thermal_zone objects */
405 } 382 } else {
406 else {
407 info->num_STA++; 383 info->num_STA++;
408 384
409 if (!(flags & 0x01)) { 385 if (!(flags & 0x01)) {
@@ -416,32 +392,34 @@ acpi_ns_init_one_device (
416 /* 392 /*
417 * The device is present. Run _INI. 393 * The device is present. Run _INI.
418 */ 394 */
419 ACPI_DEBUG_EXEC (acpi_ut_display_init_pathname (ACPI_TYPE_METHOD, 395 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD,
420 pinfo.node, METHOD_NAME__INI)); 396 pinfo.node,
421 status = acpi_ns_evaluate_relative (METHOD_NAME__INI, &pinfo); 397 METHOD_NAME__INI));
422 if (ACPI_FAILURE (status)) { 398 status = acpi_ns_evaluate_relative(METHOD_NAME__INI, &pinfo);
399 if (ACPI_FAILURE(status)) {
423 /* No _INI (AE_NOT_FOUND) means device requires no initialization */ 400 /* No _INI (AE_NOT_FOUND) means device requires no initialization */
424 401
425 if (status != AE_NOT_FOUND) { 402 if (status != AE_NOT_FOUND) {
426 /* Ignore error and move on to next device */ 403 /* Ignore error and move on to next device */
427 404
428#ifdef ACPI_DEBUG_OUTPUT 405#ifdef ACPI_DEBUG_OUTPUT
429 char *scope_name = acpi_ns_get_external_pathname (pinfo.node); 406 char *scope_name =
407 acpi_ns_get_external_pathname(pinfo.node);
430 408
431 ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n", 409 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n",
432 scope_name, acpi_format_exception (status))); 410 scope_name,
411 acpi_format_exception(status)));
433 412
434 ACPI_MEM_FREE (scope_name); 413 ACPI_MEM_FREE(scope_name);
435#endif 414#endif
436 } 415 }
437 416
438 status = AE_OK; 417 status = AE_OK;
439 } 418 } else {
440 else {
441 /* Delete any return object (especially if implicit_return is enabled) */ 419 /* Delete any return object (especially if implicit_return is enabled) */
442 420
443 if (pinfo.return_object) { 421 if (pinfo.return_object) {
444 acpi_ut_remove_reference (pinfo.return_object); 422 acpi_ut_remove_reference(pinfo.return_object);
445 } 423 }
446 424
447 /* Count of successful INIs */ 425 /* Count of successful INIs */
@@ -452,8 +430,9 @@ acpi_ns_init_one_device (
452 if (acpi_gbl_init_handler) { 430 if (acpi_gbl_init_handler) {
453 /* External initialization handler is present, call it */ 431 /* External initialization handler is present, call it */
454 432
455 status = acpi_gbl_init_handler (pinfo.node, ACPI_INIT_DEVICE_INI); 433 status =
434 acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI);
456 } 435 }
457 436
458 return_ACPI_STATUS (status); 437 return_ACPI_STATUS(status);
459} 438}