xref: /openbmc/linux/kernel/reboot.c (revision c97102ba96324da330078ad8619ba4dfe840dbe3)
115d94b82SRobin Holt /*
215d94b82SRobin Holt  *  linux/kernel/reboot.c
315d94b82SRobin Holt  *
415d94b82SRobin Holt  *  Copyright (C) 2013  Linus Torvalds
515d94b82SRobin Holt  */
615d94b82SRobin Holt 
7972ee83dSRobin Holt #define pr_fmt(fmt)	"reboot: " fmt
8972ee83dSRobin Holt 
91b3a5d02SRobin Holt #include <linux/ctype.h>
1015d94b82SRobin Holt #include <linux/export.h>
1115d94b82SRobin Holt #include <linux/kexec.h>
1215d94b82SRobin Holt #include <linux/kmod.h>
1315d94b82SRobin Holt #include <linux/kmsg_dump.h>
1415d94b82SRobin Holt #include <linux/reboot.h>
1515d94b82SRobin Holt #include <linux/suspend.h>
1615d94b82SRobin Holt #include <linux/syscalls.h>
1715d94b82SRobin Holt #include <linux/syscore_ops.h>
1815d94b82SRobin Holt #include <linux/uaccess.h>
1915d94b82SRobin Holt 
2015d94b82SRobin Holt /*
2115d94b82SRobin Holt  * this indicates whether you can reboot with ctrl-alt-del: the default is yes
2215d94b82SRobin Holt  */
2315d94b82SRobin Holt 
2415d94b82SRobin Holt int C_A_D = 1;
2515d94b82SRobin Holt struct pid *cad_pid;
2615d94b82SRobin Holt EXPORT_SYMBOL(cad_pid);
2715d94b82SRobin Holt 
281b3a5d02SRobin Holt #if defined(CONFIG_ARM) || defined(CONFIG_UNICORE32)
291b3a5d02SRobin Holt #define DEFAULT_REBOOT_MODE		= REBOOT_HARD
301b3a5d02SRobin Holt #else
311b3a5d02SRobin Holt #define DEFAULT_REBOOT_MODE
321b3a5d02SRobin Holt #endif
331b3a5d02SRobin Holt enum reboot_mode reboot_mode DEFAULT_REBOOT_MODE;
341b3a5d02SRobin Holt 
35e2f0b88eSChuansheng Liu /*
36e2f0b88eSChuansheng Liu  * This variable is used privately to keep track of whether or not
37e2f0b88eSChuansheng Liu  * reboot_type is still set to its default value (i.e., reboot= hasn't
38e2f0b88eSChuansheng Liu  * been set on the command line).  This is needed so that we can
39e2f0b88eSChuansheng Liu  * suppress DMI scanning for reboot quirks.  Without it, it's
40e2f0b88eSChuansheng Liu  * impossible to override a faulty reboot quirk without recompiling.
41e2f0b88eSChuansheng Liu  */
42e2f0b88eSChuansheng Liu int reboot_default = 1;
431b3a5d02SRobin Holt int reboot_cpu;
441b3a5d02SRobin Holt enum reboot_type reboot_type = BOOT_ACPI;
451b3a5d02SRobin Holt int reboot_force;
461b3a5d02SRobin Holt 
4715d94b82SRobin Holt /*
4815d94b82SRobin Holt  * If set, this is used for preparing the system to power off.
4915d94b82SRobin Holt  */
5015d94b82SRobin Holt 
5115d94b82SRobin Holt void (*pm_power_off_prepare)(void);
5215d94b82SRobin Holt 
5315d94b82SRobin Holt /**
5415d94b82SRobin Holt  *	emergency_restart - reboot the system
5515d94b82SRobin Holt  *
5615d94b82SRobin Holt  *	Without shutting down any hardware or taking any locks
5715d94b82SRobin Holt  *	reboot the system.  This is called when we know we are in
5815d94b82SRobin Holt  *	trouble so this is our best effort to reboot.  This is
5915d94b82SRobin Holt  *	safe to call in interrupt context.
6015d94b82SRobin Holt  */
6115d94b82SRobin Holt void emergency_restart(void)
6215d94b82SRobin Holt {
6315d94b82SRobin Holt 	kmsg_dump(KMSG_DUMP_EMERG);
6415d94b82SRobin Holt 	machine_emergency_restart();
6515d94b82SRobin Holt }
6615d94b82SRobin Holt EXPORT_SYMBOL_GPL(emergency_restart);
6715d94b82SRobin Holt 
6815d94b82SRobin Holt void kernel_restart_prepare(char *cmd)
6915d94b82SRobin Holt {
7015d94b82SRobin Holt 	blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
7115d94b82SRobin Holt 	system_state = SYSTEM_RESTART;
7215d94b82SRobin Holt 	usermodehelper_disable();
7315d94b82SRobin Holt 	device_shutdown();
7415d94b82SRobin Holt }
7515d94b82SRobin Holt 
7615d94b82SRobin Holt /**
7715d94b82SRobin Holt  *	register_reboot_notifier - Register function to be called at reboot time
7815d94b82SRobin Holt  *	@nb: Info about notifier function to be called
7915d94b82SRobin Holt  *
8015d94b82SRobin Holt  *	Registers a function with the list of functions
8115d94b82SRobin Holt  *	to be called at reboot time.
8215d94b82SRobin Holt  *
8315d94b82SRobin Holt  *	Currently always returns zero, as blocking_notifier_chain_register()
8415d94b82SRobin Holt  *	always returns zero.
8515d94b82SRobin Holt  */
8615d94b82SRobin Holt int register_reboot_notifier(struct notifier_block *nb)
8715d94b82SRobin Holt {
8815d94b82SRobin Holt 	return blocking_notifier_chain_register(&reboot_notifier_list, nb);
8915d94b82SRobin Holt }
9015d94b82SRobin Holt EXPORT_SYMBOL(register_reboot_notifier);
9115d94b82SRobin Holt 
9215d94b82SRobin Holt /**
9315d94b82SRobin Holt  *	unregister_reboot_notifier - Unregister previously registered reboot notifier
9415d94b82SRobin Holt  *	@nb: Hook to be unregistered
9515d94b82SRobin Holt  *
9615d94b82SRobin Holt  *	Unregisters a previously registered reboot
9715d94b82SRobin Holt  *	notifier function.
9815d94b82SRobin Holt  *
9915d94b82SRobin Holt  *	Returns zero on success, or %-ENOENT on failure.
10015d94b82SRobin Holt  */
10115d94b82SRobin Holt int unregister_reboot_notifier(struct notifier_block *nb)
10215d94b82SRobin Holt {
10315d94b82SRobin Holt 	return blocking_notifier_chain_unregister(&reboot_notifier_list, nb);
10415d94b82SRobin Holt }
10515d94b82SRobin Holt EXPORT_SYMBOL(unregister_reboot_notifier);
10615d94b82SRobin Holt 
107*c97102baSVivek Goyal void migrate_to_reboot_cpu(void)
10815d94b82SRobin Holt {
10915d94b82SRobin Holt 	/* The boot cpu is always logical cpu 0 */
1101b3a5d02SRobin Holt 	int cpu = reboot_cpu;
11115d94b82SRobin Holt 
11215d94b82SRobin Holt 	cpu_hotplug_disable();
11315d94b82SRobin Holt 
11415d94b82SRobin Holt 	/* Make certain the cpu I'm about to reboot on is online */
11515d94b82SRobin Holt 	if (!cpu_online(cpu))
11615d94b82SRobin Holt 		cpu = cpumask_first(cpu_online_mask);
11715d94b82SRobin Holt 
11815d94b82SRobin Holt 	/* Prevent races with other tasks migrating this task */
11915d94b82SRobin Holt 	current->flags |= PF_NO_SETAFFINITY;
12015d94b82SRobin Holt 
12115d94b82SRobin Holt 	/* Make certain I only run on the appropriate processor */
12215d94b82SRobin Holt 	set_cpus_allowed_ptr(current, cpumask_of(cpu));
12315d94b82SRobin Holt }
12415d94b82SRobin Holt 
12515d94b82SRobin Holt /**
12615d94b82SRobin Holt  *	kernel_restart - reboot the system
12715d94b82SRobin Holt  *	@cmd: pointer to buffer containing command to execute for restart
12815d94b82SRobin Holt  *		or %NULL
12915d94b82SRobin Holt  *
13015d94b82SRobin Holt  *	Shutdown everything and perform a clean reboot.
13115d94b82SRobin Holt  *	This is not safe to call in interrupt context.
13215d94b82SRobin Holt  */
13315d94b82SRobin Holt void kernel_restart(char *cmd)
13415d94b82SRobin Holt {
13515d94b82SRobin Holt 	kernel_restart_prepare(cmd);
13615d94b82SRobin Holt 	migrate_to_reboot_cpu();
13715d94b82SRobin Holt 	syscore_shutdown();
13815d94b82SRobin Holt 	if (!cmd)
139972ee83dSRobin Holt 		pr_emerg("Restarting system\n");
14015d94b82SRobin Holt 	else
141972ee83dSRobin Holt 		pr_emerg("Restarting system with command '%s'\n", cmd);
14215d94b82SRobin Holt 	kmsg_dump(KMSG_DUMP_RESTART);
14315d94b82SRobin Holt 	machine_restart(cmd);
14415d94b82SRobin Holt }
14515d94b82SRobin Holt EXPORT_SYMBOL_GPL(kernel_restart);
14615d94b82SRobin Holt 
14715d94b82SRobin Holt static void kernel_shutdown_prepare(enum system_states state)
14815d94b82SRobin Holt {
14915d94b82SRobin Holt 	blocking_notifier_call_chain(&reboot_notifier_list,
15015d94b82SRobin Holt 		(state == SYSTEM_HALT) ? SYS_HALT : SYS_POWER_OFF, NULL);
15115d94b82SRobin Holt 	system_state = state;
15215d94b82SRobin Holt 	usermodehelper_disable();
15315d94b82SRobin Holt 	device_shutdown();
15415d94b82SRobin Holt }
15515d94b82SRobin Holt /**
15615d94b82SRobin Holt  *	kernel_halt - halt the system
15715d94b82SRobin Holt  *
15815d94b82SRobin Holt  *	Shutdown everything and perform a clean system halt.
15915d94b82SRobin Holt  */
16015d94b82SRobin Holt void kernel_halt(void)
16115d94b82SRobin Holt {
16215d94b82SRobin Holt 	kernel_shutdown_prepare(SYSTEM_HALT);
16315d94b82SRobin Holt 	migrate_to_reboot_cpu();
16415d94b82SRobin Holt 	syscore_shutdown();
165972ee83dSRobin Holt 	pr_emerg("System halted\n");
16615d94b82SRobin Holt 	kmsg_dump(KMSG_DUMP_HALT);
16715d94b82SRobin Holt 	machine_halt();
16815d94b82SRobin Holt }
16915d94b82SRobin Holt EXPORT_SYMBOL_GPL(kernel_halt);
17015d94b82SRobin Holt 
17115d94b82SRobin Holt /**
17215d94b82SRobin Holt  *	kernel_power_off - power_off the system
17315d94b82SRobin Holt  *
17415d94b82SRobin Holt  *	Shutdown everything and perform a clean system power_off.
17515d94b82SRobin Holt  */
17615d94b82SRobin Holt void kernel_power_off(void)
17715d94b82SRobin Holt {
17815d94b82SRobin Holt 	kernel_shutdown_prepare(SYSTEM_POWER_OFF);
17915d94b82SRobin Holt 	if (pm_power_off_prepare)
18015d94b82SRobin Holt 		pm_power_off_prepare();
18115d94b82SRobin Holt 	migrate_to_reboot_cpu();
18215d94b82SRobin Holt 	syscore_shutdown();
183972ee83dSRobin Holt 	pr_emerg("Power down\n");
18415d94b82SRobin Holt 	kmsg_dump(KMSG_DUMP_POWEROFF);
18515d94b82SRobin Holt 	machine_power_off();
18615d94b82SRobin Holt }
18715d94b82SRobin Holt EXPORT_SYMBOL_GPL(kernel_power_off);
18815d94b82SRobin Holt 
18915d94b82SRobin Holt static DEFINE_MUTEX(reboot_mutex);
19015d94b82SRobin Holt 
19115d94b82SRobin Holt /*
19215d94b82SRobin Holt  * Reboot system call: for obvious reasons only root may call it,
19315d94b82SRobin Holt  * and even root needs to set up some magic numbers in the registers
19415d94b82SRobin Holt  * so that some mistake won't make this reboot the whole machine.
19515d94b82SRobin Holt  * You can also set the meaning of the ctrl-alt-del-key here.
19615d94b82SRobin Holt  *
19715d94b82SRobin Holt  * reboot doesn't sync: do that yourself before calling this.
19815d94b82SRobin Holt  */
19915d94b82SRobin Holt SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
20015d94b82SRobin Holt 		void __user *, arg)
20115d94b82SRobin Holt {
20215d94b82SRobin Holt 	struct pid_namespace *pid_ns = task_active_pid_ns(current);
20315d94b82SRobin Holt 	char buffer[256];
20415d94b82SRobin Holt 	int ret = 0;
20515d94b82SRobin Holt 
20615d94b82SRobin Holt 	/* We only trust the superuser with rebooting the system. */
20715d94b82SRobin Holt 	if (!ns_capable(pid_ns->user_ns, CAP_SYS_BOOT))
20815d94b82SRobin Holt 		return -EPERM;
20915d94b82SRobin Holt 
21015d94b82SRobin Holt 	/* For safety, we require "magic" arguments. */
21115d94b82SRobin Holt 	if (magic1 != LINUX_REBOOT_MAGIC1 ||
21215d94b82SRobin Holt 			(magic2 != LINUX_REBOOT_MAGIC2 &&
21315d94b82SRobin Holt 			magic2 != LINUX_REBOOT_MAGIC2A &&
21415d94b82SRobin Holt 			magic2 != LINUX_REBOOT_MAGIC2B &&
21515d94b82SRobin Holt 			magic2 != LINUX_REBOOT_MAGIC2C))
21615d94b82SRobin Holt 		return -EINVAL;
21715d94b82SRobin Holt 
21815d94b82SRobin Holt 	/*
21915d94b82SRobin Holt 	 * If pid namespaces are enabled and the current task is in a child
22015d94b82SRobin Holt 	 * pid_namespace, the command is handled by reboot_pid_ns() which will
22115d94b82SRobin Holt 	 * call do_exit().
22215d94b82SRobin Holt 	 */
22315d94b82SRobin Holt 	ret = reboot_pid_ns(pid_ns, cmd);
22415d94b82SRobin Holt 	if (ret)
22515d94b82SRobin Holt 		return ret;
22615d94b82SRobin Holt 
22715d94b82SRobin Holt 	/* Instead of trying to make the power_off code look like
22815d94b82SRobin Holt 	 * halt when pm_power_off is not set do it the easy way.
22915d94b82SRobin Holt 	 */
23015d94b82SRobin Holt 	if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
23115d94b82SRobin Holt 		cmd = LINUX_REBOOT_CMD_HALT;
23215d94b82SRobin Holt 
23315d94b82SRobin Holt 	mutex_lock(&reboot_mutex);
23415d94b82SRobin Holt 	switch (cmd) {
23515d94b82SRobin Holt 	case LINUX_REBOOT_CMD_RESTART:
23615d94b82SRobin Holt 		kernel_restart(NULL);
23715d94b82SRobin Holt 		break;
23815d94b82SRobin Holt 
23915d94b82SRobin Holt 	case LINUX_REBOOT_CMD_CAD_ON:
24015d94b82SRobin Holt 		C_A_D = 1;
24115d94b82SRobin Holt 		break;
24215d94b82SRobin Holt 
24315d94b82SRobin Holt 	case LINUX_REBOOT_CMD_CAD_OFF:
24415d94b82SRobin Holt 		C_A_D = 0;
24515d94b82SRobin Holt 		break;
24615d94b82SRobin Holt 
24715d94b82SRobin Holt 	case LINUX_REBOOT_CMD_HALT:
24815d94b82SRobin Holt 		kernel_halt();
24915d94b82SRobin Holt 		do_exit(0);
25015d94b82SRobin Holt 		panic("cannot halt");
25115d94b82SRobin Holt 
25215d94b82SRobin Holt 	case LINUX_REBOOT_CMD_POWER_OFF:
25315d94b82SRobin Holt 		kernel_power_off();
25415d94b82SRobin Holt 		do_exit(0);
25515d94b82SRobin Holt 		break;
25615d94b82SRobin Holt 
25715d94b82SRobin Holt 	case LINUX_REBOOT_CMD_RESTART2:
258972ee83dSRobin Holt 		ret = strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1);
259972ee83dSRobin Holt 		if (ret < 0) {
26015d94b82SRobin Holt 			ret = -EFAULT;
26115d94b82SRobin Holt 			break;
26215d94b82SRobin Holt 		}
26315d94b82SRobin Holt 		buffer[sizeof(buffer) - 1] = '\0';
26415d94b82SRobin Holt 
26515d94b82SRobin Holt 		kernel_restart(buffer);
26615d94b82SRobin Holt 		break;
26715d94b82SRobin Holt 
26815d94b82SRobin Holt #ifdef CONFIG_KEXEC
26915d94b82SRobin Holt 	case LINUX_REBOOT_CMD_KEXEC:
27015d94b82SRobin Holt 		ret = kernel_kexec();
27115d94b82SRobin Holt 		break;
27215d94b82SRobin Holt #endif
27315d94b82SRobin Holt 
27415d94b82SRobin Holt #ifdef CONFIG_HIBERNATION
27515d94b82SRobin Holt 	case LINUX_REBOOT_CMD_SW_SUSPEND:
27615d94b82SRobin Holt 		ret = hibernate();
27715d94b82SRobin Holt 		break;
27815d94b82SRobin Holt #endif
27915d94b82SRobin Holt 
28015d94b82SRobin Holt 	default:
28115d94b82SRobin Holt 		ret = -EINVAL;
28215d94b82SRobin Holt 		break;
28315d94b82SRobin Holt 	}
28415d94b82SRobin Holt 	mutex_unlock(&reboot_mutex);
28515d94b82SRobin Holt 	return ret;
28615d94b82SRobin Holt }
28715d94b82SRobin Holt 
28815d94b82SRobin Holt static void deferred_cad(struct work_struct *dummy)
28915d94b82SRobin Holt {
29015d94b82SRobin Holt 	kernel_restart(NULL);
29115d94b82SRobin Holt }
29215d94b82SRobin Holt 
29315d94b82SRobin Holt /*
29415d94b82SRobin Holt  * This function gets called by ctrl-alt-del - ie the keyboard interrupt.
29515d94b82SRobin Holt  * As it's called within an interrupt, it may NOT sync: the only choice
29615d94b82SRobin Holt  * is whether to reboot at once, or just ignore the ctrl-alt-del.
29715d94b82SRobin Holt  */
29815d94b82SRobin Holt void ctrl_alt_del(void)
29915d94b82SRobin Holt {
30015d94b82SRobin Holt 	static DECLARE_WORK(cad_work, deferred_cad);
30115d94b82SRobin Holt 
30215d94b82SRobin Holt 	if (C_A_D)
30315d94b82SRobin Holt 		schedule_work(&cad_work);
30415d94b82SRobin Holt 	else
30515d94b82SRobin Holt 		kill_cad_pid(SIGINT, 1);
30615d94b82SRobin Holt }
30715d94b82SRobin Holt 
30815d94b82SRobin Holt char poweroff_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/poweroff";
30915d94b82SRobin Holt 
31015d94b82SRobin Holt static int __orderly_poweroff(bool force)
31115d94b82SRobin Holt {
31215d94b82SRobin Holt 	char **argv;
31315d94b82SRobin Holt 	static char *envp[] = {
31415d94b82SRobin Holt 		"HOME=/",
31515d94b82SRobin Holt 		"PATH=/sbin:/bin:/usr/sbin:/usr/bin",
31615d94b82SRobin Holt 		NULL
31715d94b82SRobin Holt 	};
31815d94b82SRobin Holt 	int ret;
31915d94b82SRobin Holt 
32015d94b82SRobin Holt 	argv = argv_split(GFP_KERNEL, poweroff_cmd, NULL);
32115d94b82SRobin Holt 	if (argv) {
32215d94b82SRobin Holt 		ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
32315d94b82SRobin Holt 		argv_free(argv);
32415d94b82SRobin Holt 	} else {
32515d94b82SRobin Holt 		ret = -ENOMEM;
32615d94b82SRobin Holt 	}
32715d94b82SRobin Holt 
32815d94b82SRobin Holt 	if (ret && force) {
329972ee83dSRobin Holt 		pr_warn("Failed to start orderly shutdown: forcing the issue\n");
33015d94b82SRobin Holt 		/*
33115d94b82SRobin Holt 		 * I guess this should try to kick off some daemon to sync and
33215d94b82SRobin Holt 		 * poweroff asap.  Or not even bother syncing if we're doing an
33315d94b82SRobin Holt 		 * emergency shutdown?
33415d94b82SRobin Holt 		 */
33515d94b82SRobin Holt 		emergency_sync();
33615d94b82SRobin Holt 		kernel_power_off();
33715d94b82SRobin Holt 	}
33815d94b82SRobin Holt 
33915d94b82SRobin Holt 	return ret;
34015d94b82SRobin Holt }
34115d94b82SRobin Holt 
34215d94b82SRobin Holt static bool poweroff_force;
34315d94b82SRobin Holt 
34415d94b82SRobin Holt static void poweroff_work_func(struct work_struct *work)
34515d94b82SRobin Holt {
34615d94b82SRobin Holt 	__orderly_poweroff(poweroff_force);
34715d94b82SRobin Holt }
34815d94b82SRobin Holt 
34915d94b82SRobin Holt static DECLARE_WORK(poweroff_work, poweroff_work_func);
35015d94b82SRobin Holt 
35115d94b82SRobin Holt /**
35215d94b82SRobin Holt  * orderly_poweroff - Trigger an orderly system poweroff
35315d94b82SRobin Holt  * @force: force poweroff if command execution fails
35415d94b82SRobin Holt  *
35515d94b82SRobin Holt  * This may be called from any context to trigger a system shutdown.
35615d94b82SRobin Holt  * If the orderly shutdown fails, it will force an immediate shutdown.
35715d94b82SRobin Holt  */
35815d94b82SRobin Holt int orderly_poweroff(bool force)
35915d94b82SRobin Holt {
36015d94b82SRobin Holt 	if (force) /* do not override the pending "true" */
36115d94b82SRobin Holt 		poweroff_force = true;
36215d94b82SRobin Holt 	schedule_work(&poweroff_work);
36315d94b82SRobin Holt 	return 0;
36415d94b82SRobin Holt }
36515d94b82SRobin Holt EXPORT_SYMBOL_GPL(orderly_poweroff);
3661b3a5d02SRobin Holt 
3671b3a5d02SRobin Holt static int __init reboot_setup(char *str)
3681b3a5d02SRobin Holt {
3691b3a5d02SRobin Holt 	for (;;) {
3701b3a5d02SRobin Holt 		/*
3711b3a5d02SRobin Holt 		 * Having anything passed on the command line via
3721b3a5d02SRobin Holt 		 * reboot= will cause us to disable DMI checking
3731b3a5d02SRobin Holt 		 * below.
3741b3a5d02SRobin Holt 		 */
3751b3a5d02SRobin Holt 		reboot_default = 0;
3761b3a5d02SRobin Holt 
3771b3a5d02SRobin Holt 		switch (*str) {
3781b3a5d02SRobin Holt 		case 'w':
3791b3a5d02SRobin Holt 			reboot_mode = REBOOT_WARM;
3801b3a5d02SRobin Holt 			break;
3811b3a5d02SRobin Holt 
3821b3a5d02SRobin Holt 		case 'c':
3831b3a5d02SRobin Holt 			reboot_mode = REBOOT_COLD;
3841b3a5d02SRobin Holt 			break;
3851b3a5d02SRobin Holt 
3861b3a5d02SRobin Holt 		case 'h':
3871b3a5d02SRobin Holt 			reboot_mode = REBOOT_HARD;
3881b3a5d02SRobin Holt 			break;
3891b3a5d02SRobin Holt 
3901b3a5d02SRobin Holt 		case 's':
3911b3a5d02SRobin Holt 			if (isdigit(*(str+1)))
3921b3a5d02SRobin Holt 				reboot_cpu = simple_strtoul(str+1, NULL, 0);
3931b3a5d02SRobin Holt 			else if (str[1] == 'm' && str[2] == 'p' &&
3941b3a5d02SRobin Holt 							isdigit(*(str+3)))
3951b3a5d02SRobin Holt 				reboot_cpu = simple_strtoul(str+3, NULL, 0);
3961b3a5d02SRobin Holt 			else
3971b3a5d02SRobin Holt 				reboot_mode = REBOOT_SOFT;
3981b3a5d02SRobin Holt 			break;
3991b3a5d02SRobin Holt 
4001b3a5d02SRobin Holt 		case 'g':
4011b3a5d02SRobin Holt 			reboot_mode = REBOOT_GPIO;
4021b3a5d02SRobin Holt 			break;
4031b3a5d02SRobin Holt 
4041b3a5d02SRobin Holt 		case 'b':
4051b3a5d02SRobin Holt 		case 'a':
4061b3a5d02SRobin Holt 		case 'k':
4071b3a5d02SRobin Holt 		case 't':
4081b3a5d02SRobin Holt 		case 'e':
4091b3a5d02SRobin Holt 		case 'p':
4101b3a5d02SRobin Holt 			reboot_type = *str;
4111b3a5d02SRobin Holt 			break;
4121b3a5d02SRobin Holt 
4131b3a5d02SRobin Holt 		case 'f':
4141b3a5d02SRobin Holt 			reboot_force = 1;
4151b3a5d02SRobin Holt 			break;
4161b3a5d02SRobin Holt 		}
4171b3a5d02SRobin Holt 
4181b3a5d02SRobin Holt 		str = strchr(str, ',');
4191b3a5d02SRobin Holt 		if (str)
4201b3a5d02SRobin Holt 			str++;
4211b3a5d02SRobin Holt 		else
4221b3a5d02SRobin Holt 			break;
4231b3a5d02SRobin Holt 	}
4241b3a5d02SRobin Holt 	return 1;
4251b3a5d02SRobin Holt }
4261b3a5d02SRobin Holt __setup("reboot=", reboot_setup);
427