xref: /openbmc/linux/kernel/reboot.c (revision 1b3a5d02ee070c8f9943333b9b6370f486601e0f)
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 
9*1b3a5d02SRobin 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 
28*1b3a5d02SRobin Holt #if defined(CONFIG_ARM) || defined(CONFIG_UNICORE32)
29*1b3a5d02SRobin Holt #define DEFAULT_REBOOT_MODE		= REBOOT_HARD
30*1b3a5d02SRobin Holt #else
31*1b3a5d02SRobin Holt #define DEFAULT_REBOOT_MODE
32*1b3a5d02SRobin Holt #endif
33*1b3a5d02SRobin Holt enum reboot_mode reboot_mode DEFAULT_REBOOT_MODE;
34*1b3a5d02SRobin Holt 
35*1b3a5d02SRobin Holt int reboot_default;
36*1b3a5d02SRobin Holt int reboot_cpu;
37*1b3a5d02SRobin Holt enum reboot_type reboot_type = BOOT_ACPI;
38*1b3a5d02SRobin Holt int reboot_force;
39*1b3a5d02SRobin Holt 
4015d94b82SRobin Holt /*
4115d94b82SRobin Holt  * If set, this is used for preparing the system to power off.
4215d94b82SRobin Holt  */
4315d94b82SRobin Holt 
4415d94b82SRobin Holt void (*pm_power_off_prepare)(void);
4515d94b82SRobin Holt 
4615d94b82SRobin Holt /**
4715d94b82SRobin Holt  *	emergency_restart - reboot the system
4815d94b82SRobin Holt  *
4915d94b82SRobin Holt  *	Without shutting down any hardware or taking any locks
5015d94b82SRobin Holt  *	reboot the system.  This is called when we know we are in
5115d94b82SRobin Holt  *	trouble so this is our best effort to reboot.  This is
5215d94b82SRobin Holt  *	safe to call in interrupt context.
5315d94b82SRobin Holt  */
5415d94b82SRobin Holt void emergency_restart(void)
5515d94b82SRobin Holt {
5615d94b82SRobin Holt 	kmsg_dump(KMSG_DUMP_EMERG);
5715d94b82SRobin Holt 	machine_emergency_restart();
5815d94b82SRobin Holt }
5915d94b82SRobin Holt EXPORT_SYMBOL_GPL(emergency_restart);
6015d94b82SRobin Holt 
6115d94b82SRobin Holt void kernel_restart_prepare(char *cmd)
6215d94b82SRobin Holt {
6315d94b82SRobin Holt 	blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
6415d94b82SRobin Holt 	system_state = SYSTEM_RESTART;
6515d94b82SRobin Holt 	usermodehelper_disable();
6615d94b82SRobin Holt 	device_shutdown();
6715d94b82SRobin Holt }
6815d94b82SRobin Holt 
6915d94b82SRobin Holt /**
7015d94b82SRobin Holt  *	register_reboot_notifier - Register function to be called at reboot time
7115d94b82SRobin Holt  *	@nb: Info about notifier function to be called
7215d94b82SRobin Holt  *
7315d94b82SRobin Holt  *	Registers a function with the list of functions
7415d94b82SRobin Holt  *	to be called at reboot time.
7515d94b82SRobin Holt  *
7615d94b82SRobin Holt  *	Currently always returns zero, as blocking_notifier_chain_register()
7715d94b82SRobin Holt  *	always returns zero.
7815d94b82SRobin Holt  */
7915d94b82SRobin Holt int register_reboot_notifier(struct notifier_block *nb)
8015d94b82SRobin Holt {
8115d94b82SRobin Holt 	return blocking_notifier_chain_register(&reboot_notifier_list, nb);
8215d94b82SRobin Holt }
8315d94b82SRobin Holt EXPORT_SYMBOL(register_reboot_notifier);
8415d94b82SRobin Holt 
8515d94b82SRobin Holt /**
8615d94b82SRobin Holt  *	unregister_reboot_notifier - Unregister previously registered reboot notifier
8715d94b82SRobin Holt  *	@nb: Hook to be unregistered
8815d94b82SRobin Holt  *
8915d94b82SRobin Holt  *	Unregisters a previously registered reboot
9015d94b82SRobin Holt  *	notifier function.
9115d94b82SRobin Holt  *
9215d94b82SRobin Holt  *	Returns zero on success, or %-ENOENT on failure.
9315d94b82SRobin Holt  */
9415d94b82SRobin Holt int unregister_reboot_notifier(struct notifier_block *nb)
9515d94b82SRobin Holt {
9615d94b82SRobin Holt 	return blocking_notifier_chain_unregister(&reboot_notifier_list, nb);
9715d94b82SRobin Holt }
9815d94b82SRobin Holt EXPORT_SYMBOL(unregister_reboot_notifier);
9915d94b82SRobin Holt 
10015d94b82SRobin Holt static void migrate_to_reboot_cpu(void)
10115d94b82SRobin Holt {
10215d94b82SRobin Holt 	/* The boot cpu is always logical cpu 0 */
103*1b3a5d02SRobin Holt 	int cpu = reboot_cpu;
10415d94b82SRobin Holt 
10515d94b82SRobin Holt 	cpu_hotplug_disable();
10615d94b82SRobin Holt 
10715d94b82SRobin Holt 	/* Make certain the cpu I'm about to reboot on is online */
10815d94b82SRobin Holt 	if (!cpu_online(cpu))
10915d94b82SRobin Holt 		cpu = cpumask_first(cpu_online_mask);
11015d94b82SRobin Holt 
11115d94b82SRobin Holt 	/* Prevent races with other tasks migrating this task */
11215d94b82SRobin Holt 	current->flags |= PF_NO_SETAFFINITY;
11315d94b82SRobin Holt 
11415d94b82SRobin Holt 	/* Make certain I only run on the appropriate processor */
11515d94b82SRobin Holt 	set_cpus_allowed_ptr(current, cpumask_of(cpu));
11615d94b82SRobin Holt }
11715d94b82SRobin Holt 
11815d94b82SRobin Holt /**
11915d94b82SRobin Holt  *	kernel_restart - reboot the system
12015d94b82SRobin Holt  *	@cmd: pointer to buffer containing command to execute for restart
12115d94b82SRobin Holt  *		or %NULL
12215d94b82SRobin Holt  *
12315d94b82SRobin Holt  *	Shutdown everything and perform a clean reboot.
12415d94b82SRobin Holt  *	This is not safe to call in interrupt context.
12515d94b82SRobin Holt  */
12615d94b82SRobin Holt void kernel_restart(char *cmd)
12715d94b82SRobin Holt {
12815d94b82SRobin Holt 	kernel_restart_prepare(cmd);
12915d94b82SRobin Holt 	migrate_to_reboot_cpu();
13015d94b82SRobin Holt 	syscore_shutdown();
13115d94b82SRobin Holt 	if (!cmd)
132972ee83dSRobin Holt 		pr_emerg("Restarting system\n");
13315d94b82SRobin Holt 	else
134972ee83dSRobin Holt 		pr_emerg("Restarting system with command '%s'\n", cmd);
13515d94b82SRobin Holt 	kmsg_dump(KMSG_DUMP_RESTART);
13615d94b82SRobin Holt 	machine_restart(cmd);
13715d94b82SRobin Holt }
13815d94b82SRobin Holt EXPORT_SYMBOL_GPL(kernel_restart);
13915d94b82SRobin Holt 
14015d94b82SRobin Holt static void kernel_shutdown_prepare(enum system_states state)
14115d94b82SRobin Holt {
14215d94b82SRobin Holt 	blocking_notifier_call_chain(&reboot_notifier_list,
14315d94b82SRobin Holt 		(state == SYSTEM_HALT) ? SYS_HALT : SYS_POWER_OFF, NULL);
14415d94b82SRobin Holt 	system_state = state;
14515d94b82SRobin Holt 	usermodehelper_disable();
14615d94b82SRobin Holt 	device_shutdown();
14715d94b82SRobin Holt }
14815d94b82SRobin Holt /**
14915d94b82SRobin Holt  *	kernel_halt - halt the system
15015d94b82SRobin Holt  *
15115d94b82SRobin Holt  *	Shutdown everything and perform a clean system halt.
15215d94b82SRobin Holt  */
15315d94b82SRobin Holt void kernel_halt(void)
15415d94b82SRobin Holt {
15515d94b82SRobin Holt 	kernel_shutdown_prepare(SYSTEM_HALT);
15615d94b82SRobin Holt 	migrate_to_reboot_cpu();
15715d94b82SRobin Holt 	syscore_shutdown();
158972ee83dSRobin Holt 	pr_emerg("System halted\n");
15915d94b82SRobin Holt 	kmsg_dump(KMSG_DUMP_HALT);
16015d94b82SRobin Holt 	machine_halt();
16115d94b82SRobin Holt }
16215d94b82SRobin Holt EXPORT_SYMBOL_GPL(kernel_halt);
16315d94b82SRobin Holt 
16415d94b82SRobin Holt /**
16515d94b82SRobin Holt  *	kernel_power_off - power_off the system
16615d94b82SRobin Holt  *
16715d94b82SRobin Holt  *	Shutdown everything and perform a clean system power_off.
16815d94b82SRobin Holt  */
16915d94b82SRobin Holt void kernel_power_off(void)
17015d94b82SRobin Holt {
17115d94b82SRobin Holt 	kernel_shutdown_prepare(SYSTEM_POWER_OFF);
17215d94b82SRobin Holt 	if (pm_power_off_prepare)
17315d94b82SRobin Holt 		pm_power_off_prepare();
17415d94b82SRobin Holt 	migrate_to_reboot_cpu();
17515d94b82SRobin Holt 	syscore_shutdown();
176972ee83dSRobin Holt 	pr_emerg("Power down\n");
17715d94b82SRobin Holt 	kmsg_dump(KMSG_DUMP_POWEROFF);
17815d94b82SRobin Holt 	machine_power_off();
17915d94b82SRobin Holt }
18015d94b82SRobin Holt EXPORT_SYMBOL_GPL(kernel_power_off);
18115d94b82SRobin Holt 
18215d94b82SRobin Holt static DEFINE_MUTEX(reboot_mutex);
18315d94b82SRobin Holt 
18415d94b82SRobin Holt /*
18515d94b82SRobin Holt  * Reboot system call: for obvious reasons only root may call it,
18615d94b82SRobin Holt  * and even root needs to set up some magic numbers in the registers
18715d94b82SRobin Holt  * so that some mistake won't make this reboot the whole machine.
18815d94b82SRobin Holt  * You can also set the meaning of the ctrl-alt-del-key here.
18915d94b82SRobin Holt  *
19015d94b82SRobin Holt  * reboot doesn't sync: do that yourself before calling this.
19115d94b82SRobin Holt  */
19215d94b82SRobin Holt SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
19315d94b82SRobin Holt 		void __user *, arg)
19415d94b82SRobin Holt {
19515d94b82SRobin Holt 	struct pid_namespace *pid_ns = task_active_pid_ns(current);
19615d94b82SRobin Holt 	char buffer[256];
19715d94b82SRobin Holt 	int ret = 0;
19815d94b82SRobin Holt 
19915d94b82SRobin Holt 	/* We only trust the superuser with rebooting the system. */
20015d94b82SRobin Holt 	if (!ns_capable(pid_ns->user_ns, CAP_SYS_BOOT))
20115d94b82SRobin Holt 		return -EPERM;
20215d94b82SRobin Holt 
20315d94b82SRobin Holt 	/* For safety, we require "magic" arguments. */
20415d94b82SRobin Holt 	if (magic1 != LINUX_REBOOT_MAGIC1 ||
20515d94b82SRobin Holt 			(magic2 != LINUX_REBOOT_MAGIC2 &&
20615d94b82SRobin Holt 			magic2 != LINUX_REBOOT_MAGIC2A &&
20715d94b82SRobin Holt 			magic2 != LINUX_REBOOT_MAGIC2B &&
20815d94b82SRobin Holt 			magic2 != LINUX_REBOOT_MAGIC2C))
20915d94b82SRobin Holt 		return -EINVAL;
21015d94b82SRobin Holt 
21115d94b82SRobin Holt 	/*
21215d94b82SRobin Holt 	 * If pid namespaces are enabled and the current task is in a child
21315d94b82SRobin Holt 	 * pid_namespace, the command is handled by reboot_pid_ns() which will
21415d94b82SRobin Holt 	 * call do_exit().
21515d94b82SRobin Holt 	 */
21615d94b82SRobin Holt 	ret = reboot_pid_ns(pid_ns, cmd);
21715d94b82SRobin Holt 	if (ret)
21815d94b82SRobin Holt 		return ret;
21915d94b82SRobin Holt 
22015d94b82SRobin Holt 	/* Instead of trying to make the power_off code look like
22115d94b82SRobin Holt 	 * halt when pm_power_off is not set do it the easy way.
22215d94b82SRobin Holt 	 */
22315d94b82SRobin Holt 	if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
22415d94b82SRobin Holt 		cmd = LINUX_REBOOT_CMD_HALT;
22515d94b82SRobin Holt 
22615d94b82SRobin Holt 	mutex_lock(&reboot_mutex);
22715d94b82SRobin Holt 	switch (cmd) {
22815d94b82SRobin Holt 	case LINUX_REBOOT_CMD_RESTART:
22915d94b82SRobin Holt 		kernel_restart(NULL);
23015d94b82SRobin Holt 		break;
23115d94b82SRobin Holt 
23215d94b82SRobin Holt 	case LINUX_REBOOT_CMD_CAD_ON:
23315d94b82SRobin Holt 		C_A_D = 1;
23415d94b82SRobin Holt 		break;
23515d94b82SRobin Holt 
23615d94b82SRobin Holt 	case LINUX_REBOOT_CMD_CAD_OFF:
23715d94b82SRobin Holt 		C_A_D = 0;
23815d94b82SRobin Holt 		break;
23915d94b82SRobin Holt 
24015d94b82SRobin Holt 	case LINUX_REBOOT_CMD_HALT:
24115d94b82SRobin Holt 		kernel_halt();
24215d94b82SRobin Holt 		do_exit(0);
24315d94b82SRobin Holt 		panic("cannot halt");
24415d94b82SRobin Holt 
24515d94b82SRobin Holt 	case LINUX_REBOOT_CMD_POWER_OFF:
24615d94b82SRobin Holt 		kernel_power_off();
24715d94b82SRobin Holt 		do_exit(0);
24815d94b82SRobin Holt 		break;
24915d94b82SRobin Holt 
25015d94b82SRobin Holt 	case LINUX_REBOOT_CMD_RESTART2:
251972ee83dSRobin Holt 		ret = strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1);
252972ee83dSRobin Holt 		if (ret < 0) {
25315d94b82SRobin Holt 			ret = -EFAULT;
25415d94b82SRobin Holt 			break;
25515d94b82SRobin Holt 		}
25615d94b82SRobin Holt 		buffer[sizeof(buffer) - 1] = '\0';
25715d94b82SRobin Holt 
25815d94b82SRobin Holt 		kernel_restart(buffer);
25915d94b82SRobin Holt 		break;
26015d94b82SRobin Holt 
26115d94b82SRobin Holt #ifdef CONFIG_KEXEC
26215d94b82SRobin Holt 	case LINUX_REBOOT_CMD_KEXEC:
26315d94b82SRobin Holt 		ret = kernel_kexec();
26415d94b82SRobin Holt 		break;
26515d94b82SRobin Holt #endif
26615d94b82SRobin Holt 
26715d94b82SRobin Holt #ifdef CONFIG_HIBERNATION
26815d94b82SRobin Holt 	case LINUX_REBOOT_CMD_SW_SUSPEND:
26915d94b82SRobin Holt 		ret = hibernate();
27015d94b82SRobin Holt 		break;
27115d94b82SRobin Holt #endif
27215d94b82SRobin Holt 
27315d94b82SRobin Holt 	default:
27415d94b82SRobin Holt 		ret = -EINVAL;
27515d94b82SRobin Holt 		break;
27615d94b82SRobin Holt 	}
27715d94b82SRobin Holt 	mutex_unlock(&reboot_mutex);
27815d94b82SRobin Holt 	return ret;
27915d94b82SRobin Holt }
28015d94b82SRobin Holt 
28115d94b82SRobin Holt static void deferred_cad(struct work_struct *dummy)
28215d94b82SRobin Holt {
28315d94b82SRobin Holt 	kernel_restart(NULL);
28415d94b82SRobin Holt }
28515d94b82SRobin Holt 
28615d94b82SRobin Holt /*
28715d94b82SRobin Holt  * This function gets called by ctrl-alt-del - ie the keyboard interrupt.
28815d94b82SRobin Holt  * As it's called within an interrupt, it may NOT sync: the only choice
28915d94b82SRobin Holt  * is whether to reboot at once, or just ignore the ctrl-alt-del.
29015d94b82SRobin Holt  */
29115d94b82SRobin Holt void ctrl_alt_del(void)
29215d94b82SRobin Holt {
29315d94b82SRobin Holt 	static DECLARE_WORK(cad_work, deferred_cad);
29415d94b82SRobin Holt 
29515d94b82SRobin Holt 	if (C_A_D)
29615d94b82SRobin Holt 		schedule_work(&cad_work);
29715d94b82SRobin Holt 	else
29815d94b82SRobin Holt 		kill_cad_pid(SIGINT, 1);
29915d94b82SRobin Holt }
30015d94b82SRobin Holt 
30115d94b82SRobin Holt char poweroff_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/poweroff";
30215d94b82SRobin Holt 
30315d94b82SRobin Holt static int __orderly_poweroff(bool force)
30415d94b82SRobin Holt {
30515d94b82SRobin Holt 	char **argv;
30615d94b82SRobin Holt 	static char *envp[] = {
30715d94b82SRobin Holt 		"HOME=/",
30815d94b82SRobin Holt 		"PATH=/sbin:/bin:/usr/sbin:/usr/bin",
30915d94b82SRobin Holt 		NULL
31015d94b82SRobin Holt 	};
31115d94b82SRobin Holt 	int ret;
31215d94b82SRobin Holt 
31315d94b82SRobin Holt 	argv = argv_split(GFP_KERNEL, poweroff_cmd, NULL);
31415d94b82SRobin Holt 	if (argv) {
31515d94b82SRobin Holt 		ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
31615d94b82SRobin Holt 		argv_free(argv);
31715d94b82SRobin Holt 	} else {
31815d94b82SRobin Holt 		ret = -ENOMEM;
31915d94b82SRobin Holt 	}
32015d94b82SRobin Holt 
32115d94b82SRobin Holt 	if (ret && force) {
322972ee83dSRobin Holt 		pr_warn("Failed to start orderly shutdown: forcing the issue\n");
32315d94b82SRobin Holt 		/*
32415d94b82SRobin Holt 		 * I guess this should try to kick off some daemon to sync and
32515d94b82SRobin Holt 		 * poweroff asap.  Or not even bother syncing if we're doing an
32615d94b82SRobin Holt 		 * emergency shutdown?
32715d94b82SRobin Holt 		 */
32815d94b82SRobin Holt 		emergency_sync();
32915d94b82SRobin Holt 		kernel_power_off();
33015d94b82SRobin Holt 	}
33115d94b82SRobin Holt 
33215d94b82SRobin Holt 	return ret;
33315d94b82SRobin Holt }
33415d94b82SRobin Holt 
33515d94b82SRobin Holt static bool poweroff_force;
33615d94b82SRobin Holt 
33715d94b82SRobin Holt static void poweroff_work_func(struct work_struct *work)
33815d94b82SRobin Holt {
33915d94b82SRobin Holt 	__orderly_poweroff(poweroff_force);
34015d94b82SRobin Holt }
34115d94b82SRobin Holt 
34215d94b82SRobin Holt static DECLARE_WORK(poweroff_work, poweroff_work_func);
34315d94b82SRobin Holt 
34415d94b82SRobin Holt /**
34515d94b82SRobin Holt  * orderly_poweroff - Trigger an orderly system poweroff
34615d94b82SRobin Holt  * @force: force poweroff if command execution fails
34715d94b82SRobin Holt  *
34815d94b82SRobin Holt  * This may be called from any context to trigger a system shutdown.
34915d94b82SRobin Holt  * If the orderly shutdown fails, it will force an immediate shutdown.
35015d94b82SRobin Holt  */
35115d94b82SRobin Holt int orderly_poweroff(bool force)
35215d94b82SRobin Holt {
35315d94b82SRobin Holt 	if (force) /* do not override the pending "true" */
35415d94b82SRobin Holt 		poweroff_force = true;
35515d94b82SRobin Holt 	schedule_work(&poweroff_work);
35615d94b82SRobin Holt 	return 0;
35715d94b82SRobin Holt }
35815d94b82SRobin Holt EXPORT_SYMBOL_GPL(orderly_poweroff);
359*1b3a5d02SRobin Holt 
360*1b3a5d02SRobin Holt static int __init reboot_setup(char *str)
361*1b3a5d02SRobin Holt {
362*1b3a5d02SRobin Holt 	for (;;) {
363*1b3a5d02SRobin Holt 		/*
364*1b3a5d02SRobin Holt 		 * Having anything passed on the command line via
365*1b3a5d02SRobin Holt 		 * reboot= will cause us to disable DMI checking
366*1b3a5d02SRobin Holt 		 * below.
367*1b3a5d02SRobin Holt 		 */
368*1b3a5d02SRobin Holt 		reboot_default = 0;
369*1b3a5d02SRobin Holt 
370*1b3a5d02SRobin Holt 		switch (*str) {
371*1b3a5d02SRobin Holt 		case 'w':
372*1b3a5d02SRobin Holt 			reboot_mode = REBOOT_WARM;
373*1b3a5d02SRobin Holt 			break;
374*1b3a5d02SRobin Holt 
375*1b3a5d02SRobin Holt 		case 'c':
376*1b3a5d02SRobin Holt 			reboot_mode = REBOOT_COLD;
377*1b3a5d02SRobin Holt 			break;
378*1b3a5d02SRobin Holt 
379*1b3a5d02SRobin Holt 		case 'h':
380*1b3a5d02SRobin Holt 			reboot_mode = REBOOT_HARD;
381*1b3a5d02SRobin Holt 			break;
382*1b3a5d02SRobin Holt 
383*1b3a5d02SRobin Holt 		case 's':
384*1b3a5d02SRobin Holt 			if (isdigit(*(str+1)))
385*1b3a5d02SRobin Holt 				reboot_cpu = simple_strtoul(str+1, NULL, 0);
386*1b3a5d02SRobin Holt 			else if (str[1] == 'm' && str[2] == 'p' &&
387*1b3a5d02SRobin Holt 							isdigit(*(str+3)))
388*1b3a5d02SRobin Holt 				reboot_cpu = simple_strtoul(str+3, NULL, 0);
389*1b3a5d02SRobin Holt 			else
390*1b3a5d02SRobin Holt 				reboot_mode = REBOOT_SOFT;
391*1b3a5d02SRobin Holt 			break;
392*1b3a5d02SRobin Holt 
393*1b3a5d02SRobin Holt 		case 'g':
394*1b3a5d02SRobin Holt 			reboot_mode = REBOOT_GPIO;
395*1b3a5d02SRobin Holt 			break;
396*1b3a5d02SRobin Holt 
397*1b3a5d02SRobin Holt 		case 'b':
398*1b3a5d02SRobin Holt 		case 'a':
399*1b3a5d02SRobin Holt 		case 'k':
400*1b3a5d02SRobin Holt 		case 't':
401*1b3a5d02SRobin Holt 		case 'e':
402*1b3a5d02SRobin Holt 		case 'p':
403*1b3a5d02SRobin Holt 			reboot_type = *str;
404*1b3a5d02SRobin Holt 			break;
405*1b3a5d02SRobin Holt 
406*1b3a5d02SRobin Holt 		case 'f':
407*1b3a5d02SRobin Holt 			reboot_force = 1;
408*1b3a5d02SRobin Holt 			break;
409*1b3a5d02SRobin Holt 		}
410*1b3a5d02SRobin Holt 
411*1b3a5d02SRobin Holt 		str = strchr(str, ',');
412*1b3a5d02SRobin Holt 		if (str)
413*1b3a5d02SRobin Holt 			str++;
414*1b3a5d02SRobin Holt 		else
415*1b3a5d02SRobin Holt 			break;
416*1b3a5d02SRobin Holt 	}
417*1b3a5d02SRobin Holt 	return 1;
418*1b3a5d02SRobin Holt }
419*1b3a5d02SRobin Holt __setup("reboot=", reboot_setup);
420