bpf: Enable cpumasks to be queried and used as kptrs
[linux-2.6-block.git] / kernel / power / poweroff.c
CommitLineData
8092f73c 1// SPDX-License-Identifier: GPL-2.0-only
1da177e4
LT
2/*
3 * poweroff.c - sysrq handler to gracefully power down machine.
1da177e4
LT
4 */
5
6#include <linux/kernel.h>
7#include <linux/sysrq.h>
8#include <linux/init.h>
9#include <linux/pm.h>
10#include <linux/workqueue.h>
ff319777 11#include <linux/reboot.h>
2f15fc4b 12#include <linux/cpumask.h>
1da177e4
LT
13
14/*
15 * When the user hits Sys-Rq o to power down the machine this is the
16 * callback we use.
17 */
18
65f27f38 19static void do_poweroff(struct work_struct *dummy)
1da177e4 20{
ff319777 21 kernel_power_off();
1da177e4
LT
22}
23
65f27f38 24static DECLARE_WORK(poweroff_work, do_poweroff);
1da177e4 25
1495cc9d 26static void handle_poweroff(int key)
1da177e4 27{
2f15fc4b 28 /* run sysrq poweroff on boot cpu */
41c7bb95 29 schedule_work_on(cpumask_first(cpu_online_mask), &poweroff_work);
1da177e4
LT
30}
31
6400b5a0 32static const struct sysrq_key_op sysrq_poweroff_op = {
1da177e4 33 .handler = handle_poweroff,
28ad585e 34 .help_msg = "poweroff(o)",
1da177e4 35 .action_msg = "Power Off",
1dc492a0 36 .enable_mask = SYSRQ_ENABLE_BOOT,
1da177e4
LT
37};
38
bbdc18a3 39static int __init pm_sysrq_init(void)
1da177e4
LT
40{
41 register_sysrq_key('o', &sysrq_poweroff_op);
42 return 0;
43}
44
45subsys_initcall(pm_sysrq_init);