diff options
Diffstat (limited to 'drivers/acpi/namespace/nsinit.c')
-rw-r--r-- | drivers/acpi/namespace/nsinit.c | 103 |
1 files changed, 55 insertions, 48 deletions
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/namespace/nsinit.c index 0a08d2f04a06..6c117893f301 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,8 @@ 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_REPORT_ERROR(("walk_namespace failed! %s\n", |
97 | acpi_format_exception(status))); | 97 | acpi_format_exception(status))); |
98 | } | 98 | } |
99 | 99 | ||
100 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, | 100 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, |
@@ -159,8 +159,8 @@ acpi_status acpi_ns_initialize_devices(void) | |||
159 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); | 159 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
160 | 160 | ||
161 | if (ACPI_FAILURE(status)) { | 161 | if (ACPI_FAILURE(status)) { |
162 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed! %s\n", | 162 | ACPI_REPORT_ERROR(("walk_namespace failed! %s\n", |
163 | acpi_format_exception(status))); | 163 | acpi_format_exception(status))); |
164 | } | 164 | } |
165 | 165 | ||
166 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, | 166 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, |
@@ -289,12 +289,7 @@ acpi_ns_init_one_object(acpi_handle obj_handle, | |||
289 | } | 289 | } |
290 | 290 | ||
291 | if (ACPI_FAILURE(status)) { | 291 | if (ACPI_FAILURE(status)) { |
292 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR, "\n")); | 292 | ACPI_REPORT_ERROR(("\nCould not execute arguments for [%4.4s] (%s), %s\n", acpi_ut_get_node_name(node), acpi_ut_get_type_name(type), acpi_format_exception(status))); |
293 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, | ||
294 | "Could not execute arguments for [%4.4s] (%s), %s\n", | ||
295 | acpi_ut_get_node_name(node), | ||
296 | acpi_ut_get_type_name(type), | ||
297 | acpi_format_exception(status))); | ||
298 | } | 293 | } |
299 | 294 | ||
300 | /* | 295 | /* |
@@ -336,23 +331,22 @@ acpi_ns_init_one_device(acpi_handle obj_handle, | |||
336 | struct acpi_parameter_info pinfo; | 331 | struct acpi_parameter_info pinfo; |
337 | u32 flags; | 332 | u32 flags; |
338 | acpi_status status; | 333 | acpi_status status; |
334 | struct acpi_namespace_node *ini_node; | ||
335 | struct acpi_namespace_node *device_node; | ||
339 | 336 | ||
340 | ACPI_FUNCTION_TRACE("ns_init_one_device"); | 337 | ACPI_FUNCTION_TRACE("ns_init_one_device"); |
341 | 338 | ||
342 | pinfo.parameters = NULL; | 339 | device_node = acpi_ns_map_handle_to_node(obj_handle); |
343 | pinfo.parameter_type = ACPI_PARAM_ARGS; | 340 | 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); | 341 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
348 | } | 342 | } |
349 | 343 | ||
350 | /* | 344 | /* |
351 | * We will run _STA/_INI on Devices, Processors and thermal_zones only | 345 | * We will run _STA/_INI on Devices, Processors and thermal_zones only |
352 | */ | 346 | */ |
353 | if ((pinfo.node->type != ACPI_TYPE_DEVICE) && | 347 | if ((device_node->type != ACPI_TYPE_DEVICE) && |
354 | (pinfo.node->type != ACPI_TYPE_PROCESSOR) && | 348 | (device_node->type != ACPI_TYPE_PROCESSOR) && |
355 | (pinfo.node->type != ACPI_TYPE_THERMAL)) { | 349 | (device_node->type != ACPI_TYPE_THERMAL)) { |
356 | return_ACPI_STATUS(AE_OK); | 350 | return_ACPI_STATUS(AE_OK); |
357 | } | 351 | } |
358 | 352 | ||
@@ -364,57 +358,70 @@ acpi_ns_init_one_device(acpi_handle obj_handle, | |||
364 | info->device_count++; | 358 | info->device_count++; |
365 | 359 | ||
366 | /* | 360 | /* |
367 | * Run _STA to determine if we can run _INI on the device. | 361 | * Check if the _INI method exists for this device - |
362 | * if _INI does not exist, there is no need to run _STA | ||
363 | * No _INI means device requires no initialization | ||
364 | */ | ||
365 | status = acpi_ns_search_node(*ACPI_CAST_PTR(u32, METHOD_NAME__INI), | ||
366 | device_node, ACPI_TYPE_METHOD, &ini_node); | ||
367 | if (ACPI_FAILURE(status)) { | ||
368 | /* No _INI method found - move on to next device */ | ||
369 | |||
370 | return_ACPI_STATUS(AE_OK); | ||
371 | } | ||
372 | |||
373 | /* | ||
374 | * Run _STA to determine if we can run _INI on the device - | ||
375 | * the device must be present before _INI can be run. | ||
376 | * However, _STA is not required - assume device present if no _STA | ||
368 | */ | 377 | */ |
369 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, | 378 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, |
370 | pinfo.node, | 379 | device_node, |
371 | METHOD_NAME__STA)); | 380 | METHOD_NAME__STA)); |
372 | status = acpi_ut_execute_STA(pinfo.node, &flags); | ||
373 | 381 | ||
382 | pinfo.node = device_node; | ||
383 | pinfo.parameters = NULL; | ||
384 | pinfo.parameter_type = ACPI_PARAM_ARGS; | ||
385 | |||
386 | status = acpi_ut_execute_STA(pinfo.node, &flags); | ||
374 | if (ACPI_FAILURE(status)) { | 387 | if (ACPI_FAILURE(status)) { |
375 | if (pinfo.node->type == ACPI_TYPE_DEVICE) { | 388 | /* Ignore error and move on to next device */ |
376 | /* Ignore error and move on to next device */ | ||
377 | 389 | ||
378 | return_ACPI_STATUS(AE_OK); | 390 | return_ACPI_STATUS(AE_OK); |
379 | } | 391 | } |
380 | 392 | ||
381 | /* _STA is not required for Processor or thermal_zone objects */ | 393 | if (flags != ACPI_UINT32_MAX) { |
382 | } else { | ||
383 | info->num_STA++; | 394 | info->num_STA++; |
395 | } | ||
384 | 396 | ||
385 | if (!(flags & 0x01)) { | 397 | if (!(flags & ACPI_STA_DEVICE_PRESENT)) { |
386 | /* Don't look at children of a not present device */ | 398 | /* Don't look at children of a not present device */ |
387 | 399 | ||
388 | return_ACPI_STATUS(AE_CTRL_DEPTH); | 400 | return_ACPI_STATUS(AE_CTRL_DEPTH); |
389 | } | ||
390 | } | 401 | } |
391 | 402 | ||
392 | /* | 403 | /* |
393 | * The device is present. Run _INI. | 404 | * The device is present and _INI exists. Run the _INI method. |
405 | * (We already have the _INI node from above) | ||
394 | */ | 406 | */ |
395 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, | 407 | ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname(ACPI_TYPE_METHOD, |
396 | pinfo.node, | 408 | pinfo.node, |
397 | METHOD_NAME__INI)); | 409 | 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 | 410 | ||
402 | if (status != AE_NOT_FOUND) { | 411 | pinfo.node = ini_node; |
403 | /* Ignore error and move on to next device */ | 412 | status = acpi_ns_evaluate_by_handle(&pinfo); |
413 | if (ACPI_FAILURE(status)) { | ||
414 | /* Ignore error and move on to next device */ | ||
404 | 415 | ||
405 | #ifdef ACPI_DEBUG_OUTPUT | 416 | #ifdef ACPI_DEBUG_OUTPUT |
406 | char *scope_name = | 417 | char *scope_name = acpi_ns_get_external_pathname(ini_node); |
407 | acpi_ns_get_external_pathname(pinfo.node); | ||
408 | 418 | ||
409 | ACPI_DEBUG_PRINT((ACPI_DB_WARN, "%s._INI failed: %s\n", | 419 | ACPI_REPORT_WARNING(("%s._INI failed: %s\n", |
410 | scope_name, | 420 | scope_name, |
411 | acpi_format_exception(status))); | 421 | 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 | } |