From bf7c3d2de183a1c138ac667e41be357ce59f5998 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 19 May 2004 02:32:36 -0700 Subject: [PATCH] [PATCH] system_state splitup Split the system_state state `SYSTEM_SHUTDOWN' into SYSTEM_HALT, SYSTEM_POWER_OFF and SYSTEM_RESTART and export system_state to modules. This allows driver shutdown routines to know why they are being shutdown. The IDE subsystem wants this so that it knows to not spin the disks down across a reboot. --- include/linux/kernel.h | 11 +++++++---- init/main.c | 3 ++- kernel/sys.c | 8 ++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index c1171e77c76bf..67da15c2e1e33 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -109,14 +109,17 @@ static inline void console_verbose(void) extern void bust_spinlocks(int yes); extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ extern int panic_on_oops; -extern int system_state; /* See values below */ extern int tainted; extern const char *print_tainted(void); /* Values used for system_state */ -#define SYSTEM_BOOTING 0 -#define SYSTEM_RUNNING 1 -#define SYSTEM_SHUTDOWN 2 +extern enum system_states { + SYSTEM_BOOTING, + SYSTEM_RUNNING, + SYSTEM_HALT, + SYSTEM_POWER_OFF, + SYSTEM_RESTART, +} system_state; #define TAINT_PROPRIETARY_MODULE (1<<0) #define TAINT_FORCED_MODULE (1<<1) diff --git a/init/main.c b/init/main.c index 6913e1acfc04f..63530aa09c05d 100644 --- a/init/main.c +++ b/init/main.c @@ -95,7 +95,8 @@ extern void prepare_namespace(void); extern void tc_init(void); #endif -int system_state; /* SYSTEM_BOOTING/RUNNING/SHUTDOWN */ +enum system_states system_state; +EXPORT_SYMBOL(system_state); /* * Boot command-line arguments diff --git a/kernel/sys.c b/kernel/sys.c index ece6365b8c450..14d58b2f983ac 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -451,7 +451,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user switch (cmd) { case LINUX_REBOOT_CMD_RESTART: notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); - system_state = SYSTEM_SHUTDOWN; + system_state = SYSTEM_RESTART; device_shutdown(); printk(KERN_EMERG "Restarting system.\n"); machine_restart(NULL); @@ -467,7 +467,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user case LINUX_REBOOT_CMD_HALT: notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); - system_state = SYSTEM_SHUTDOWN; + system_state = SYSTEM_HALT; device_shutdown(); printk(KERN_EMERG "System halted.\n"); machine_halt(); @@ -477,7 +477,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user case LINUX_REBOOT_CMD_POWER_OFF: notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); - system_state = SYSTEM_SHUTDOWN; + system_state = SYSTEM_POWER_OFF; device_shutdown(); printk(KERN_EMERG "Power down.\n"); machine_power_off(); @@ -493,7 +493,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user buffer[sizeof(buffer) - 1] = '\0'; notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer); - system_state = SYSTEM_SHUTDOWN; + system_state = SYSTEM_RESTART; device_shutdown(); printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer); machine_restart(buffer); -- 2.53.0