aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sys.c')
-rw-r--r--kernel/sys.c25
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}
441EXPORT_SYMBOL_GPL(kernel_kexec); 441EXPORT_SYMBOL_GPL(kernel_kexec);
442 442
443void 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 */
448void kernel_halt_prepare(void)
449{
450 notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
451 system_state = SYSTEM_HALT;
452 device_shutdown();
453}
454void kernel_halt(void) 455void 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
460EXPORT_SYMBOL_GPL(kernel_halt); 462EXPORT_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 */
467void 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}
473void kernel_power_off(void) 469void 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}
479EXPORT_SYMBOL_GPL(kernel_power_off); 475EXPORT_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