Find the ACPI power resource object and put it into OFF state before scanning ACPI device tree Signed-off-by: Zhao Yakui --- drivers/acpi/scan.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) Index: linux-2.6/drivers/acpi/scan.c =================================================================== --- linux-2.6.orig/drivers/acpi/scan.c 2009-04-20 09:13:37.000000000 +0800 +++ linux-2.6/drivers/acpi/scan.c 2009-05-04 09:40:56.000000000 +0800 @@ -1575,6 +1575,37 @@ return result; } +/* + * Find the power resource and turn off the power resource by calling the + * _OFF object + */ +static acpi_status +find_and_power_off(acpi_handle handle, u32 level, void *context, + void **return_value) +{ + char bus_id[5]; + acpi_handle dummy_handle; + struct acpi_buffer buffer = {sizeof(bus_id), bus_id}; + + acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer); + + /* + * check whether there exists the _ON/_OFF object for the power + * resource. If it doesn't exists, it will be regarded as a bogus + * power resource object. + */ + if (ACPI_FAILURE(acpi_get_handle(handle, "_ON", &dummy_handle)) || + ACPI_FAILURE(acpi_get_handle(handle, "_OFF", &dummy_handle))) { + printk(KERN_INFO " bogus power resource[%s] is found\n", + bus_id); + return AE_OK; + } + /* Power off the power resource object by evaluating the _OFF */ + acpi_evaluate_object(handle, "_OFF", NULL, NULL); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, " power resource [%s] is off", + bus_id)); + return AE_OK; +} int __init acpi_scan_init(void) { @@ -1585,6 +1616,12 @@ ops.acpi_op_add = 1; ops.acpi_op_start = 1; + /* + * Find the power resource object and put it into OFF state. + */ + acpi_walk_namespace(ACPI_TYPE_POWER, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + find_and_power_off, NULL, NULL); + result = bus_register(&acpi_bus_type); if (result) { /* We don't want to quit even if we failed to add suspend/resume */