ACPI: suspend: consolidate handling of Sx states.

Recent changes to sleep initialization in ACPI dropped reporting of supported Sx
states above S3. Fix that and also move S5 init into same file as other Sx.
The only functional change is adding printk() for S4 and S5 cases.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by Alexey Starikovskiy and committed by Len Brown f216cc37 335fb8fc

+49 -81
+1 -1
drivers/acpi/sleep/Makefile
··· 1 - obj-y := poweroff.o wakeup.o 1 + obj-y := wakeup.o 2 2 obj-$(CONFIG_ACPI_SLEEP) += main.o 3 3 obj-$(CONFIG_ACPI_SLEEP) += proc.o 4 4
+48 -5
drivers/acpi/sleep/main.c
··· 15 15 #include <linux/dmi.h> 16 16 #include <linux/device.h> 17 17 #include <linux/suspend.h> 18 + 19 + #include <asm/io.h> 20 + 18 21 #include <acpi/acpi_bus.h> 19 22 #include <acpi/acpi_drivers.h> 20 23 #include "sleep.h" ··· 58 55 error = -ENOSYS; 59 56 } 60 57 return error; 58 + } 59 + 60 + int acpi_sleep_prepare(u32 acpi_state) 61 + { 62 + #ifdef CONFIG_ACPI_SLEEP 63 + /* do we have a wakeup address for S2 and S3? */ 64 + if (acpi_state == ACPI_STATE_S3) { 65 + if (!acpi_wakeup_address) { 66 + return -EFAULT; 67 + } 68 + acpi_set_firmware_waking_vector((acpi_physical_address) 69 + virt_to_phys((void *) 70 + acpi_wakeup_address)); 71 + 72 + } 73 + ACPI_FLUSH_CPU_CACHE(); 74 + acpi_enable_wakeup_device_prep(acpi_state); 75 + #endif 76 + acpi_gpe_sleep_prepare(acpi_state); 77 + acpi_enter_sleep_state_prep(acpi_state); 78 + return 0; 61 79 } 62 80 63 81 /** ··· 374 350 return d_max; 375 351 } 376 352 353 + static void acpi_power_off_prepare(void) 354 + { 355 + /* Prepare to power off the system */ 356 + acpi_sleep_prepare(ACPI_STATE_S5); 357 + } 358 + 359 + static void acpi_power_off(void) 360 + { 361 + /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ 362 + printk("%s called\n", __FUNCTION__); 363 + local_irq_disable(); 364 + acpi_enter_sleep_state(ACPI_STATE_S5); 365 + } 366 + 377 367 int __init acpi_sleep_init(void) 378 368 { 379 369 acpi_status status; ··· 401 363 if (acpi_disabled) 402 364 return 0; 403 365 366 + printk(KERN_INFO PREFIX "(supports"); 404 367 #ifdef CONFIG_SUSPEND 405 - printk(KERN_INFO PREFIX "(supports"); 406 368 for (i = ACPI_STATE_S0; i < ACPI_STATE_S4; i++) { 407 369 status = acpi_get_sleep_type_data(i, &type_a, &type_b); 408 370 if (ACPI_SUCCESS(status)) { ··· 410 372 printk(" S%d", i); 411 373 } 412 374 } 413 - printk(")\n"); 414 375 415 376 pm_set_ops(&acpi_pm_ops); 416 377 #endif ··· 419 382 if (ACPI_SUCCESS(status)) { 420 383 hibernation_set_ops(&acpi_hibernation_ops); 421 384 sleep_states[ACPI_STATE_S4] = 1; 385 + printk(" S4"); 422 386 } 423 - #else 424 - sleep_states[ACPI_STATE_S4] = 0; 425 387 #endif 426 - 388 + status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); 389 + if (ACPI_SUCCESS(status)) { 390 + sleep_states[ACPI_STATE_S5] = 1; 391 + printk(" S5"); 392 + pm_power_off_prepare = acpi_power_off_prepare; 393 + pm_power_off = acpi_power_off; 394 + } 395 + printk(")\n"); 427 396 return 0; 428 397 }
-75
drivers/acpi/sleep/poweroff.c
··· 1 - /* 2 - * poweroff.c - ACPI handler for powering off the system. 3 - * 4 - * AKA S5, but it is independent of whether or not the kernel supports 5 - * any other sleep support in the system. 6 - * 7 - * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> 8 - * 9 - * This file is released under the GPLv2. 10 - */ 11 - 12 - #include <linux/pm.h> 13 - #include <linux/init.h> 14 - #include <acpi/acpi_bus.h> 15 - #include <linux/sysdev.h> 16 - #include <asm/io.h> 17 - #include "sleep.h" 18 - 19 - int acpi_sleep_prepare(u32 acpi_state) 20 - { 21 - #ifdef CONFIG_ACPI_SLEEP 22 - /* do we have a wakeup address for S2 and S3? */ 23 - if (acpi_state == ACPI_STATE_S3) { 24 - if (!acpi_wakeup_address) { 25 - return -EFAULT; 26 - } 27 - acpi_set_firmware_waking_vector((acpi_physical_address) 28 - virt_to_phys((void *) 29 - acpi_wakeup_address)); 30 - 31 - } 32 - ACPI_FLUSH_CPU_CACHE(); 33 - acpi_enable_wakeup_device_prep(acpi_state); 34 - #endif 35 - acpi_gpe_sleep_prepare(acpi_state); 36 - acpi_enter_sleep_state_prep(acpi_state); 37 - return 0; 38 - } 39 - 40 - #ifdef CONFIG_PM 41 - 42 - static void acpi_power_off_prepare(void) 43 - { 44 - /* Prepare to power off the system */ 45 - acpi_sleep_prepare(ACPI_STATE_S5); 46 - } 47 - 48 - static void acpi_power_off(void) 49 - { 50 - /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ 51 - printk("%s called\n", __FUNCTION__); 52 - local_irq_disable(); 53 - /* Some SMP machines only can poweroff in boot CPU */ 54 - acpi_enter_sleep_state(ACPI_STATE_S5); 55 - } 56 - 57 - static int acpi_poweroff_init(void) 58 - { 59 - if (!acpi_disabled) { 60 - u8 type_a, type_b; 61 - acpi_status status; 62 - 63 - status = 64 - acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); 65 - if (ACPI_SUCCESS(status)) { 66 - pm_power_off_prepare = acpi_power_off_prepare; 67 - pm_power_off = acpi_power_off; 68 - } 69 - } 70 - return 0; 71 - } 72 - 73 - late_initcall(acpi_poweroff_init); 74 - 75 - #endif /* CONFIG_PM */