diff options
author | Jeremy Fitzhardinge <jeremy@xensource.com> | 2007-07-17 21:37:02 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy@goop.org> | 2007-07-18 11:47:40 -0400 |
commit | 10a0a8d4e3f6bf2d077f94344441909abe670f5a (patch) | |
tree | b834c912629498e9fefb5958ee9965c414d32d69 /drivers/sbus/char | |
parent | 0ab4dc92278a0f3816e486d6350c6652a72e06c8 (diff) |
Add common orderly_poweroff()
Various pieces of code around the kernel want to be able to trigger an
orderly poweroff. This pulls them together into a single
implementation.
By default the poweroff command is /sbin/poweroff, but it can be set
via sysctl: kernel/poweroff_cmd. This is split at whitespace, so it
can include command-line arguments.
This patch replaces four other instances of invoking either "poweroff"
or "shutdown -h now": two sbus drivers, and acpi thermal
management.
sparc64 has its own "powerd"; still need to determine whether it should
be replaced by orderly_poweroff().
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Acked-by: Len Brown <lenb@kernel.org>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/sbus/char')
-rw-r--r-- | drivers/sbus/char/bbc_envctrl.c | 5 | ||||
-rw-r--r-- | drivers/sbus/char/envctrl.c | 7 |
2 files changed, 4 insertions, 8 deletions
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c index a54e4140683a..e821a155b658 100644 --- a/drivers/sbus/char/bbc_envctrl.c +++ b/drivers/sbus/char/bbc_envctrl.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/kthread.h> | 7 | #include <linux/kthread.h> |
8 | #include <linux/delay.h> | 8 | #include <linux/delay.h> |
9 | #include <linux/kmod.h> | 9 | #include <linux/kmod.h> |
10 | #include <linux/reboot.h> | ||
10 | #include <asm/oplib.h> | 11 | #include <asm/oplib.h> |
11 | #include <asm/ebus.h> | 12 | #include <asm/ebus.h> |
12 | 13 | ||
@@ -170,8 +171,6 @@ static void get_current_temps(struct bbc_cpu_temperature *tp) | |||
170 | static void do_envctrl_shutdown(struct bbc_cpu_temperature *tp) | 171 | static void do_envctrl_shutdown(struct bbc_cpu_temperature *tp) |
171 | { | 172 | { |
172 | static int shutting_down = 0; | 173 | static int shutting_down = 0; |
173 | static char *envp[] = { "HOME=/", "TERM=linux", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL }; | ||
174 | char *argv[] = { "/sbin/shutdown", "-h", "now", NULL }; | ||
175 | char *type = "???"; | 174 | char *type = "???"; |
176 | s8 val = -1; | 175 | s8 val = -1; |
177 | 176 | ||
@@ -195,7 +194,7 @@ static void do_envctrl_shutdown(struct bbc_cpu_temperature *tp) | |||
195 | printk(KERN_CRIT "kenvctrld: Shutting down the system now.\n"); | 194 | printk(KERN_CRIT "kenvctrld: Shutting down the system now.\n"); |
196 | 195 | ||
197 | shutting_down = 1; | 196 | shutting_down = 1; |
198 | if (call_usermodehelper("/sbin/shutdown", argv, envp, 0) < 0) | 197 | if (orderly_poweroff(true) < 0) |
199 | printk(KERN_CRIT "envctrl: shutdown execution failed\n"); | 198 | printk(KERN_CRIT "envctrl: shutdown execution failed\n"); |
200 | } | 199 | } |
201 | 200 | ||
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index 8328acab47fd..dadabef116b6 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/ioport.h> | 26 | #include <linux/ioport.h> |
27 | #include <linux/miscdevice.h> | 27 | #include <linux/miscdevice.h> |
28 | #include <linux/kmod.h> | 28 | #include <linux/kmod.h> |
29 | #include <linux/reboot.h> | ||
29 | 30 | ||
30 | #include <asm/ebus.h> | 31 | #include <asm/ebus.h> |
31 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
@@ -966,10 +967,6 @@ static struct i2c_child_t *envctrl_get_i2c_child(unsigned char mon_type) | |||
966 | static void envctrl_do_shutdown(void) | 967 | static void envctrl_do_shutdown(void) |
967 | { | 968 | { |
968 | static int inprog = 0; | 969 | static int inprog = 0; |
969 | static char *envp[] = { | ||
970 | "HOME=/", "TERM=linux", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL }; | ||
971 | char *argv[] = { | ||
972 | "/sbin/shutdown", "-h", "now", NULL }; | ||
973 | int ret; | 970 | int ret; |
974 | 971 | ||
975 | if (inprog != 0) | 972 | if (inprog != 0) |
@@ -977,7 +974,7 @@ static void envctrl_do_shutdown(void) | |||
977 | 974 | ||
978 | inprog = 1; | 975 | inprog = 1; |
979 | printk(KERN_CRIT "kenvctrld: WARNING: Shutting down the system now.\n"); | 976 | printk(KERN_CRIT "kenvctrld: WARNING: Shutting down the system now.\n"); |
980 | ret = call_usermodehelper("/sbin/shutdown", argv, envp, 0); | 977 | ret = orderly_poweroff(true); |
981 | if (ret < 0) { | 978 | if (ret < 0) { |
982 | printk(KERN_CRIT "kenvctrld: WARNING: system shutdown failed!\n"); | 979 | printk(KERN_CRIT "kenvctrld: WARNING: system shutdown failed!\n"); |
983 | inprog = 0; /* unlikely to succeed, but we could try again */ | 980 | inprog = 0; /* unlikely to succeed, but we could try again */ |