diff options
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index d09cac23fdfd..0929c698affc 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -440,23 +440,25 @@ void kernel_kexec(void) | |||
440 | } | 440 | } |
441 | EXPORT_SYMBOL_GPL(kernel_kexec); | 441 | EXPORT_SYMBOL_GPL(kernel_kexec); |
442 | 442 | ||
443 | void kernel_shutdown_prepare(enum system_states state) | ||
444 | { | ||
445 | notifier_call_chain(&reboot_notifier_list, | ||
446 | (state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL); | ||
447 | system_state = state; | ||
448 | device_shutdown(); | ||
449 | } | ||
443 | /** | 450 | /** |
444 | * kernel_halt - halt the system | 451 | * kernel_halt - halt the system |
445 | * | 452 | * |
446 | * Shutdown everything and perform a clean system halt. | 453 | * Shutdown everything and perform a clean system halt. |
447 | */ | 454 | */ |
448 | void kernel_halt_prepare(void) | ||
449 | { | ||
450 | notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); | ||
451 | system_state = SYSTEM_HALT; | ||
452 | device_shutdown(); | ||
453 | } | ||
454 | void kernel_halt(void) | 455 | void kernel_halt(void) |
455 | { | 456 | { |
456 | kernel_halt_prepare(); | 457 | kernel_shutdown_prepare(SYSTEM_HALT); |
457 | printk(KERN_EMERG "System halted.\n"); | 458 | printk(KERN_EMERG "System halted.\n"); |
458 | machine_halt(); | 459 | machine_halt(); |
459 | } | 460 | } |
461 | |||
460 | EXPORT_SYMBOL_GPL(kernel_halt); | 462 | EXPORT_SYMBOL_GPL(kernel_halt); |
461 | 463 | ||
462 | /** | 464 | /** |
@@ -464,20 +466,13 @@ EXPORT_SYMBOL_GPL(kernel_halt); | |||
464 | * | 466 | * |
465 | * Shutdown everything and perform a clean system power_off. | 467 | * Shutdown everything and perform a clean system power_off. |
466 | */ | 468 | */ |
467 | void kernel_power_off_prepare(void) | ||
468 | { | ||
469 | notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); | ||
470 | system_state = SYSTEM_POWER_OFF; | ||
471 | device_shutdown(); | ||
472 | } | ||
473 | void kernel_power_off(void) | 469 | void kernel_power_off(void) |
474 | { | 470 | { |
475 | kernel_power_off_prepare(); | 471 | kernel_shutdown_prepare(SYSTEM_POWER_OFF); |
476 | printk(KERN_EMERG "Power down.\n"); | 472 | printk(KERN_EMERG "Power down.\n"); |
477 | machine_power_off(); | 473 | machine_power_off(); |
478 | } | 474 | } |
479 | EXPORT_SYMBOL_GPL(kernel_power_off); | 475 | EXPORT_SYMBOL_GPL(kernel_power_off); |
480 | |||
481 | /* | 476 | /* |
482 | * Reboot system call: for obvious reasons only root may call it, | 477 | * Reboot system call: for obvious reasons only root may call it, |
483 | * and even root needs to set up some magic numbers in the registers | 478 | * and even root needs to set up some magic numbers in the registers |