Blame view
kernel/power/poweroff.c
980 Bytes
1da177e4c
|
1 2 3 4 5 6 7 8 9 10 11 |
/* * poweroff.c - sysrq handler to gracefully power down machine. * * This file is released under the GPL v2 */ #include <linux/kernel.h> #include <linux/sysrq.h> #include <linux/init.h> #include <linux/pm.h> #include <linux/workqueue.h> |
ff3197778
|
12 |
#include <linux/reboot.h> |
2f15fc4bd
|
13 |
#include <linux/cpumask.h> |
1da177e4c
|
14 15 16 17 18 |
/* * When the user hits Sys-Rq o to power down the machine this is the * callback we use. */ |
65f27f384
|
19 |
static void do_poweroff(struct work_struct *dummy) |
1da177e4c
|
20 |
{ |
ff3197778
|
21 |
kernel_power_off(); |
1da177e4c
|
22 |
} |
65f27f384
|
23 |
static DECLARE_WORK(poweroff_work, do_poweroff); |
1da177e4c
|
24 |
|
1495cc9df
|
25 |
static void handle_poweroff(int key) |
1da177e4c
|
26 |
{ |
2f15fc4bd
|
27 |
/* run sysrq poweroff on boot cpu */ |
41c7bb958
|
28 |
schedule_work_on(cpumask_first(cpu_online_mask), &poweroff_work); |
1da177e4c
|
29 30 31 32 33 34 |
} static struct sysrq_key_op sysrq_poweroff_op = { .handler = handle_poweroff, .help_msg = "powerOff", .action_msg = "Power Off", |
1dc492a0a
|
35 |
.enable_mask = SYSRQ_ENABLE_BOOT, |
1da177e4c
|
36 37 38 39 40 41 42 43 44 |
}; static int pm_sysrq_init(void) { register_sysrq_key('o', &sysrq_poweroff_op); return 0; } subsys_initcall(pm_sysrq_init); |