public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Linus Torvalds <torvalds@osdl.org>
Cc: len.brown@intel.com, Pierre Ossman <drzeus-list@drzeus.cx>,
	acpi-devel@lists.sourceforge.net, ncunningham@cyclades.com,
	Pavel Machek <pavel@ucw.cz>, Masoud Sharbiani <masouds@masoud.ir>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] reboot:  Comment and factor the main reboot functions
Date: Tue, 20 Sep 2005 11:42:21 -0600	[thread overview]
Message-ID: <m14q8fhc02.fsf_-_@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <Pine.SOC.4.61.0509111140550.9218@math.ut.ee> (Meelis Roos's message of "Sun, 11 Sep 2005 11:43:04 +0300 (EEST)")


In the lead up to 2.6.13 I fixed a large number of reboot
problems by making the calling conventions consistent.  Despite
checking and double checking my work it appears I missed an
obvious one.  

This first patch simply refactors the reboot routines
so all of the preparation for various kinds of reboots
are in their own functions.  Making it very hard to
get the various kinds of reboot out of sync.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>


---

 include/linux/reboot.h |    4 ++++
 kernel/sys.c           |   52 ++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 50 insertions(+), 6 deletions(-)

bc95b88c85ec3e7a0525f73f6c3ae19fa9640fbd
diff --git a/include/linux/reboot.h b/include/linux/reboot.h
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -59,6 +59,10 @@ extern void machine_crash_shutdown(struc
  * Architecture independent implemenations of sys_reboot commands.
  */
 
+extern void kernel_restart_prepare(char *cmd);
+extern void kernel_halt_prepare(void);
+extern void kernel_power_off_prepare(void);
+
 extern void kernel_restart(char *cmd);
 extern void kernel_halt(void);
 extern void kernel_power_off(void);
diff --git a/kernel/sys.c b/kernel/sys.c
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -361,17 +361,35 @@ out_unlock:
 	return retval;
 }
 
+/**
+ *	emergency_restart - reboot the system
+ *
+ *	Without shutting down any hardware or taking any locks
+ *	reboot the system.  This is called when we know we are in
+ *	trouble so this is our best effort to reboot.  This is
+ *	safe to call in interrupt context.
+ */
 void emergency_restart(void)
 {
 	machine_emergency_restart();
 }
 EXPORT_SYMBOL_GPL(emergency_restart);
 
-void kernel_restart(char *cmd)
+/**
+ *	kernel_restart - reboot the system
+ *
+ *	Shutdown everything and perform a clean reboot.
+ *	This is not safe to call in interrupt context.
+ */
+void kernel_restart_prepare(char *cmd)
 {
 	notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
 	system_state = SYSTEM_RESTART;
 	device_shutdown();
+}
+void kernel_restart(char *cmd)
+{
+	kernel_restart_prepare(cmd);
 	if (!cmd) {
 		printk(KERN_EMERG "Restarting system.\n");
 	} else {
@@ -382,6 +400,12 @@ void kernel_restart(char *cmd)
 }
 EXPORT_SYMBOL_GPL(kernel_restart);
 
+/**
+ *	kernel_kexec - reboot the system
+ *
+ *	Move into place and start executing a preloaded standalone
+ *	executable.  If nothing was preloaded return an error.
+ */
 void kernel_kexec(void)
 {
 #ifdef CONFIG_KEXEC
@@ -390,9 +414,7 @@ void kernel_kexec(void)
 	if (!image) {
 		return;
 	}
-	notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL);
-	system_state = SYSTEM_RESTART;
-	device_shutdown();
+	kernel_restart_prepare(NULL);
 	printk(KERN_EMERG "Starting new kernel\n");
 	machine_shutdown();
 	machine_kexec(image);
@@ -400,21 +422,39 @@ void kernel_kexec(void)
 }
 EXPORT_SYMBOL_GPL(kernel_kexec);
 
-void kernel_halt(void)
+/**
+ *	kernel_halt - halt the system
+ *
+ *	Shutdown everything and perform a clean system halt.
+ */
+void kernel_halt_prepare(void)
 {
 	notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
 	system_state = SYSTEM_HALT;
 	device_shutdown();
+}
+void kernel_halt(void)
+{
+	kernel_halt_prepare();
 	printk(KERN_EMERG "System halted.\n");
 	machine_halt();
 }
 EXPORT_SYMBOL_GPL(kernel_halt);
 
-void kernel_power_off(void)
+/**
+ *	kernel_power_off - power_off the system
+ *
+ *	Shutdown everything and perform a clean system power_off.
+ */
+void kernel_power_off_prepare(void)
 {
 	notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
 	system_state = SYSTEM_POWER_OFF;
 	device_shutdown();
+}
+void kernel_power_off(void)
+{
+	kernel_power_off_prepare();
 	printk(KERN_EMERG "Power down.\n");
 	machine_power_off();
 }

  parent reply	other threads:[~2005-09-20 17:42 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <F7DC2337C7631D4386A2DF6E8FB22B30047B8DAF@hdsmsx401.amr.corp.intel.com>
2005-09-10 21:07 ` reboot vs poweroff Eric W. Biederman
     [not found]   ` <m1d5ngk4xa.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2005-09-11  8:43     ` Meelis Roos
     [not found]       ` <Pine.SOC.4.61.0509111140550.9218-ptEonEWSGqKptlylMvRsHA@public.gmane.org>
2005-09-11  8:53         ` Eric W. Biederman
2005-09-20 17:42       ` Eric W. Biederman [this message]
     [not found]         ` <m14q8fhc02.fsf_-_-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2005-09-20 17:49           ` [PATCH 2/2] suspend: Cleanup calling of power off methods Eric W. Biederman
2005-09-20 21:06             ` Pavel Machek
     [not found]               ` <20050920210617.GA1779-I/5MKhXcvmPrBKCeMvbIDA@public.gmane.org>
2005-09-21  2:08                 ` Eric W. Biederman
2005-09-21 10:18                   ` Pavel Machek
2005-09-21 13:50                     ` Eric W. Biederman
     [not found]                     ` <20050921101855.GD25297-jyMamyUUXNJG4ohzP4jBZS1Fcj925eT/@public.gmane.org>
2005-09-21 16:35                       ` Linus Torvalds
2005-09-21 17:28                         ` Eric W. Biederman
     [not found]                           ` <m1slvycotk.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2005-09-21 18:02                             ` Andrew Morton
2005-09-21 17:36                         ` Alexander Nyberg
2005-09-21 18:15                           ` Andrew Morton
     [not found]                             ` <20050921111523.4b007281.akpm-3NddpPZAyC0@public.gmane.org>
2005-09-21 19:45                               ` Hugh Dickins
2005-09-21 18:35                           ` Diego Calleja
     [not found]                             ` <20050921203505.32cc714d.diegocg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2005-09-21 18:49                               ` Andrew Morton
2005-09-21 19:54                                 ` Martin J. Bligh
2005-09-26 12:09                                   ` Diego Calleja
     [not found]                                     ` <20050926140900.d070b604.diegocg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2005-09-26 13:47                                       ` Martin J. Bligh
2005-09-21 20:16                                 ` Diego Calleja
2005-09-21 19:43                           ` Russell King
     [not found]                             ` <20050921194306.GC13246-f404yB8NqCZvn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2005-09-21 20:10                               ` Andrew Morton
2005-09-22  7:15                               ` Pierre Ossman
2005-09-22  8:10                                 ` [ACPI] " Rafael J. Wysocki
     [not found]                                 ` <43325A02.90208-p3sGCRWkH8CeZLLa646FqQ@public.gmane.org>
2005-09-22  9:30                                   ` Eric W. Biederman
     [not found]                                     ` <m14q8dcuvm.fsf-T1Yj925okcoyDheHMi7gv2pdwda3JcWeAL8bYrjMMd8@public.gmane.org>
2005-09-22  9:38                                       ` Russell King
2005-09-22 10:54                                     ` Pierre Ossman
     [not found]                         ` <Pine.LNX.4.58.0509210930410.2553-hNm40g4Ew95AfugRpC6u6w@public.gmane.org>
2005-09-21 17:46                           ` Andrew Morton
     [not found]                             ` <20050921104615.2e8dd7d5.akpm-3NddpPZAyC0@public.gmane.org>
2005-09-21 18:08                               ` Eric W. Biederman
2005-09-21 18:24                                 ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m14q8fhc02.fsf_-_@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=acpi-devel@lists.sourceforge.net \
    --cc=drzeus-list@drzeus.cx \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masouds@masoud.ir \
    --cc=ncunningham@cyclades.com \
    --cc=pavel@ucw.cz \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox