Commit bf7c3d2d authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[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.
parent 2e7d2212
...@@ -109,14 +109,17 @@ static inline void console_verbose(void) ...@@ -109,14 +109,17 @@ static inline void console_verbose(void)
extern void bust_spinlocks(int yes); extern void bust_spinlocks(int yes);
extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
extern int panic_on_oops; extern int panic_on_oops;
extern int system_state; /* See values below */
extern int tainted; extern int tainted;
extern const char *print_tainted(void); extern const char *print_tainted(void);
/* Values used for system_state */ /* Values used for system_state */
#define SYSTEM_BOOTING 0 extern enum system_states {
#define SYSTEM_RUNNING 1 SYSTEM_BOOTING,
#define SYSTEM_SHUTDOWN 2 SYSTEM_RUNNING,
SYSTEM_HALT,
SYSTEM_POWER_OFF,
SYSTEM_RESTART,
} system_state;
#define TAINT_PROPRIETARY_MODULE (1<<0) #define TAINT_PROPRIETARY_MODULE (1<<0)
#define TAINT_FORCED_MODULE (1<<1) #define TAINT_FORCED_MODULE (1<<1)
......
...@@ -95,7 +95,8 @@ extern void prepare_namespace(void); ...@@ -95,7 +95,8 @@ extern void prepare_namespace(void);
extern void tc_init(void); extern void tc_init(void);
#endif #endif
int system_state; /* SYSTEM_BOOTING/RUNNING/SHUTDOWN */ enum system_states system_state;
EXPORT_SYMBOL(system_state);
/* /*
* Boot command-line arguments * Boot command-line arguments
......
...@@ -451,7 +451,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user ...@@ -451,7 +451,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
switch (cmd) { switch (cmd) {
case LINUX_REBOOT_CMD_RESTART: case LINUX_REBOOT_CMD_RESTART:
notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL);
system_state = SYSTEM_SHUTDOWN; system_state = SYSTEM_RESTART;
device_shutdown(); device_shutdown();
printk(KERN_EMERG "Restarting system.\n"); printk(KERN_EMERG "Restarting system.\n");
machine_restart(NULL); machine_restart(NULL);
...@@ -467,7 +467,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user ...@@ -467,7 +467,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
case LINUX_REBOOT_CMD_HALT: case LINUX_REBOOT_CMD_HALT:
notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
system_state = SYSTEM_SHUTDOWN; system_state = SYSTEM_HALT;
device_shutdown(); device_shutdown();
printk(KERN_EMERG "System halted.\n"); printk(KERN_EMERG "System halted.\n");
machine_halt(); machine_halt();
...@@ -477,7 +477,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user ...@@ -477,7 +477,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
case LINUX_REBOOT_CMD_POWER_OFF: case LINUX_REBOOT_CMD_POWER_OFF:
notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
system_state = SYSTEM_SHUTDOWN; system_state = SYSTEM_POWER_OFF;
device_shutdown(); device_shutdown();
printk(KERN_EMERG "Power down.\n"); printk(KERN_EMERG "Power down.\n");
machine_power_off(); machine_power_off();
...@@ -493,7 +493,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user ...@@ -493,7 +493,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
buffer[sizeof(buffer) - 1] = '\0'; buffer[sizeof(buffer) - 1] = '\0';
notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer); notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer);
system_state = SYSTEM_SHUTDOWN; system_state = SYSTEM_RESTART;
device_shutdown(); device_shutdown();
printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer); printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer);
machine_restart(buffer); machine_restart(buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment