diff options
Diffstat (limited to 'drivers/acpi/namespace/nsinit.c')
-rw-r--r-- | drivers/acpi/namespace/nsinit.c | 105 |
1 files changed, 56 insertions, 49 deletions
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c index 0a08d2f04a06..9f929e479fd8 100644 --- a/drivers/acpi/namespace/nsinit.c +++ b/drivers/acpi/namespace/nsinit.c | |||
@@ -5,7 +5,7 @@ | |||
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
7 | /* | 7 | /* |
8 | * Copyright (C) 2000 - 2005, R. Byron Moore | 8 | * Copyright (C) 2000 - 2006, R. Byron Moore |
9 | * All rights reserved. | 9 | * All rights reserved. |
10 | * | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without |
@@ -93,8 +93,7 @@ acpi_status acpi_ns_initialize_objects(void) | |||
93 | ACPI_UINT32_MAX, acpi_ns_init_one_object, | 93 | ACPI_UINT32_MAX, acpi_ns_init_one_object, |
94 | &info, NULL); | 94 | &info, NULL); |
95 | if (ACPI_FAILURE(status)) { | 95 | if (ACPI_FAILURE(status)) { |
96 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", | 96 | ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace")); |
97 | acpi_format_exception(status))); | ||
98 | } | 97 | } |
99 | 98 | ||
100 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, | 99 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, |
@@ -159,12 +158,11 @@ acpi_status acpi_ns_initialize_devices(void) | |||
159 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 158 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
160 | 159 | ||
161 | if (ACPI_FAILURE(status)) { | 160 | if (ACPI_FAILURE(status)) { |
162 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", | 161 | ACPI_EXCEPTION((AE_INFO, status, "During walk_namespace")); |
163 | acpi_format_exception(status))); | ||
164 | } | 162 | } |
165 | 163 | ||
166 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, | 164 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, |
167 | "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n", | 165 | "\n%hd Devices found - executed %hd _STA, %hd _INI methods\n", |
168 | info.device_count, info.num_STA, info.num_INI)); | 166 | info.device_count, info.num_STA, info.num_INI)); |
169 | 167 | ||
170 | return_ACPI_STATUS(status); | 168 | return_ACPI_STATUS(status); |
@@ -289,12 +287,10 @@ acpi_ns_init_one_object(acpi_handle obj_handle, | |||
289 | } | 287 | } |
290 | 288 | ||
291 | if (ACPI_FAILURE(status)) { | 289 | if (ACPI_FAILURE(status)) { |
292 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, "\n")); | 290 | ACPI_EXCEPTION((AE_INFO, status, |
293 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | 291 | "Could not execute arguments for [%4.4s] (%s)", |
294 | "Could not execute arguments for [%4.4s] (%s), %s\n", | 292 | acpi_ut_get_node_name(node), |
295 | acpi_ut_get_node_name(node), | 293 | acpi_ut_get_type_name(type))); |
296 | acpi_ut_get_type_name(type), | ||
297 | acpi_format_exception(status))); | ||
298 | } | 294 | } |
299 | 295 | ||
300 | /* | 296 | /* |
@@ -336,23 +332,22 @@ acpi_ns_init_one_device(acpi_handle obj_handle, | |||
336 | struct acpi_parameter_info pinfo; | 332 | struct acpi_parameter_info pinfo; |
337 | u32 flags; | 333 | u32 flags; |
338 | acpi_status status; | 334 | acpi_status status; |
335 | struct acpi_namespace_node *ini_node; | ||
336 | struct acpi_namespace_node *device_node; | ||
339 | 337 | ||
340 | ACPI_FUNCTION_TRACE("ns_init_one_device"); | 338 | ACPI_FUNCTION_TRACE("ns_init_one_device"); |
341 | 339 | ||
342 | pinfo.parameters = NULL; | 340 | device_node = acpi_ns_map_handle_to_node(obj_handle); |
343 | pinfo.parameter_type = ACPI_PARAM_ARGS; | 341 | if (!device_node) { |
344 | |||
345 | pinfo.node = acpi_ns_map_handle_to_node(obj_handle); | ||
346 | if (!pinfo.node) { | ||
347 | return_ACPI_STATUS(AE_BAD_PARAMETER); | 342 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
348 | } | 343 | } |
349 | 344 | ||
350 | /* | 345 | /* |
351 | * We will run _STA/_INI on Devices, Processors and thermal_zones only | 346 | * We will run _STA/_INI on Devices, Processors and thermal_zones only |
352 | */ | 347 | */ |
353 | if ((pinfo.node->type != ACPI_TYPE_DEVICE) && | 348 | if ((device_node->type != ACPI_TYPE_DEVICE) && |
354 | (pinfo.node->type != ACPI_TYPE_PROCESSOR) && | 349 | (device_node->type != ACPI_TYPE_PROCESSOR) && |
355 | (pinfo.node->type != ACPI_TYPE_THERMAL)) { | 350 | (device_node->type != ACPI_TYPE_THERMAL)) { |
356 | return_ACPI_STATUS(AE_OK); | 351 | return_ACPI_STATUS(AE_OK); |
357 | } | 352 | } |
358 | 353 | ||
@@ -364,57 +359,69 @@ acpi_ns_init_one_device(acpi_handle obj_handle, | |||
364 | info->device_count++; | 359 | info->device_count++; |
365 | 360 | ||
366 | /* | 361 | /* |
367 | * Run _STA to determine if we can run _INI on the device. | 362 | * Check if the _INI method exists for this device - |
363 | * if _INI does not exist, there is no need to run _STA | ||
364 | * No _INI means device requires no initialization | ||
365 | */ | ||
366 | status = acpi_ns_search_node(*ACPI_CAST_PTR(u32, METHOD_NAME__INI), | ||
367 | device_node, ACPI_TYPE_METHOD, &ini_node); | ||
368 | if (ACPI_FAILURE(status)) { | ||
369 | /* No _INI method found - move on to next device */ | ||
370 | |||
371 | return_ACPI_STATUS(AE_OK); | ||
372 | } | ||
373 | |||
374 | /* | ||
375 | * Run _STA to determine if we can run _INI on the device - | ||
376 | * the device must be present before _INI can be run. | ||
377 | * However, _STA is not required - assume device present if no _STA | ||
368 | */ | 378 | */ |
369 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, | 379 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, |
370 | pinfo.node, | 380 | device_node, |
371 | METHOD_NAME__STA)); | 381 | METHOD_NAME__STA)); |
372 | status = acpi_ut_execute_STA(pinfo.node, &flags); | ||
373 | 382 | ||
383 | pinfo.node = device_node; | ||
384 | pinfo.parameters = NULL; | ||
385 | pinfo.parameter_type = ACPI_PARAM_ARGS; | ||
386 | |||
387 | status = acpi_ut_execute_STA(pinfo.node, &flags); | ||
374 | if (ACPI_FAILURE(status)) { | 388 | if (ACPI_FAILURE(status)) { |
375 | if (pinfo.node->type == ACPI_TYPE_DEVICE) { | 389 | /* Ignore error and move on to next device */ |
376 | /* Ignore error and move on to next device */ | ||
377 | 390 | ||
378 | return_ACPI_STATUS(AE_OK); | 391 | return_ACPI_STATUS(AE_OK); |
379 | } | 392 | } |
380 | 393 | ||
381 | /* _STA is not required for Processor or thermal_zone objects */ | 394 | if (flags != ACPI_UINT32_MAX) { |
382 | } else { | ||
383 | info->num_STA++; | 395 | info->num_STA++; |
396 | } | ||
384 | 397 | ||
385 | if (!(flags & 0x01)) { | 398 | if (!(flags & ACPI_STA_DEVICE_PRESENT)) { |
386 | /* Don't look at children of a not present device */ | 399 | /* Don't look at children of a not present device */ |
387 | 400 | ||
388 | return_ACPI_STATUS(AE_CTRL_DEPTH); | 401 | return_ACPI_STATUS(AE_CTRL_DEPTH); |
389 | } | ||
390 | } | 402 | } |
391 | 403 | ||
392 | /* | 404 | /* |
393 | * The device is present. Run _INI. | 405 | * The device is present and _INI exists. Run the _INI method. |
406 | * (We already have the _INI node from above) | ||
394 | */ | 407 | */ |
395 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, | 408 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, |
396 | pinfo.node, | 409 | pinfo.node, |
397 | METHOD_NAME__INI)); | 410 | METHOD_NAME__INI)); |
398 | status = acpi_ns_evaluate_relative(METHOD_NAME__INI, &pinfo); | ||
399 | if (ACPI_FAILURE(status)) { | ||
400 | /* No _INI (AE_NOT_FOUND) means device requires no initialization */ | ||
401 | 411 | ||
402 | if (status != AE_NOT_FOUND) { | 412 | pinfo.node = ini_node; |
403 | /* Ignore error and move on to next device */ | 413 | status = acpi_ns_evaluate_by_handle(&pinfo); |
414 | if (ACPI_FAILURE(status)) { | ||
415 | /* Ignore error and move on to next device */ | ||
404 | 416 | ||
405 | #ifdef ACPI_DEBUG_OUTPUT | 417 | #ifdef ACPI_DEBUG_OUTPUT |
406 | char *scope_name = | 418 | char *scope_name = acpi_ns_get_external_pathname(ini_node); |
407 | acpi_ns_get_external_pathname(pinfo.node); | ||
408 | 419 | ||
409 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n", | 420 | ACPI_WARNING((AE_INFO, "%s._INI failed: %s", |
410 | scope_name, | 421 | scope_name, acpi_format_exception(status))); |
411 | acpi_format_exception(status))); | ||
412 | 422 | ||
413 | ACPI_MEM_FREE(scope_name); | 423 | ACPI_MEM_FREE(scope_name); |
414 | #endif | 424 | #endif |
415 | } | ||
416 | |||
417 | status = AE_OK; | ||
418 | } else { | 425 | } else { |
419 | /* Delete any return object (especially if implicit_return is enabled) */ | 426 | /* Delete any return object (especially if implicit_return is enabled) */ |
420 | 427 | ||
@@ -434,5 +441,5 @@ acpi_ns_init_one_device(acpi_handle obj_handle, | |||
434 | acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI); | 441 | acpi_gbl_init_handler(pinfo.node, ACPI_INIT_DEVICE_INI); |
435 | } | 442 | } |
436 | 443 | ||
437 | return_ACPI_STATUS(status); | 444 | return_ACPI_STATUS(AE_OK); |
438 | } | 445 | } |